-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
148 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/storybook/src/stories/select/labeled-searchable-select.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<script lang="ts"> | ||
import { | ||
Label, | ||
SearchableSelect, | ||
type SelectState, | ||
type SortOptions, | ||
} from '@viamrobotics/prime-core'; | ||
export let options: string[] = []; | ||
export let value: string | undefined = undefined; | ||
export let disabled = false; | ||
export let state: SelectState = 'none'; | ||
export let sort: SortOptions = 'default'; | ||
export let button: { text: string; icon: string } | undefined = undefined; | ||
export let heading = ''; | ||
</script> | ||
|
||
<Label> | ||
Options: | ||
<SearchableSelect | ||
slot="input" | ||
{options} | ||
{value} | ||
{disabled} | ||
{state} | ||
{sort} | ||
{button} | ||
{heading} | ||
/> | ||
</Label> |
109 changes: 109 additions & 0 deletions
109
packages/storybook/src/stories/select/searchable-select.stories.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import { Canvas, Meta, Story } from '@storybook/addon-docs'; | ||
import { SearchableSelect } from '@viamrobotics/prime-core'; | ||
import LabeledSelect from './labeled-searchable-select.svelte'; | ||
|
||
<Meta | ||
title='Elements/Select/SearchableSelect' | ||
argTypes={{ | ||
value: { | ||
description: "The select's value", | ||
control: { type: 'text' }, | ||
table: { defaultValue: { summary: '' } }, | ||
}, | ||
options: { | ||
description: 'The select options', | ||
control: { type: 'object' }, | ||
table: { | ||
defaultValue: { | ||
summary: '[]', | ||
}, | ||
}, | ||
}, | ||
disabled: { | ||
description: 'If the select should be readonly and inoperable', | ||
control: { type: 'boolean' }, | ||
table: { defaultValue: { summary: false } }, | ||
}, | ||
state: { | ||
description: 'The state of the select', | ||
control: { type: 'select' }, | ||
options: ['warn', 'error', 'none'], | ||
table: { defaultValue: { summary: 'none' } }, | ||
}, | ||
sort: { | ||
description: 'The sorting/filtering behavior for the select', | ||
control: { type: 'select' }, | ||
options: ['default', 'reduce', 'off'], | ||
table: { defaultValue: { summary: 'default' } }, | ||
}, | ||
button: { | ||
description: 'An optional action button for the select', | ||
control: { type: 'object' }, | ||
table: { | ||
defaultValue: { summary: { text: 'Do Something', icon: 'alert' } }, | ||
}, | ||
}, | ||
value: { | ||
description: 'An optional heading to put at the top of the select menu', | ||
control: { type: 'text' }, | ||
table: { defaultValue: { summary: 'Search results' } }, | ||
}, | ||
}} | ||
/> | ||
|
||
# Searchable Select | ||
|
||
A simple user input for selecting from a list of options. This is an implementation | ||
of the native HTML `<select />` with our styles applied. | ||
|
||
<Canvas> | ||
<Story | ||
name='SearchableSelect' | ||
args={{ | ||
options: [ | ||
'First Option', | ||
'Option 2', | ||
'C.) Option', | ||
'Something Else', | ||
'With A Whole Lot Of Parts', | ||
], | ||
}} | ||
> | ||
{(props) => ({ | ||
Component: SearchableSelect, | ||
props, | ||
})} | ||
</Story> | ||
</Canvas> | ||
|
||
## Labels | ||
|
||
For accessibility, consider wrapping your `<SearchableSelect />` in a `<Label />`. Make | ||
to pass it `slot="input"` to correctly slot it in. | ||
|
||
<Canvas> | ||
<Story | ||
name='Labeled Select' | ||
args={{ | ||
options: [ | ||
'First Option', | ||
'Option 2', | ||
'C.) Option', | ||
'Something Else', | ||
'With A Whole Lot Of Parts', | ||
], | ||
}} | ||
> | ||
{(props) => ({ | ||
Component: LabeledSelect, | ||
options: [ | ||
'First Option', | ||
'Option 2', | ||
'C.) Option', | ||
'Something Else', | ||
'With A Whole Lot Of Parts', | ||
], | ||
props, | ||
})} | ||
</Story> | ||
</Canvas> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters