Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dropdown): multiple selection dropdown #1712

Merged
merged 5 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions packages/components/dropdown/src/Dropdown.doc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ import { Dropdown } from '@spark-ui/dropdown'

<Canvas of={stories.ControlledOpenState} />

### Custom item

<Canvas of={stories.CustomItem} />

### Disabled

TODO
Expand All @@ -107,12 +103,16 @@ TODO

TODO

## Trigger leading icon
### Trigger leading icon

TODO

### Multiple selection

<Canvas of={stories.MultipleSelection} />

### Multiple selection (controlled)

TODO

### Read only
Expand All @@ -121,6 +121,10 @@ TODO

## Advanced usage

### Custom item

<Canvas of={stories.CustomItem} />

### With form field label

<Canvas of={stories.FormFieldLabel} />
39 changes: 31 additions & 8 deletions packages/components/dropdown/src/Dropdown.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default meta

export const Default: StoryFn = _args => {
return (
<div className="w-sz-480 pb-[300px]">
<div className="pb-[300px]">
<Dropdown>
<Dropdown.Trigger aria-label="Book">
<Dropdown.LeadingIcon>
Expand Down Expand Up @@ -44,7 +44,7 @@ export const Controlled: StoryFn = () => {
const [value, setValue] = useState('book-1')

return (
<div className="w-sz-480 pb-[300px]">
<div className="pb-[300px]">
<Dropdown value={value} onValueChange={setValue}>
<Dropdown.Trigger aria-label="Book">
<Dropdown.Value placeholder="Pick a book" />
Expand All @@ -66,7 +66,7 @@ export const Controlled: StoryFn = () => {
}

export const ControlledOpenState: StoryFn = () => {
const [open, setOpen] = useState(false)
const [open, setOpen] = useState(true)

return (
<div className="flex flex-col gap-lg">
Expand All @@ -79,7 +79,7 @@ export const ControlledOpenState: StoryFn = () => {
</Button>
</div>

<div className="w-sz-480 pb-[300px]">
<div className="pb-[300px]">
<Dropdown open={open} onOpenChange={setOpen}>
<Dropdown.Trigger aria-label="Book">
<Dropdown.Value placeholder="Pick a book" />
Expand All @@ -103,7 +103,7 @@ export const ControlledOpenState: StoryFn = () => {

export const CustomItem: StoryFn = _args => {
return (
<div className="w-sz-480 pb-[300px]">
<div className="pb-[300px]">
<Dropdown>
<Dropdown.Trigger aria-label="Book">
<Dropdown.Value placeholder="Pick a book" />
Expand Down Expand Up @@ -144,7 +144,7 @@ export const CustomItem: StoryFn = _args => {

export const DisabledItem: StoryFn = _args => {
return (
<div className="w-sz-480 pb-[300px]">
<div className="pb-[300px]">
<Dropdown>
<Dropdown.Trigger aria-label="Book">
<Dropdown.Value placeholder="Pick a book" />
Expand All @@ -169,7 +169,7 @@ export const DisabledItem: StoryFn = _args => {

export const Grouped: StoryFn = _args => {
return (
<div className="w-sz-480 pb-[300px]">
<div className="pb-[300px]">
<Dropdown>
<Dropdown.Trigger aria-label="Book">
<Dropdown.Value placeholder="Pick a book" />
Expand Down Expand Up @@ -200,7 +200,7 @@ export const Grouped: StoryFn = _args => {

export const FormFieldLabel: StoryFn = _args => {
return (
<div className="w-sz-480 pb-[300px]">
<div className="pb-[300px]">
<FormField>
<FormField.Label>Book</FormField.Label>
<Dropdown>
Expand All @@ -222,3 +222,26 @@ export const FormFieldLabel: StoryFn = _args => {
</div>
)
}

export const MultipleSelection: StoryFn = _args => {
return (
<div className="pb-[300px]">
<Dropdown multiple>
<Dropdown.Trigger aria-label="Book">
<Dropdown.Value placeholder="Pick a book" />
</Dropdown.Trigger>

<Dropdown.Popover>
<Dropdown.Items>
<Dropdown.Item value="book-1">To Kill a Mockingbird</Dropdown.Item>
<Dropdown.Item value="book-2">War and Peace</Dropdown.Item>
<Dropdown.Item value="book-3">The Idiot</Dropdown.Item>
<Dropdown.Item value="book-4">A Picture of Dorian Gray</Dropdown.Item>
<Dropdown.Item value="book-5">1984</Dropdown.Item>
<Dropdown.Item value="book-6">Pride and Prejudice</Dropdown.Item>
</Dropdown.Items>
</Dropdown.Popover>
</Dropdown>
</div>
)
}
Loading
Loading