|
1 |
| -import { Story } from "@storybook/react"; |
| 1 | +import { Meta, StoryObj } from "@storybook/react"; |
2 | 2 | import { ChooseOne, Cond } from "./ChooseOne";
|
3 | 3 |
|
4 |
| -export default { |
| 4 | +const meta: Meta<typeof ChooseOne> = { |
5 | 5 | title: "components/Conditionals/ChooseOne",
|
6 | 6 | component: ChooseOne,
|
7 |
| - subcomponents: { Cond }, |
8 | 7 | };
|
9 | 8 |
|
10 |
| -export const FirstIsTrue: Story = () => ( |
11 |
| - <ChooseOne> |
12 |
| - <Cond condition>The first one shows.</Cond> |
13 |
| - <Cond condition={false}>The second one does not show.</Cond> |
14 |
| - <Cond>The default does not show.</Cond> |
15 |
| - </ChooseOne> |
16 |
| -); |
| 9 | +export default meta; |
| 10 | +type Story = StoryObj<typeof ChooseOne>; |
17 | 11 |
|
18 |
| -export const SecondIsTrue: Story = () => ( |
19 |
| - <ChooseOne> |
20 |
| - <Cond condition={false}>The first one does not show.</Cond> |
21 |
| - <Cond condition>The second one shows.</Cond> |
22 |
| - <Cond>The default does not show.</Cond> |
23 |
| - </ChooseOne> |
24 |
| -); |
| 12 | +export const FirstIsTrue: Story = { |
| 13 | + args: { |
| 14 | + children: ( |
| 15 | + <> |
| 16 | + <Cond condition>The first one shows.</Cond> |
| 17 | + <Cond condition={false}>The second one does not show.</Cond> |
| 18 | + <Cond>The default does not show.</Cond> |
| 19 | + </> |
| 20 | + ), |
| 21 | + }, |
| 22 | +}; |
25 | 23 |
|
26 |
| -export const AllAreTrue: Story = () => ( |
27 |
| - <ChooseOne> |
28 |
| - <Cond condition>Only the first one shows.</Cond> |
29 |
| - <Cond condition>The second one does not show.</Cond> |
30 |
| - <Cond>The default does not show.</Cond> |
31 |
| - </ChooseOne> |
32 |
| -); |
| 24 | +export const SecondIsTrue: Story = { |
| 25 | + args: { |
| 26 | + children: ( |
| 27 | + <> |
| 28 | + <Cond condition={false}>The first one does not show.</Cond> |
| 29 | + <Cond condition>The second one shows.</Cond> |
| 30 | + <Cond>The default does not show.</Cond> |
| 31 | + </> |
| 32 | + ), |
| 33 | + }, |
| 34 | +}; |
| 35 | +export const AllAreTrue: Story = { |
| 36 | + args: { |
| 37 | + children: ( |
| 38 | + <> |
| 39 | + <Cond condition>Only the first one shows.</Cond> |
| 40 | + <Cond condition>The second one does not show.</Cond> |
| 41 | + <Cond>The default does not show.</Cond> |
| 42 | + </> |
| 43 | + ), |
| 44 | + }, |
| 45 | +}; |
33 | 46 |
|
34 |
| -export const NoneAreTrue: Story = () => ( |
35 |
| - <ChooseOne> |
36 |
| - <Cond condition={false}>The first one does not show.</Cond> |
37 |
| - <Cond condition={false}>The second one does not show.</Cond> |
38 |
| - <Cond>The default shows.</Cond> |
39 |
| - </ChooseOne> |
40 |
| -); |
| 47 | +export const NoneAreTrue: Story = { |
| 48 | + args: { |
| 49 | + children: ( |
| 50 | + <> |
| 51 | + <Cond condition={false}>The first one does not show.</Cond> |
| 52 | + <Cond condition={false}>The second one does not show.</Cond> |
| 53 | + <Cond>The default shows.</Cond> |
| 54 | + </> |
| 55 | + ), |
| 56 | + }, |
| 57 | +}; |
41 | 58 |
|
42 |
| -export const OneCond: Story = () => ( |
43 |
| - <ChooseOne> |
44 |
| - <Cond>An only child renders.</Cond> |
45 |
| - </ChooseOne> |
46 |
| -); |
| 59 | +export const OneCond: Story = { |
| 60 | + args: { |
| 61 | + children: <Cond>An only child renders.</Cond>, |
| 62 | + }, |
| 63 | +}; |
0 commit comments