diff --git a/src/tedi/components/form/search/search.stories.tsx b/src/tedi/components/form/search/search.stories.tsx index 4ce133e10..00f773170 100644 --- a/src/tedi/components/form/search/search.stories.tsx +++ b/src/tedi/components/form/search/search.stories.tsx @@ -31,88 +31,89 @@ export default meta; type Story = StoryObj; const stateArray = ['Default', 'Hover', 'Focus', 'Active', 'Disabled']; +const sizeArray: SearchProps['size'][] = ['small', 'default', 'large']; interface TemplateStateProps extends SearchProps { array: typeof stateArray; } -const sizeArray: SearchProps['size'][] = ['small', 'default', 'large']; - interface TemplateMultipleProps extends SearchProps { array: Type[]; property: keyof SearchProps; } const TemplateColumn: StoryFn = (args) => { - const { array, property, ...textFieldProps } = args; + const { array, property, id = 'search', ...textFieldProps } = args; return (
- {array.map((value, key) => ( - - - {value ? value.charAt(0).toUpperCase() + value.slice(1) : ''} - - - - - - - - - - ))} + {array.map((value, key) => { + const baseId = `${id}-${property}-${value}`; + + return ( + + + {value ? value.charAt(0).toUpperCase() + value.slice(1) : ''} + + + + + + + + + + ); + })}
); }; const TemplateColumnWithStates: StoryFn = (args) => { - const { array, ...textFieldProps } = args; + const { array, id = 'search', ...textFieldProps } = args; return (
- {array.map((state, index) => ( - - - {state} - - - - - - ))} + {array.map((state, index) => { + const stateId = `${id}-${state.toLowerCase()}`; + + return ( + + + {state} + + + + + + ); + })} + Success - + + Error - +
@@ -121,16 +122,16 @@ const TemplateColumnWithStates: StoryFn = (args) => { export const Default: Story = { args: { - id: 'example-1', + id: 'search-default', label: 'Search', + placeholder: 'Search by name or keyword', }, }; export const Sizes: StoryObj = { render: TemplateColumn, - args: { - id: 'example-1', + id: 'search-sizes', label: 'Search', property: 'size', array: sizeArray, @@ -142,6 +143,7 @@ export const States: StoryObj = { args: { array: stateArray, label: 'Search', + id: 'search-states', }, parameters: { pseudo: { @@ -154,15 +156,15 @@ export const States: StoryObj = { export const Placeholder: Story = { args: { - id: 'example-1', + id: 'search-placeholder', label: 'Search', - placeholder: 'Name', + placeholder: 'Type something...', }, }; export const Clearable: Story = { args: { - id: 'example-1', + id: 'search-clearable', label: 'Search', isClearable: true, value: 'Lorem ipsum', @@ -171,18 +173,55 @@ export const Clearable: Story = { export const ClearableButton: Story = { args: { - id: 'example-1', + id: 'search-clearable-button', label: 'Search', isClearable: true, value: 'Lorem ipsum', - button: { iconLeft: 'search', children: 'Otsi' }, + button: { iconLeft: 'search', children: 'Search' }, }, }; export const WithHint: Story = { args: { - id: 'example-1', + id: 'search-with-hint', label: 'Search', helper: { text: 'Hint text' }, }, }; + +export const Estonian: Story = { + args: { + id: 'search-et', + label: 'Otsing', + placeholder: 'Otsi tooteid, artikleid või abiinfot...', + ariaLabel: 'Otsi kogu saidilt', + button: { iconLeft: 'search', children: 'Otsi' }, + }, +}; + +export const AccessibilityFocused: Story = { + name: 'Accessibility: No Visible Label', + args: { + id: 'search-accessible', + placeholder: 'Otsi tooteid või teenuseid...', + ariaLabel: 'Otsi tooteid või teenuseid', + }, + parameters: { + a11y: { + config: { + rules: { + label: { enabled: false }, + }, + }, + }, + docs: { + description: { + story: ` +Always prefer a native \`