-
Notifications
You must be signed in to change notification settings - Fork 11
feat(Menu): add new Menu composites
#728
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
Draft
noahchoii
wants to merge
9
commits into
main
Choose a base branch
from
menu-composites
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f55f0ac
add composites filtering command
noahchoii abdb1bc
add new `Menu` composites
noahchoii 403387f
update lockfile
noahchoii 7aa4d74
Merge branch 'main' into menu-composites
noahchoii c664301
add new `Menu` composites
noahchoii f779006
format
noahchoii d352d81
propagate onClick prop
noahchoii 3cfea89
enhance storybook
noahchoii 72ae5c4
add menu.submenu
noahchoii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| --- | ||
| '@vapor-ui/composites': minor | ||
| --- | ||
|
|
||
| add new `Menu` composites |
This file contains hidden or 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 hidden or 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,8 @@ | ||
| export { | ||
| MenuRoot as Root, | ||
| MenuGroup as Group, | ||
| MenuItem as Item, | ||
| MenuCheckGroup as CheckGroup, | ||
| MenuCheckItem as CheckItem, | ||
| MenuSubmenu as Submenu, | ||
| } from './menu'; |
This file contains hidden or 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 @@ | ||
| export * as Menu from './index.parts'; |
134 changes: 134 additions & 0 deletions
134
packages/composites/src/components/menu/menu.stories.tsx
This file contains hidden or 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,134 @@ | ||
| import { useState } from 'react'; | ||
|
|
||
| import type { Meta, StoryObj } from '@storybook/react-vite'; | ||
| import { Button, Text, VStack } from '@vapor-ui/core'; | ||
| import { ChevronDoubleRightOutlineIcon, PlusOutlineIcon } from '@vapor-ui/icons'; | ||
|
|
||
| import { Menu } from '.'; | ||
|
|
||
| export default { | ||
| title: 'Composites/Menu', | ||
| component: Menu.Root, | ||
| argTypes: { | ||
| defaultOpen: { control: 'boolean' }, | ||
| modal: { control: 'boolean' }, | ||
| isDisabled: { control: 'boolean' }, | ||
| side: { control: 'inline-radio', options: ['top', 'bottom', 'left', 'right'] }, | ||
| align: { control: 'inline-radio', options: ['start', 'center', 'end'] }, | ||
| }, | ||
| } satisfies Meta<typeof Menu.Root>; | ||
|
|
||
| type Story = StoryObj<typeof Menu.Root>; | ||
|
|
||
| export const Default: Story = { | ||
| render: (args) => { | ||
| return ( | ||
| <div style={{ width: '100%', textAlign: 'center' }}> | ||
| <Menu.Root trigger={<Button>Menu Trigger</Button>} defaultOpen {...args}> | ||
| <Menu.Group label="label"> | ||
| <Menu.Item label="item 1" onClick={() => alert('clicked item 1')} /> | ||
| <Menu.Item | ||
| label="item 2" | ||
| leading={<PlusOutlineIcon />} | ||
| onClick={() => alert('clicked item 2')} | ||
| /> | ||
| <Menu.Item | ||
| label="item 3" | ||
| leading={<PlusOutlineIcon />} | ||
| trailing={<ChevronDoubleRightOutlineIcon />} | ||
| onClick={() => alert('clicked item 3')} | ||
| /> | ||
| <Menu.Item | ||
| label="item 4" | ||
| trailing={<ChevronDoubleRightOutlineIcon />} | ||
| onClick={() => alert('clicked item 4')} | ||
| /> | ||
| <Menu.Item | ||
| label="item 5" | ||
| trailing={<ChevronDoubleRightOutlineIcon />} | ||
| variant="critical" | ||
| onClick={() => alert('clicked item 5')} | ||
| /> | ||
| </Menu.Group> | ||
|
|
||
| <Menu.Submenu trigger="label"> | ||
| <Menu.CheckGroup mode="multiple" label="multiple group"> | ||
| <Menu.CheckItem label="multiple 1" value="multiple 1" /> | ||
| <Menu.CheckItem label="multiple 2" value="multiple 2" /> | ||
| <Menu.CheckItem label="multiple 3" value="multiple 3" /> | ||
| <Menu.CheckItem label="multiple 4" value="multiple 4" /> | ||
| </Menu.CheckGroup> | ||
| </Menu.Submenu> | ||
|
|
||
| <Menu.CheckGroup mode="single" label="single group"> | ||
| <Menu.CheckItem label="single 1" value="single 1" /> | ||
| <Menu.CheckItem label="single 2" value="single 2" /> | ||
| <Menu.CheckItem label="single 3" value="single 3" /> | ||
| <Menu.CheckItem label="single 4" value="single 4" /> | ||
| </Menu.CheckGroup> | ||
|
|
||
| <Menu.CheckGroup mode="multiple" label="multiple group"> | ||
| <Menu.CheckItem label="multiple 1" value="multiple 1" /> | ||
| <Menu.CheckItem label="multiple 2" value="multiple 2" /> | ||
| <Menu.CheckItem label="multiple 3" value="multiple 3" /> | ||
| <Menu.CheckItem label="multiple 4" value="multiple 4" /> | ||
| </Menu.CheckGroup> | ||
| </Menu.Root> | ||
| </div> | ||
| ); | ||
| }, | ||
| }; | ||
|
|
||
| export const Controlled: Story = { | ||
| render: (args) => { | ||
| const [singleValue, setSingleValue] = useState<string>(); | ||
| const [multipleValue, setMultipleValue] = useState<string[]>(); | ||
|
|
||
| return ( | ||
| <VStack $css={{ alignItems: 'flex-start' }}> | ||
| <Text>1. Selected Single Value: {singleValue ?? <span>Not Selected</span>}</Text> | ||
| <Text> | ||
| 2. Selected Multiple Value:{' '} | ||
| {multipleValue ? multipleValue.join(', ') : <span>Not Selected</span>} | ||
| </Text> | ||
|
|
||
| <Menu.Root | ||
| trigger={ | ||
| <Button | ||
| $css={{ marginTop: '$100' }} | ||
| colorPalette="secondary" | ||
| variant="outline" | ||
| > | ||
| Open Menu | ||
| </Button> | ||
| } | ||
| {...args} | ||
| > | ||
| <Menu.CheckGroup | ||
| mode="single" | ||
| label="single group" | ||
| value={singleValue} | ||
| onValueChange={setSingleValue} | ||
| > | ||
| <Menu.CheckItem label="Single 1" value="single 1" /> | ||
| <Menu.CheckItem label="Single 2" value="single 2" /> | ||
| <Menu.CheckItem label="Single 3" value="single 3" /> | ||
| <Menu.CheckItem label="Single 4" value="single 4" /> | ||
| </Menu.CheckGroup> | ||
|
|
||
| <Menu.CheckGroup | ||
| mode="multiple" | ||
| label="multiple group" | ||
| value={multipleValue} | ||
| onValueChange={setMultipleValue} | ||
| > | ||
| <Menu.CheckItem label="Multiple 1" value="multiple 1" /> | ||
| <Menu.CheckItem label="Multiple 2" value="multiple 2" /> | ||
| <Menu.CheckItem label="Multiple 3" value="multiple 3" /> | ||
| <Menu.CheckItem label="Multiple 4" value="multiple 4" /> | ||
| </Menu.CheckGroup> | ||
| </Menu.Root> | ||
| </VStack> | ||
| ); | ||
| }, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.