-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dropdown): add demo implementation for Dropdown component (#212)
- Loading branch information
Showing
3 changed files
with
324 additions
and
0 deletions.
There are no files selected for viewing
108 changes: 108 additions & 0 deletions
108
apps/nextjs-app/src/components/ui/dropdown/dropdown.stories.tsx
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,108 @@ | ||
import type { Meta } from '@storybook/react'; | ||
import React from 'react'; | ||
|
||
import { Button } from '@/components/ui/button'; | ||
|
||
import { | ||
DropdownMenu, | ||
DropdownMenuTrigger, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuCheckboxItem, | ||
DropdownMenuRadioItem, | ||
DropdownMenuLabel, | ||
DropdownMenuSeparator, | ||
DropdownMenuSub, | ||
DropdownMenuSubTrigger, | ||
DropdownMenuSubContent, | ||
DropdownMenuRadioGroup, | ||
} from './dropdown'; | ||
|
||
const meta: Meta = { | ||
component: DropdownMenu, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default = () => ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button>Open Menu</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuItem>Item One</DropdownMenuItem> | ||
<DropdownMenuItem>Item Two</DropdownMenuItem> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuItem>Item Three</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
|
||
export const WithCheckboxItems = () => { | ||
const [checked, setChecked] = React.useState(true); | ||
const [checked2, setChecked2] = React.useState(false); | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button>Open Menu</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuCheckboxItem | ||
checked={checked} | ||
onCheckedChange={setChecked} | ||
> | ||
Option One | ||
</DropdownMenuCheckboxItem> | ||
<DropdownMenuCheckboxItem | ||
checked={checked2} | ||
onCheckedChange={setChecked2} | ||
> | ||
Option Two | ||
</DropdownMenuCheckboxItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}; | ||
|
||
export const WithRadioItems = () => { | ||
const [value, setValue] = React.useState('one'); | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button>Open Menu</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuLabel>Select an option</DropdownMenuLabel> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuRadioGroup value={value} onValueChange={setValue}> | ||
<DropdownMenuRadioItem value="one">Option One</DropdownMenuRadioItem> | ||
<DropdownMenuRadioItem value="two">Option Two</DropdownMenuRadioItem> | ||
<DropdownMenuRadioItem value="three"> | ||
Option Three | ||
</DropdownMenuRadioItem> | ||
</DropdownMenuRadioGroup> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}; | ||
|
||
export const WithSubmenus = () => ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger> | ||
<Button>Open Menu</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuItem>Item One</DropdownMenuItem> | ||
<DropdownMenuSub> | ||
<DropdownMenuSubTrigger>More Options</DropdownMenuSubTrigger> | ||
<DropdownMenuSubContent> | ||
<DropdownMenuItem>Sub Item One</DropdownMenuItem> | ||
<DropdownMenuItem>Sub Item Two</DropdownMenuItem> | ||
</DropdownMenuSubContent> | ||
</DropdownMenuSub> | ||
<DropdownMenuItem>Item Three</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); |
108 changes: 108 additions & 0 deletions
108
apps/nextjs-pages/src/components/ui/dropdown/dropdown.stories.tsx
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,108 @@ | ||
import type { Meta } from '@storybook/react'; | ||
import React from 'react'; | ||
|
||
import { Button } from '@/components/ui/button'; | ||
|
||
import { | ||
DropdownMenu, | ||
DropdownMenuTrigger, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuCheckboxItem, | ||
DropdownMenuRadioItem, | ||
DropdownMenuLabel, | ||
DropdownMenuSeparator, | ||
DropdownMenuSub, | ||
DropdownMenuSubTrigger, | ||
DropdownMenuSubContent, | ||
DropdownMenuRadioGroup, | ||
} from './dropdown'; | ||
|
||
const meta: Meta = { | ||
component: DropdownMenu, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default = () => ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button>Open Menu</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuItem>Item One</DropdownMenuItem> | ||
<DropdownMenuItem>Item Two</DropdownMenuItem> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuItem>Item Three</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
|
||
export const WithCheckboxItems = () => { | ||
const [checked, setChecked] = React.useState(true); | ||
const [checked2, setChecked2] = React.useState(false); | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button>Open Menu</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuCheckboxItem | ||
checked={checked} | ||
onCheckedChange={setChecked} | ||
> | ||
Option One | ||
</DropdownMenuCheckboxItem> | ||
<DropdownMenuCheckboxItem | ||
checked={checked2} | ||
onCheckedChange={setChecked2} | ||
> | ||
Option Two | ||
</DropdownMenuCheckboxItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}; | ||
|
||
export const WithRadioItems = () => { | ||
const [value, setValue] = React.useState('one'); | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button>Open Menu</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuLabel>Select an option</DropdownMenuLabel> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuRadioGroup value={value} onValueChange={setValue}> | ||
<DropdownMenuRadioItem value="one">Option One</DropdownMenuRadioItem> | ||
<DropdownMenuRadioItem value="two">Option Two</DropdownMenuRadioItem> | ||
<DropdownMenuRadioItem value="three"> | ||
Option Three | ||
</DropdownMenuRadioItem> | ||
</DropdownMenuRadioGroup> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}; | ||
|
||
export const WithSubmenus = () => ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger> | ||
<Button>Open Menu</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuItem>Item One</DropdownMenuItem> | ||
<DropdownMenuSub> | ||
<DropdownMenuSubTrigger>More Options</DropdownMenuSubTrigger> | ||
<DropdownMenuSubContent> | ||
<DropdownMenuItem>Sub Item One</DropdownMenuItem> | ||
<DropdownMenuItem>Sub Item Two</DropdownMenuItem> | ||
</DropdownMenuSubContent> | ||
</DropdownMenuSub> | ||
<DropdownMenuItem>Item Three</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); |
108 changes: 108 additions & 0 deletions
108
apps/react-vite/src/components/ui/dropdown/dropdown.stories.tsx
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,108 @@ | ||
import type { Meta } from '@storybook/react'; | ||
import React from 'react'; | ||
|
||
import { Button } from '@/components/ui/button'; | ||
|
||
import { | ||
DropdownMenu, | ||
DropdownMenuTrigger, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuCheckboxItem, | ||
DropdownMenuRadioItem, | ||
DropdownMenuLabel, | ||
DropdownMenuSeparator, | ||
DropdownMenuSub, | ||
DropdownMenuSubTrigger, | ||
DropdownMenuSubContent, | ||
DropdownMenuRadioGroup, | ||
} from './dropdown'; | ||
|
||
const meta: Meta = { | ||
component: DropdownMenu, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default = () => ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button>Open Menu</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuItem>Item One</DropdownMenuItem> | ||
<DropdownMenuItem>Item Two</DropdownMenuItem> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuItem>Item Three</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
|
||
export const WithCheckboxItems = () => { | ||
const [checked, setChecked] = React.useState(true); | ||
const [checked2, setChecked2] = React.useState(false); | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button>Open Menu</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuCheckboxItem | ||
checked={checked} | ||
onCheckedChange={setChecked} | ||
> | ||
Option One | ||
</DropdownMenuCheckboxItem> | ||
<DropdownMenuCheckboxItem | ||
checked={checked2} | ||
onCheckedChange={setChecked2} | ||
> | ||
Option Two | ||
</DropdownMenuCheckboxItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}; | ||
|
||
export const WithRadioItems = () => { | ||
const [value, setValue] = React.useState('one'); | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button>Open Menu</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuLabel>Select an option</DropdownMenuLabel> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuRadioGroup value={value} onValueChange={setValue}> | ||
<DropdownMenuRadioItem value="one">Option One</DropdownMenuRadioItem> | ||
<DropdownMenuRadioItem value="two">Option Two</DropdownMenuRadioItem> | ||
<DropdownMenuRadioItem value="three"> | ||
Option Three | ||
</DropdownMenuRadioItem> | ||
</DropdownMenuRadioGroup> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}; | ||
|
||
export const WithSubmenus = () => ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger> | ||
<Button>Open Menu</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuItem>Item One</DropdownMenuItem> | ||
<DropdownMenuSub> | ||
<DropdownMenuSubTrigger>More Options</DropdownMenuSubTrigger> | ||
<DropdownMenuSubContent> | ||
<DropdownMenuItem>Sub Item One</DropdownMenuItem> | ||
<DropdownMenuItem>Sub Item Two</DropdownMenuItem> | ||
</DropdownMenuSubContent> | ||
</DropdownMenuSub> | ||
<DropdownMenuItem>Item Three</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); |