forked from cerc-io/snowballtools-base
[13/n][Storybook] Radio argTypes update (#50)
This commit is contained in:
commit
1c05ba8822
@ -1,11 +1,17 @@
|
|||||||
import { StoryObj, Meta } from '@storybook/react';
|
import { StoryObj, Meta } from '@storybook/react';
|
||||||
|
|
||||||
import { Radio, RadioTheme } from 'components/shared/Radio';
|
import { Radio, RadioOption, RadioTheme } from 'components/shared/Radio';
|
||||||
|
|
||||||
|
const radioVariants: RadioTheme['variant'][] = ['unstyled', 'card'];
|
||||||
const radioOrientation: RadioTheme['orientation'][] = [
|
const radioOrientation: RadioTheme['orientation'][] = [
|
||||||
'horizontal',
|
'horizontal',
|
||||||
'vertical',
|
'vertical',
|
||||||
];
|
];
|
||||||
|
const radioOptions: RadioOption[] = [
|
||||||
|
{ label: 'Option 1', value: 'option1' },
|
||||||
|
{ label: 'Option 2', value: 'option2' },
|
||||||
|
{ label: 'Option 3', value: 'option3' },
|
||||||
|
];
|
||||||
|
|
||||||
const meta: Meta<typeof Radio> = {
|
const meta: Meta<typeof Radio> = {
|
||||||
title: 'Components/Radio',
|
title: 'Components/Radio',
|
||||||
@ -20,11 +26,22 @@ const meta: Meta<typeof Radio> = {
|
|||||||
options: radioOrientation,
|
options: radioOrientation,
|
||||||
},
|
},
|
||||||
value: {
|
value: {
|
||||||
control: 'text',
|
control: 'object',
|
||||||
},
|
},
|
||||||
onValueChange: {
|
onValueChange: {
|
||||||
action: 'onValueChange',
|
action: 'valueChange',
|
||||||
},
|
},
|
||||||
|
variant: {
|
||||||
|
control: 'select',
|
||||||
|
options: radioVariants,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
args: {
|
||||||
|
options: radioOptions,
|
||||||
|
orientation: 'horizontal',
|
||||||
|
value: 'option1',
|
||||||
|
onValueChange: (value: string) => console.log(value),
|
||||||
|
variant: 'unstyled',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -33,43 +50,56 @@ export default meta;
|
|||||||
type Story = StoryObj<typeof Radio>;
|
type Story = StoryObj<typeof Radio>;
|
||||||
|
|
||||||
export const Default: Story = {
|
export const Default: Story = {
|
||||||
render: ({ options, orientation, value, onValueChange }) => (
|
render: ({ options, orientation, value, onValueChange, ...args }) => (
|
||||||
<Radio
|
<Radio
|
||||||
options={options}
|
options={options}
|
||||||
orientation={orientation}
|
orientation={orientation}
|
||||||
value={value}
|
value={value}
|
||||||
onValueChange={onValueChange}
|
onValueChange={onValueChange}
|
||||||
|
{...args}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
args: {
|
args: {
|
||||||
options: [
|
options: radioOptions,
|
||||||
{ label: 'Option 1', value: 'option1' },
|
|
||||||
{ label: 'Option 2', value: 'option2' },
|
|
||||||
{ label: 'Option 3', value: 'option3' },
|
|
||||||
],
|
|
||||||
orientation: 'horizontal',
|
orientation: 'horizontal',
|
||||||
value: 'option1',
|
value: 'option1',
|
||||||
onValueChange: (value: string) => console.log(value),
|
onValueChange: (value) => console.log(value),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Vertical: Story = {
|
export const Vertical: Story = {
|
||||||
render: ({ options, orientation, value, onValueChange }) => (
|
render: ({ options, orientation, value, onValueChange, ...args }) => (
|
||||||
<Radio
|
<Radio
|
||||||
options={options}
|
options={options}
|
||||||
orientation={orientation}
|
orientation={orientation}
|
||||||
value={value}
|
value={value}
|
||||||
onValueChange={onValueChange}
|
onValueChange={onValueChange}
|
||||||
|
{...args}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
args: {
|
args: {
|
||||||
options: [
|
options: radioOptions,
|
||||||
{ label: 'Option 1', value: 'option1' },
|
|
||||||
{ label: 'Option 2', value: 'option2' },
|
|
||||||
{ label: 'Option 3', value: 'option3' },
|
|
||||||
],
|
|
||||||
orientation: 'vertical',
|
orientation: 'vertical',
|
||||||
value: 'option1',
|
value: 'option1',
|
||||||
onValueChange: (value: string) => console.log(value),
|
onValueChange: (value) => console.log(value),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Card: Story = {
|
||||||
|
render: ({ options, orientation, value, onValueChange, ...args }) => (
|
||||||
|
<Radio
|
||||||
|
options={options}
|
||||||
|
orientation={orientation}
|
||||||
|
value={value}
|
||||||
|
onValueChange={onValueChange}
|
||||||
|
{...args}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
args: {
|
||||||
|
options: radioOptions,
|
||||||
|
orientation: 'horizontal',
|
||||||
|
value: 'option1',
|
||||||
|
onValueChange: (value: string) => console.log(value),
|
||||||
|
variant: 'card',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user