mirror of
https://github.com/snowball-tools/snowballtools-base.git
synced 2024-12-22 20:47:44 +00:00
[5/n][Storybook] SegmentedControls update argTypes and use typed themes
This commit is contained in:
parent
1c05ba8822
commit
8d96be625e
@ -1,2 +1,3 @@
|
||||
export * from './SegmentedControlItem';
|
||||
export * from './SegmentedControls';
|
||||
export * from './SegmentedControls.theme';
|
||||
|
@ -1,6 +1,24 @@
|
||||
import { StoryObj, Meta } from '@storybook/react';
|
||||
|
||||
import { SegmentedControls } from 'components/shared/SegmentedControls';
|
||||
import {
|
||||
SegmentedControls,
|
||||
SegmentedControlsVariants,
|
||||
SegmentedControlsOption,
|
||||
} from 'components/shared/SegmentedControls';
|
||||
|
||||
const segmentedControlsTypes: SegmentedControlsVariants['type'][] = [
|
||||
'fixed-width',
|
||||
'full-width',
|
||||
];
|
||||
const segmentedControlsSizes: SegmentedControlsVariants['size'][] = [
|
||||
'sm',
|
||||
'md',
|
||||
];
|
||||
const segmentedControlsOptions: SegmentedControlsOption[] = [
|
||||
{ label: 'Option 1', value: '1' },
|
||||
{ label: 'Option 2', value: '2' },
|
||||
{ label: 'Option 3', value: '3' },
|
||||
];
|
||||
|
||||
const meta: Meta<typeof SegmentedControls> = {
|
||||
title: 'Components/SegmentedControls',
|
||||
@ -14,8 +32,21 @@ const meta: Meta<typeof SegmentedControls> = {
|
||||
control: 'text',
|
||||
},
|
||||
onChange: {
|
||||
action: 'onChange',
|
||||
action: 'change',
|
||||
},
|
||||
type: {
|
||||
control: 'select',
|
||||
options: segmentedControlsTypes,
|
||||
},
|
||||
size: {
|
||||
control: 'select',
|
||||
options: segmentedControlsSizes,
|
||||
},
|
||||
},
|
||||
args: {
|
||||
options: segmentedControlsOptions,
|
||||
value: '1',
|
||||
size: 'md',
|
||||
},
|
||||
};
|
||||
|
||||
@ -24,15 +55,16 @@ export default meta;
|
||||
type Story = StoryObj<typeof SegmentedControls>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: ({ options, value, onChange }) => (
|
||||
<SegmentedControls options={options} value={value} onChange={onChange} />
|
||||
render: ({ options, value, onChange, ...args }) => (
|
||||
<SegmentedControls
|
||||
options={options}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
{...args}
|
||||
/>
|
||||
),
|
||||
args: {
|
||||
options: [
|
||||
{ label: 'Option 1', value: '1' },
|
||||
{ label: 'Option 2', value: '2' },
|
||||
{ label: 'Option 3', value: '3' },
|
||||
],
|
||||
options: segmentedControlsOptions,
|
||||
value: '1',
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user