♻️(react) update stories for themes

The stories do not need CunninghamProvider anymore since it is
handled by the configuration for the themes support. Some stories
were also using wrong colors that didn't handle multiple themes.
This commit is contained in:
Nathan Vasse
2023-09-26 11:41:55 +02:00
committed by NathanVss
parent b94abbd6b3
commit b0d68becfe
11 changed files with 902 additions and 987 deletions

View File

@@ -3,7 +3,6 @@ import React, { useEffect, useMemo, useState } from "react";
import { faker } from "@faker-js/faker"; import { faker } from "@faker-js/faker";
import { DataGrid, SortModel } from ":/components/DataGrid/index"; import { DataGrid, SortModel } from ":/components/DataGrid/index";
import { usePagination } from ":/components/Pagination"; import { usePagination } from ":/components/Pagination";
import { CunninghamProvider } from ":/components/Provider";
import { Button } from ":/components/Button"; import { Button } from ":/components/Button";
import { SimpleDataGrid } from ":/components/DataGrid/SimpleDataGrid"; import { SimpleDataGrid } from ":/components/DataGrid/SimpleDataGrid";
import { DataList } from ":/components/DataGrid/DataList"; import { DataList } from ":/components/DataGrid/DataList";
@@ -15,7 +14,6 @@ export default {
export const Empty = () => { export const Empty = () => {
return ( return (
<CunninghamProvider>
<DataGrid <DataGrid
columns={[ columns={[
{ {
@@ -26,13 +24,11 @@ export const Empty = () => {
]} ]}
rows={[]} rows={[]}
/> />
</CunninghamProvider>
); );
}; };
export const Loading = () => { export const Loading = () => {
return ( return (
<CunninghamProvider>
<DataGrid <DataGrid
columns={[ columns={[
{ {
@@ -44,7 +40,6 @@ export const Loading = () => {
rows={[]} rows={[]}
isLoading={true} isLoading={true}
/> />
</CunninghamProvider>
); );
}; };
@@ -61,7 +56,6 @@ export const ClientSideWithoutPagination = () => {
[], [],
); );
return ( return (
<CunninghamProvider>
<SimpleDataGrid <SimpleDataGrid
columns={[ columns={[
{ {
@@ -97,7 +91,6 @@ export const ClientSideWithoutPagination = () => {
]} ]}
rows={database} rows={database}
/> />
</CunninghamProvider>
); );
}; };
@@ -116,7 +109,7 @@ export const ClientSideWithPagination = () => {
const [rowSelection, setRowSelection] = useState({}); const [rowSelection, setRowSelection] = useState({});
return ( return (
<CunninghamProvider> <>
<SimpleDataGrid <SimpleDataGrid
columns={[ columns={[
{ {
@@ -149,7 +142,7 @@ export const ClientSideWithPagination = () => {
onRowSelectionChange={setRowSelection} onRowSelectionChange={setRowSelection}
/> />
<div>Selected rows: {Object.keys(rowSelection).join(", ")}</div> <div>Selected rows: {Object.keys(rowSelection).join(", ")}</div>
</CunninghamProvider> </>
); );
}; };
@@ -208,7 +201,6 @@ export const FullServerSide = () => {
}, [pagination.page, sortModel]); }, [pagination.page, sortModel]);
return ( return (
<CunninghamProvider>
<DataGrid <DataGrid
columns={[ columns={[
{ {
@@ -249,7 +241,6 @@ export const FullServerSide = () => {
rowSelection={rowSelection} rowSelection={rowSelection}
onRowSelectionChange={setRowSelection} onRowSelectionChange={setRowSelection}
/> />
</CunninghamProvider>
); );
}; };
@@ -265,7 +256,6 @@ export const DataListOnly = () => {
); );
return ( return (
<CunninghamProvider>
<DataList <DataList
rows={database} rows={database}
columns={[ columns={[
@@ -284,6 +274,5 @@ export const DataListOnly = () => {
}, },
]} ]}
/> />
</CunninghamProvider>
); );
}; };

View File

@@ -122,7 +122,7 @@ export const Success = {
export const Group = () => ( export const Group = () => (
<div> <div>
<div className="fs-l fw-bold mb-t">Your offices</div> <div className="fs-l fw-bold mb-t clr-greyscale-900">Your offices</div>
<CheckboxGroup> <CheckboxGroup>
<Checkbox label="Paris" /> <Checkbox label="Paris" />
<Checkbox label="New York" text="United States" checked={true} /> <Checkbox label="New York" text="United States" checked={true} />
@@ -135,7 +135,7 @@ export const Group = () => (
export const GroupError = () => ( export const GroupError = () => (
<div> <div>
<div className="fs-l fw-bold mb-t">Your offices</div> <div className="fs-l fw-bold mb-t clr-greyscale-900">Your offices</div>
<CheckboxGroup state="error" text="An important error message"> <CheckboxGroup state="error" text="An important error message">
<Checkbox label="Paris" /> <Checkbox label="Paris" />
<Checkbox label="New York" text="United States" checked={true} /> <Checkbox label="New York" text="United States" checked={true} />
@@ -148,7 +148,7 @@ export const GroupError = () => (
export const GroupSuccess = () => ( export const GroupSuccess = () => (
<div> <div>
<div className="fs-l fw-bold mb-t">Your offices</div> <div className="fs-l fw-bold mb-t clr-greyscale-900">Your offices</div>
<CheckboxGroup state="success" text="Success message !"> <CheckboxGroup state="success" text="Success message !">
<Checkbox label="Paris" /> <Checkbox label="Paris" />
<Checkbox label="New York" text="United States" checked={true} /> <Checkbox label="New York" text="United States" checked={true} />

View File

@@ -16,16 +16,12 @@ export default {
} as Meta<typeof DatePicker>; } as Meta<typeof DatePicker>;
const Template: StoryFn<typeof DatePicker> = (args) => ( const Template: StoryFn<typeof DatePicker> = (args) => (
<CunninghamProvider>
<DatePicker {...args} label="Pick a date" /> <DatePicker {...args} label="Pick a date" />
</CunninghamProvider>
); );
export const Default = () => ( export const Default = () => (
<div style={{ minHeight: "400px" }}> <div style={{ minHeight: "400px" }}>
<CunninghamProvider>
<DatePicker label="Pick a date" /> <DatePicker label="Pick a date" />
</CunninghamProvider>
</div> </div>
); );
@@ -98,13 +94,11 @@ export const Fullwidth = {
export const CustomLocale = () => ( export const CustomLocale = () => (
<div style={{ minHeight: "400px" }}> <div style={{ minHeight: "400px" }}>
<CunninghamProvider>
<DatePicker <DatePicker
label="Pick a date" label="Pick a date"
locale="hi-IN-u-ca-indian" locale="hi-IN-u-ca-indian"
defaultValue="2023-06-25T00:00:00.000+00:00" defaultValue="2023-06-25T00:00:00.000+00:00"
/> />
</CunninghamProvider>
</div> </div>
); );
@@ -122,9 +116,8 @@ export const CunninghamLocale = () => (
export const Controlled = () => { export const Controlled = () => {
const [value, setValue] = useState<string | null>("2023-04-25T12:00:00.000Z"); const [value, setValue] = useState<string | null>("2023-04-25T12:00:00.000Z");
return ( return (
<CunninghamProvider>
<div>
<div> <div>
<div className="clr-greyscale-900">
Value: <span>{value?.toString()}</span> Value: <span>{value?.toString()}</span>
</div> </div>
<DatePicker <DatePicker
@@ -136,7 +129,6 @@ export const Controlled = () => {
/> />
<Button onClick={() => setValue("")}>Reset</Button> <Button onClick={() => setValue("")}>Reset</Button>
</div> </div>
</CunninghamProvider>
); );
}; };
@@ -153,7 +145,6 @@ export const ReactHookForm = () => {
}); });
return ( return (
<CunninghamProvider>
<FormProvider {...methods}> <FormProvider {...methods}>
<form <form
style={{ style={{
@@ -168,23 +159,19 @@ export const ReactHookForm = () => {
<Button fullWidth={true}>Submit</Button> <Button fullWidth={true}>Submit</Button>
</form> </form>
</FormProvider> </FormProvider>
</CunninghamProvider>
); );
}; };
export const RangeDefault = () => { export const RangeDefault = () => {
return ( return (
<div style={{ minHeight: "400px" }}> <div style={{ minHeight: "400px" }}>
<CunninghamProvider>
<DateRangePicker startLabel="Start date" endLabel="Due date" /> <DateRangePicker startLabel="Start date" endLabel="Due date" />
</CunninghamProvider>
</div> </div>
); );
}; };
export const RangeDefaultValue = () => { export const RangeDefaultValue = () => {
return ( return (
<CunninghamProvider>
<DateRangePicker <DateRangePicker
startLabel="Start date" startLabel="Start date"
endLabel="Due date" endLabel="Due date"
@@ -193,7 +180,6 @@ export const RangeDefaultValue = () => {
"2023-06-23T00:00:00.000+00:00", "2023-06-23T00:00:00.000+00:00",
]} ]}
/> />
</CunninghamProvider>
); );
}; };
@@ -204,8 +190,7 @@ export const RangeControlled = () => {
]); ]);
return ( return (
<div> <div>
<CunninghamProvider> <div className="clr-greyscale-900">Value: {value?.join(" ")}</div>
<div>Value: {value?.join(" ")}</div>
<DateRangePicker <DateRangePicker
startLabel="Start date" startLabel="Start date"
endLabel="Due date" endLabel="Due date"
@@ -215,7 +200,6 @@ export const RangeControlled = () => {
onChange={(e) => setValue(e)} onChange={(e) => setValue(e)}
/> />
<Button onClick={() => setValue(null)}>Reset</Button> <Button onClick={() => setValue(null)}>Reset</Button>
</CunninghamProvider>
</div> </div>
); );
}; };

View File

@@ -5,7 +5,6 @@ import { useForm, FormProvider } from "react-hook-form";
import * as Yup from "yup"; import * as Yup from "yup";
import { RhfInput } from ":/components/Forms/Input/stories-utils"; import { RhfInput } from ":/components/Forms/Input/stories-utils";
import { Button } from ":/components/Button"; import { Button } from ":/components/Button";
import { CunninghamProvider } from ":/components/Provider";
import { Radio, RadioGroup } from ":/components/Forms/Radio"; import { Radio, RadioGroup } from ":/components/Forms/Radio";
import { RhfSelect } from ":/components/Forms/Select/stories-utils"; import { RhfSelect } from ":/components/Forms/Select/stories-utils";
import { import {
@@ -55,7 +54,6 @@ const SportsBase = ({ values }: SportProps) => {
}, [values]); }, [values]);
return ( return (
<CunninghamProvider>
<FormProvider {...methods}> <FormProvider {...methods}>
<form <form
style={{ style={{
@@ -167,7 +165,6 @@ const SportsBase = ({ values }: SportProps) => {
</a> </a>
</form> </form>
</FormProvider> </FormProvider>
</CunninghamProvider>
); );
}; };

View File

@@ -5,7 +5,6 @@ import { Input } from ":/components/Forms/Input";
import { Checkbox } from ":/components/Forms/Checkbox"; import { Checkbox } from ":/components/Forms/Checkbox";
import { Button } from ":/components/Button"; import { Button } from ":/components/Button";
import { Select } from ":/components/Forms/Select"; import { Select } from ":/components/Forms/Select";
import { CunninghamProvider } from ":/components/Provider";
import { FileUploader } from ":/components/Forms/FileUploader"; import { FileUploader } from ":/components/Forms/FileUploader";
import { Switch } from ":/components/Forms/Switch"; import { Switch } from ":/components/Forms/Switch";
import { Radio } from ":/components/Forms/Radio"; import { Radio } from ":/components/Forms/Radio";
@@ -55,7 +54,6 @@ export const Login = () => {
export const Application = () => { export const Application = () => {
return ( return (
<CunninghamProvider>
<form <form
style={{ style={{
display: "flex", display: "flex",
@@ -101,9 +99,7 @@ export const Application = () => {
<Input label="City" fullWidth={true} /> <Input label="City" fullWidth={true} />
</div> </div>
<div> <div>
<div className="fs-l clr-greyscale-800 mb-t"> <div className="fs-l clr-greyscale-800 mb-t">Your curriculum vitae</div>
Your curriculum vitae
</div>
<FileUploader <FileUploader
fullWidth={true} fullWidth={true}
text="pdf only ( 4mb maximum )" text="pdf only ( 4mb maximum )"
@@ -124,13 +120,11 @@ export const Application = () => {
Need help ? Need help ?
</a> </a>
</form> </form>
</CunninghamProvider>
); );
}; };
export const Sports = () => { export const Sports = () => {
return ( return (
<CunninghamProvider>
<form <form
style={{ style={{
display: "flex", display: "flex",
@@ -138,6 +132,7 @@ export const Sports = () => {
gap: "1rem", gap: "1rem",
width: "400px", width: "400px",
}} }}
onSubmit={(e) => e.preventDefault()}
> >
<h1 <h1
className="fs-h3 fw-bold clr-greyscale-900" className="fs-h3 fw-bold clr-greyscale-900"
@@ -217,13 +212,11 @@ export const Sports = () => {
Need help ? Need help ?
</a> </a>
</form> </form>
</CunninghamProvider>
); );
}; };
export const SportsDisabled = () => { export const SportsDisabled = () => {
const [withValues, setWithValues] = useState(false); const [withValues, setWithValues] = useState(false);
return ( return (
<CunninghamProvider>
<form <form
style={{ style={{
display: "flex", display: "flex",
@@ -241,12 +234,7 @@ export const SportsDisabled = () => {
<div> <div>
<div className="fs-l clr-greyscale-800 mb-t">Gender</div> <div className="fs-l clr-greyscale-800 mb-t">Gender</div>
<div style={{ display: "flex", gap: "0.5rem" }}> <div style={{ display: "flex", gap: "0.5rem" }}>
<Radio <Radio name="gender" label="Male" fullWidth={true} disabled={true} />
name="gender"
label="Male"
fullWidth={true}
disabled={true}
/>
<Radio name="gender" label="Female" disabled={true} /> <Radio name="gender" label="Female" disabled={true} />
<Radio name="gender" label="Other" disabled={true} /> <Radio name="gender" label="Other" disabled={true} />
</div> </div>
@@ -315,10 +303,7 @@ export const SportsDisabled = () => {
endLabel="End date" endLabel="End date"
value={ value={
withValues withValues
? [ ? ["2023-05-23T00:00:00.000+00:00", "2023-06-23T00:00:00.000+00:00"]
"2023-05-23T00:00:00.000+00:00",
"2023-06-23T00:00:00.000+00:00",
]
: undefined : undefined
} }
fullWidth={true} fullWidth={true}
@@ -340,6 +325,5 @@ export const SportsDisabled = () => {
Need help ? Need help ?
</a> </a>
</form> </form>
</CunninghamProvider>
); );
}; };

View File

@@ -1,19 +1,12 @@
import { Meta, StoryFn } from "@storybook/react"; import { Meta } from "@storybook/react";
import React, { useEffect, useRef, useState } from "react"; import React, { useEffect, useRef, useState } from "react";
import { faker } from "@faker-js/faker"; import { faker } from "@faker-js/faker";
import { import {
FileUploader, FileUploader,
FileUploaderRefType, FileUploaderRefType,
} from ":/components/Forms/FileUploader/index"; } from ":/components/Forms/FileUploader/index";
import { CunninghamProvider } from ":/components/Provider";
import { Button } from ":/components/Button"; import { Button } from ":/components/Button";
const Template: StoryFn<typeof FileUploader> = (args) => (
<CunninghamProvider>
<FileUploader {...args} />
</CunninghamProvider>
);
const FAKE_FILES = [ const FAKE_FILES = [
new File(["42"], faker.lorem.sentence(5) + "pdf"), new File(["42"], faker.lorem.sentence(5) + "pdf"),
new File(["42"], faker.lorem.sentence(1) + "pdf"), new File(["42"], faker.lorem.sentence(1) + "pdf"),
@@ -24,7 +17,6 @@ const FAKE_FILES = [
const meta: Meta<typeof FileUploader> = { const meta: Meta<typeof FileUploader> = {
title: "Components/Forms/FileUploader", title: "Components/Forms/FileUploader",
component: FileUploader, component: FileUploader,
render: Template,
}; };
export default meta; export default meta;
@@ -146,7 +138,7 @@ export const MonoStatesShowcase = {
// the fake default files. In all other step we want it to be persistant in order to see transitions ( like the // the fake default files. In all other step we want it to be persistant in order to see transitions ( like the
// border color ). // border color ).
return ( return (
<Template <FileUploader
key={step === "fileSelected" ? step : "const"} key={step === "fileSelected" ? step : "const"}
{...stepToProps[step]} {...stepToProps[step]}
/> />
@@ -159,7 +151,6 @@ export const MonoValue = {
const ref = useRef<FileUploaderRefType>(null); const ref = useRef<FileUploaderRefType>(null);
const [value, setValue] = useState<File[]>([]); const [value, setValue] = useState<File[]>([]);
return ( return (
<CunninghamProvider>
<div> <div>
<div>Value: {value.map((file) => file.name).join(", ")}</div> <div>Value: {value.map((file) => file.name).join(", ")}</div>
<FileUploader <FileUploader
@@ -168,7 +159,6 @@ export const MonoValue = {
/> />
<Button onClick={() => ref.current?.reset()}>Reset</Button> <Button onClick={() => ref.current?.reset()}>Reset</Button>
</div> </div>
</CunninghamProvider>
); );
}, },
}; };
@@ -273,7 +263,7 @@ export const MultiStatesShowcase = {
// the fake default files. In all other step we want it to be persistant in order to see transitions ( like the // the fake default files. In all other step we want it to be persistant in order to see transitions ( like the
// border color ). // border color ).
return ( return (
<Template <FileUploader
key={step === "fileSelected" ? step : "const"} key={step === "fileSelected" ? step : "const"}
multiple={true} multiple={true}
{...stepToProps[step]} {...stepToProps[step]}
@@ -287,7 +277,6 @@ export const MultiValue = {
const ref = useRef<FileUploaderRefType>(null); const ref = useRef<FileUploaderRefType>(null);
const [value, setValue] = useState<File[]>([]); const [value, setValue] = useState<File[]>([]);
return ( return (
<CunninghamProvider>
<div> <div>
<div>Value: {value.map((file) => file.name).join(", ")}</div> <div>Value: {value.map((file) => file.name).join(", ")}</div>
<FileUploader <FileUploader
@@ -297,7 +286,6 @@ export const MultiValue = {
/> />
<Button onClick={() => ref.current?.reset()}>Reset</Button> <Button onClick={() => ref.current?.reset()}>Reset</Button>
</div> </div>
</CunninghamProvider>
); );
}, },
}; };
@@ -314,7 +302,6 @@ export const Form = {
}; };
return ( return (
<CunninghamProvider>
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<div> <div>
<FileUploader <FileUploader
@@ -336,7 +323,6 @@ export const Form = {
<Button>Submit</Button> <Button>Submit</Button>
</div> </div>
</form> </form>
</CunninghamProvider>
); );
}, },
}; };

View File

@@ -163,7 +163,7 @@ export const Controlled = () => {
const [value, setValue] = React.useState("I am controlled"); const [value, setValue] = React.useState("I am controlled");
return ( return (
<div> <div>
<div> <div className="clr-greyscale-900">
Value: <span>{value}</span> Value: <span>{value}</span>
</div> </div>
<Input <Input

View File

@@ -7,7 +7,6 @@ import { yupResolver } from "@hookform/resolvers/yup";
import { onSubmit } from ":/components/Forms/Examples/ReactHookForm/reactHookFormUtils"; import { onSubmit } from ":/components/Forms/Examples/ReactHookForm/reactHookFormUtils";
import { Select } from ":/components/Forms/Select"; import { Select } from ":/components/Forms/Select";
import { Button } from ":/components/Button"; import { Button } from ":/components/Button";
import { CunninghamProvider } from ":/components/Provider";
import { RhfSelect } from ":/components/Forms/Select/stories-utils"; import { RhfSelect } from ":/components/Forms/Select/stories-utils";
export default { export default {
@@ -17,9 +16,7 @@ export default {
const Template: StoryFn<typeof Select> = (args) => ( const Template: StoryFn<typeof Select> = (args) => (
<div style={{ paddingBottom: "200px" }}> <div style={{ paddingBottom: "200px" }}>
<CunninghamProvider>
<Select {...args} /> <Select {...args} />
</CunninghamProvider>
</div> </div>
); );
@@ -75,7 +72,6 @@ export const HiddenLabel = {
export const Controlled = () => { export const Controlled = () => {
const [value, setValue] = useState(OPTIONS[8].value); const [value, setValue] = useState(OPTIONS[8].value);
return ( return (
<CunninghamProvider>
<div> <div>
<div> <div>
Value: <span>{value}</span> Value: <span>{value}</span>
@@ -96,7 +92,6 @@ export const Controlled = () => {
Set {OPTIONS[1].label} Set {OPTIONS[1].label}
</Button> </Button>
</div> </div>
</CunninghamProvider>
); );
}; };
@@ -151,7 +146,6 @@ export const SearchableDisabled = {
export const SearchableControlled = () => { export const SearchableControlled = () => {
const [value, setValue] = useState(OPTIONS[8].value); const [value, setValue] = useState(OPTIONS[8].value);
return ( return (
<CunninghamProvider>
<div> <div>
<div> <div>
Value: <span>{value}</span> Value: <span>{value}</span>
@@ -173,7 +167,6 @@ export const SearchableControlled = () => {
Set {OPTIONS[1].label} Set {OPTIONS[1].label}
</Button> </Button>
</div> </div>
</CunninghamProvider>
); );
}; };
@@ -244,7 +237,6 @@ export const FormExample = () => {
}; };
return ( return (
<CunninghamProvider>
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<div className="mb-s"> <div className="mb-s">
<Select <Select
@@ -342,7 +334,6 @@ export const FormExample = () => {
</div> </div>
<Button>Submit</Button> <Button>Submit</Button>
</form> </form>
</CunninghamProvider>
); );
}; };
@@ -374,7 +365,6 @@ export const ReactHookForm = () => {
}); });
return ( return (
<CunninghamProvider>
<FormProvider {...methods}> <FormProvider {...methods}>
<form <form
style={{ style={{
@@ -385,7 +375,9 @@ export const ReactHookForm = () => {
}} }}
onSubmit={methods.handleSubmit(onSubmit)} onSubmit={methods.handleSubmit(onSubmit)}
> >
<div>Where will the 2024 Olympics take place?</div> <div className="clr-greyscale-900">
Where will the 2024 Olympics take place?
</div>
<RhfSelect <RhfSelect
name="joTown" name="joTown"
label="Select a city" label="Select a city"
@@ -408,6 +400,5 @@ export const ReactHookForm = () => {
<Button fullWidth={true}>Submit</Button> <Button fullWidth={true}>Submit</Button>
</form> </form>
</FormProvider> </FormProvider>
</CunninghamProvider>
); );
}; };

View File

@@ -6,7 +6,6 @@ import { Meta, StoryFn } from "@storybook/react";
import { faker } from "@faker-js/faker"; import { faker } from "@faker-js/faker";
import { onSubmit } from ":/components/Forms/Examples/ReactHookForm/reactHookFormUtils"; import { onSubmit } from ":/components/Forms/Examples/ReactHookForm/reactHookFormUtils";
import { Select } from ":/components/Forms/Select"; import { Select } from ":/components/Forms/Select";
import { CunninghamProvider } from ":/components/Provider";
import { Button } from ":/components/Button"; import { Button } from ":/components/Button";
import { RhfSelect } from ":/components/Forms/Select/stories-utils"; import { RhfSelect } from ":/components/Forms/Select/stories-utils";
@@ -15,13 +14,13 @@ export default {
component: Select, component: Select,
} as Meta<typeof Select>; } as Meta<typeof Select>;
const Template: StoryFn<typeof Select> = (args) => ( const Template: StoryFn<typeof Select> = (args) => {
return (
<div style={{ paddingBottom: "200px" }}> <div style={{ paddingBottom: "200px" }}>
<CunninghamProvider>
<Select {...args} multi={true} /> <Select {...args} multi={true} />
</CunninghamProvider>
</div> </div>
); );
};
const CITIES = Array.from({ length: 10 }).map(() => faker.location.city()); const CITIES = Array.from({ length: 10 }).map(() => faker.location.city());
const OPTIONS = CITIES.map((city) => ({ const OPTIONS = CITIES.map((city) => ({
@@ -71,9 +70,8 @@ export const HiddenLabel = {
export const Controlled = () => { export const Controlled = () => {
const [value, setValue] = useState([OPTIONS[6].value, OPTIONS[8].value]); const [value, setValue] = useState([OPTIONS[6].value, OPTIONS[8].value]);
return ( return (
<CunninghamProvider>
<div>
<div> <div>
<div className="clr-greyscale-900">
Value: <span>{JSON.stringify(value)}</span> Value: <span>{JSON.stringify(value)}</span>
</div> </div>
<Select <Select
@@ -85,7 +83,6 @@ export const Controlled = () => {
/> />
<Button onClick={() => setValue([])}>Reset</Button> <Button onClick={() => setValue([])}>Reset</Button>
</div> </div>
</CunninghamProvider>
); );
}; };
@@ -136,9 +133,8 @@ export const SearchableDisabled = {
export const SearchableControlled = () => { export const SearchableControlled = () => {
const [value, setValue] = useState([OPTIONS[6].value, OPTIONS[8].value]); const [value, setValue] = useState([OPTIONS[6].value, OPTIONS[8].value]);
return ( return (
<CunninghamProvider>
<div>
<div> <div>
<div className="clr-greyscale-900">
Value: <span>{JSON.stringify(value)}</span> Value: <span>{JSON.stringify(value)}</span>
</div> </div>
<Select <Select
@@ -151,7 +147,6 @@ export const SearchableControlled = () => {
/> />
<Button onClick={() => setValue([])}>Reset</Button> <Button onClick={() => setValue([])}>Reset</Button>
</div> </div>
</CunninghamProvider>
); );
}; };
@@ -232,7 +227,6 @@ export const FormExample = () => {
}; };
return ( return (
<CunninghamProvider>
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<div className="mb-s"> <div className="mb-s">
<Select <Select
@@ -314,7 +308,6 @@ export const FormExample = () => {
<Button>Submit</Button> <Button>Submit</Button>
</form> </form>
</CunninghamProvider>
); );
}; };
@@ -353,7 +346,6 @@ export const ReactHookForm = () => {
}); });
return ( return (
<CunninghamProvider>
<FormProvider {...methods}> <FormProvider {...methods}>
<form <form
style={{ style={{
@@ -364,7 +356,9 @@ export const ReactHookForm = () => {
}} }}
onSubmit={methods.handleSubmit(onSubmit)} onSubmit={methods.handleSubmit(onSubmit)}
> >
<div>Which cities are capital of countries ?</div> <div className="clr-greyscale-900">
Which cities are capital of countries ?
</div>
<RhfSelect <RhfSelect
name="capitalCity" name="capitalCity"
label="Select a city" label="Select a city"
@@ -392,6 +386,5 @@ export const ReactHookForm = () => {
<Button fullWidth={true}>Submit</Button> <Button fullWidth={true}>Submit</Button>
</form> </form>
</FormProvider> </FormProvider>
</CunninghamProvider>
); );
}; };

View File

@@ -119,7 +119,9 @@ export const Controlled = {
const [checked, setChecked] = React.useState(false); const [checked, setChecked] = React.useState(false);
return ( return (
<div> <div>
<div>Value: {JSON.stringify(checked)}</div> <div className="clr-greyscale-900">
Value: {JSON.stringify(checked)}
</div>
<Switch <Switch
checked={checked} checked={checked}
onChange={(e) => setChecked(e.target.checked)} onChange={(e) => setChecked(e.target.checked)}

View File

@@ -1,7 +1,6 @@
import { Meta } from "@storybook/react"; import { Meta } from "@storybook/react";
import React, { useEffect, useMemo, useState } from "react"; import React, { useEffect, useMemo, useState } from "react";
import { Pagination, usePagination } from ":/components/Pagination/index"; import { Pagination, usePagination } from ":/components/Pagination/index";
import { CunninghamProvider } from ":/components/Provider";
export default { export default {
title: "Components/Pagination", title: "Components/Pagination",
@@ -13,11 +12,7 @@ export const Basic = () => {
defaultPagesCount: 100, defaultPagesCount: 100,
defaultPage: 50, defaultPage: 50,
}); });
return ( return <Pagination {...pagination} />;
<CunninghamProvider>
<Pagination {...pagination} />
</CunninghamProvider>
);
}; };
export const List = () => { export const List = () => {
@@ -49,7 +44,6 @@ export const List = () => {
}, [pagination.page]); }, [pagination.page]);
return ( return (
<CunninghamProvider>
<div> <div>
<div> <div>
{items.map((item) => ( {items.map((item) => (
@@ -60,7 +54,6 @@ export const List = () => {
</div> </div>
<Pagination {...pagination} /> <Pagination {...pagination} />
</div> </div>
</CunninghamProvider>
); );
}; };
@@ -76,9 +69,5 @@ export const ForcePage = () => {
clearTimeout(timeout); clearTimeout(timeout);
}; };
}, []); }, []);
return ( return <Pagination {...pagination} />;
<CunninghamProvider>
<Pagination {...pagination} />
</CunninghamProvider>
);
}; };