From d76db4fb96a1c650baab06972395ceec8e48faf8 Mon Sep 17 00:00:00 2001 From: Vivian Phung Date: Tue, 14 May 2024 16:39:29 -0400 Subject: [PATCH] [12/n][Storybook] Select argTypes and typed variants --- .../src/components/shared/Select/index.ts | 1 + .../src/stories/Components/Select.stories.tsx | 178 +++++++++++++----- 2 files changed, 130 insertions(+), 49 deletions(-) diff --git a/packages/frontend/src/components/shared/Select/index.ts b/packages/frontend/src/components/shared/Select/index.ts index 7669724a..6540c2f0 100644 --- a/packages/frontend/src/components/shared/Select/index.ts +++ b/packages/frontend/src/components/shared/Select/index.ts @@ -1,2 +1,3 @@ export * from './Select'; export * from './SelectItem'; +export * from './Select.theme'; diff --git a/packages/frontend/src/stories/Components/Select.stories.tsx b/packages/frontend/src/stories/Components/Select.stories.tsx index 488f6717..ff41209f 100644 --- a/packages/frontend/src/stories/Components/Select.stories.tsx +++ b/packages/frontend/src/stories/Components/Select.stories.tsx @@ -1,6 +1,21 @@ import { StoryObj, Meta } from '@storybook/react'; +import { PlusIcon } from 'components/shared/CustomIcon'; -import { Select } from 'components/shared/Select'; +import { Select, SelectOption, SelectTheme } from 'components/shared/Select'; + +const selectOrientation: SelectTheme['orientation'][] = [ + 'horizontal', + 'vertical', +]; +const selectVariants: SelectTheme['variant'][] = ['default', 'danger']; +const selectSizes: SelectTheme['size'][] = ['sm', 'md']; +const selectError: SelectTheme['error'][] = [true, false]; +const selectIsOpen: SelectTheme['isOpen'][] = [true, false]; +const selectOptions: SelectOption[] = [ + { label: 'Option 1', value: 'option1' }, + { label: 'Option 2', value: 'option2' }, + { label: 'Option 3', value: 'option3' }, +]; const meta: Meta = { title: 'Components/Select', @@ -17,13 +32,13 @@ const meta: Meta = { control: 'text', }, multiple: { - control: 'boolean', + type: 'boolean', }, searchable: { - control: 'boolean', + type: 'boolean', }, clearable: { - control: 'boolean', + type: 'boolean', }, leftIcon: { control: 'text', @@ -35,7 +50,7 @@ const meta: Meta = { control: 'text', }, hideValues: { - control: 'boolean', + type: 'boolean', }, value: { control: 'object', @@ -46,6 +61,29 @@ const meta: Meta = { onChange: { action: 'change', }, + orientation: { + control: 'radio', + options: selectOrientation, + }, + placeholder: { + control: 'text', + }, + variant: { + control: 'select', + options: selectVariants, + }, + size: { + control: 'select', + options: selectSizes, + }, + error: { + control: 'radio', + options: selectError, + }, + isOpen: { + control: 'radio', + options: selectIsOpen, + }, }, }; @@ -54,52 +92,94 @@ export default meta; type Story = StoryObj; export const Default: Story = { - render: ({ - options, - label, - description, - multiple, - searchable, - clearable, - leftIcon, - rightIcon, - helperText, - hideValues, - value, - onClear, - onChange, - }) => ( -