This commit is contained in:
@@ -5,7 +5,7 @@ import { Dropdown } from './Dropdown';
|
||||
const choices = [
|
||||
{ id: 'draft', label: 'Draft' },
|
||||
{ id: 'review', label: 'In review' },
|
||||
{ id: 'published', label: 'Published' }
|
||||
{ id: 'published', label: 'Published' },
|
||||
];
|
||||
|
||||
const meta = {
|
||||
@@ -15,76 +15,77 @@ const meta = {
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: 'Styled select component with label, error state, stacked/inline layout, and multiple sizes.'
|
||||
}
|
||||
}
|
||||
component:
|
||||
'Styled select component with label, error state, stacked/inline layout, and multiple sizes.',
|
||||
},
|
||||
},
|
||||
},
|
||||
argTypes: {
|
||||
label: {
|
||||
description: 'Label text shown above (stacked) or on the left (inline).',
|
||||
control: 'text',
|
||||
table: { type: { summary: 'string' } }
|
||||
table: { type: { summary: 'string' } },
|
||||
},
|
||||
value: {
|
||||
description: 'Current selected value (must match one `choices[].id`).',
|
||||
control: 'text',
|
||||
table: { type: { summary: 'string' } }
|
||||
table: { type: { summary: 'string' } },
|
||||
},
|
||||
choices: {
|
||||
description: "Options list in `{ id: string; label: string }` format.",
|
||||
description: 'Options list in `{ id: string; label: string }` format.',
|
||||
control: 'object',
|
||||
table: { type: { summary: 'Array<{ id: string; label: string }>' } }
|
||||
table: { type: { summary: 'Array<{ id: string; label: string }>' } },
|
||||
},
|
||||
size: {
|
||||
description: 'Control size.',
|
||||
options: ['sm', 'md', 'lg', 'full'],
|
||||
control: 'inline-radio',
|
||||
table: { type: { summary: "'sm' | 'md' | 'lg' | 'full'" } }
|
||||
table: { type: { summary: "'sm' | 'md' | 'lg' | 'full'" } },
|
||||
},
|
||||
layout: {
|
||||
description: 'Label/control layout mode.',
|
||||
options: ['stacked', 'inline'],
|
||||
control: 'inline-radio',
|
||||
table: { type: { summary: "'stacked' | 'inline'" } }
|
||||
table: { type: { summary: "'stacked' | 'inline'" } },
|
||||
},
|
||||
disabled: {
|
||||
description: 'Disables the field.',
|
||||
control: 'boolean',
|
||||
table: { type: { summary: 'boolean' } }
|
||||
table: { type: { summary: 'boolean' } },
|
||||
},
|
||||
required: {
|
||||
description: 'Sets the native HTML `required` attribute.',
|
||||
control: 'boolean',
|
||||
table: { type: { summary: 'boolean' } }
|
||||
table: { type: { summary: 'boolean' } },
|
||||
},
|
||||
error: {
|
||||
description: 'Error message shown below the field.',
|
||||
control: 'text',
|
||||
table: { type: { summary: 'string' } }
|
||||
table: { type: { summary: 'string' } },
|
||||
},
|
||||
className: {
|
||||
description: 'Extra CSS classes for the wrapper.',
|
||||
control: 'text',
|
||||
table: { type: { summary: 'string' } }
|
||||
table: { type: { summary: 'string' } },
|
||||
},
|
||||
selectClassName: {
|
||||
description: 'Extra CSS classes for the `<select>` element.',
|
||||
control: 'text',
|
||||
table: { type: { summary: 'string' } }
|
||||
table: { type: { summary: 'string' } },
|
||||
},
|
||||
onChange: {
|
||||
description: 'Callback fired with the newly selected value.',
|
||||
action: 'changed',
|
||||
table: { type: { summary: '(value: string) => void' } }
|
||||
}
|
||||
table: { type: { summary: '(value: string) => void' } },
|
||||
},
|
||||
},
|
||||
args: {
|
||||
label: 'Status',
|
||||
value: 'draft',
|
||||
choices,
|
||||
size: 'md',
|
||||
layout: 'stacked'
|
||||
}
|
||||
layout: 'stacked',
|
||||
},
|
||||
} satisfies Meta<typeof Dropdown>;
|
||||
|
||||
export default meta;
|
||||
@@ -103,13 +104,13 @@ export const Stacked: Story = {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const Inline: Story = {
|
||||
args: {
|
||||
layout: 'inline',
|
||||
size: 'sm'
|
||||
size: 'sm',
|
||||
},
|
||||
render: (args) => {
|
||||
const [value, setValue] = useState(args.value);
|
||||
@@ -123,19 +124,19 @@ export const Inline: Story = {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const Disabled: Story = {
|
||||
args: {
|
||||
disabled: true
|
||||
}
|
||||
disabled: true,
|
||||
},
|
||||
};
|
||||
|
||||
export const WithError: Story = {
|
||||
args: {
|
||||
error: 'Please choose a valid status'
|
||||
}
|
||||
error: 'Please choose a valid status',
|
||||
},
|
||||
};
|
||||
|
||||
export const SizeMatrix: Story = {
|
||||
@@ -149,5 +150,5 @@ export const SizeMatrix: Story = {
|
||||
<Dropdown {...args} value={value} size="full" label="Full" onChange={setValue} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user