-
Notifications
You must be signed in to change notification settings - Fork 658
SelectMenu #600
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
Merged
Merged
SelectMenu #600
Changes from all commits
Commits
Show all changes
206 commits
Select commit
Hold shift + click to select a range
1b22a98
add web component dep
d25c1f0
add docs page
541007a
Add Modal & Summary
4a9e197
add Header, Title, and breakpoints
7b38b65
start adding filter
a1be8ff
don't need to import CE package in file
edc436c
add @binarymuse TextInput updates
4e9ae38
fixes
de73a7e
refactor styles
144a232
tab styles
83e1523
move CSS
d2dfcf8
add footer
784fef3
add loading state
870360a
add checked styles
0700fcc
add Animation component
8a86781
refactor
bedca12
move into separate files
c7e70b1
tabs refactoring
7be9d9a
first pass at documentation
6ae68d2
add SelectMenu.Item docs
a75cb7f
update docs
bc7bfef
typo
7a75fe4
Merge branch 'master' into select-menu
8239ba4
lint & snapshots
8fb6bcb
update types
3753b45
rename Animation component
954051c
typo
a573a19
fix typings
f427141
Update index.d.ts
3a932c1
Update index.d.ts
3c2a919
add theme to SelectMenu
c5af58b
fix Button system props
4851f30
add ButtonTableList component
e4072ae
lint it up
edf5e35
types typo
a588ca6
ButtonTableList tweaks
05fc7c8
fix up SelectMenu.Item
2b59e42
lint
699d591
use display to show/hide selected icon
85f2aaa
add selected prop
9dc0bcb
switch up details-menu ordering
d5c5cf9
lint
00472b5
don't import CE
774f54c
remove text decoration
3a33e97
add link
e19df84
merge in master
27bbef0
Merge branch 'release-15.1.0' into select-menu
4feab80
fix up px
3fef875
Merge branch 'master' of github.com:primer/components into select-menu
66a48ba
tab navigation
051b944
initial filter work
9ef1ccf
typos
e00bab1
filtering
f2e19aa
refactor panels + list
55d0c5a
lint
130fadf
update snaps
73de961
typo in types
4ea2e23
add fragment component
e014a10
lint
be14646
update deps
4f02f97
add new types
9340a98
add static filter
1e26ef2
lint
c84f9aa
fix failing test
ffcc83e
type typo
f48bd11
add types packages
14c13ee
remove filter input
6562514
delete static filter
b6af090
refactor all the things lol
c554f25
add link styles for nested links
4d7e885
fix text input type
448fe11
add autofocus to Filter types
e47cc6f
update text input
d279932
remove unnecessary prop on filter
071aef6
KeyboardNav hook
cd010f4
fix linting errors
8b1b66d
Expose MenuContext and track filterText in context
dmarcey 2866e50
Remove unused import.
dmarcey 7670755
typo
6eef60f
Merge branch 'select-menu' of github.com:primer/components into selec…
d4bd9e5
update hook
f5382fa
remove e.Handled
8cbbf78
refactor styles
d094741
open menu if not open yet
167ea40
add event listener to details in useKeyboardNav
dmarcey a1ee357
Prettier lint fix.
dmarcey 37293f6
add hooks folder, export filter hook
496f0bb
remove details-menu
6640706
new hooks folder
bb4da83
move context into top level component
5267dfb
Move Context into separate file to fix circular dependency
dmarcey 02cd588
Don't store extra filterText state in useFilter
dmarcey 3fdac49
Merge branch 'master' into select-menu
dmarcey 3980d31
Fix SelectMenuFilterProps
dmarcey cb9e952
Change Select Item to link
85416a8
autofocus filter for select menu
04df0b9
fix docs
8b56618
hide items with hidden attribute
c2483b9
add comment
0ebffeb
refactor modal a bit
b557400
rename filter -> menuFilter
5bbd404
style fixes
c037c2a
lint fix
a883599
use non strict versions
990918b
fix types for tabs
7576427
add prop types to TabPanel
d4518c9
types typo
bf13579
fix types
7387c6f
add initial tab to select menu type
f8e6bc4
tab style fixes
397e3d4
lint
ced2f37
log menu context
71aadc3
lint
97faf21
lintntntntntnt
56e4ef5
put initial tab in context
df0bda4
lint
43c3010
use data attribute
515f758
remove data attribute
4646aba
Merge branch 'master' into select-menu
11b5585
update snaps
392d0ef
rename context provider
d9475c0
update focus styles
8fef8d9
rename SelectMenu.Loading to LoadingOctoface
bac293a
add code comment to TextInput
730a864
use ul and li for menu + clean up styles
8292da6
update box shadow
ecd3dc4
match selected styles to Primer CSS
31e98ae
update Divider
220cc91
add footer docs
e94ece2
update Divdier, Footer & tabs documentation
3590d78
refactor Tabs and Tab
2806f7b
lint
ad0dc0b
refactor Heading and List into wrapping components
1beadf6
remove SelectMenu.Summary
3d11e33
update docs
877dee7
update types
56bbce1
add List back
217d8ca
fix tab border issue
4595146
updat3e docs
b692ac5
props cleanup
7c15fde
remove export
31df2fa
linting
0252590
docs
58e8862
update filter docs
578d444
lint
31a1d9c
docs
368069d
move files around
1b0e628
fix tests
c0f0a61
spread out theme
5d8db4d
fix focus management
c9b6b4f
add code comment
ae04253
fix filter background color
309584d
dont use ul
1c5a4fd
fix uncontrolled input error
17b715f
rearrange docs
eed0eae
Merge branch 'master' into select-menu
bcb1664
update border radius and focus color
17bef76
fix tab border radius
4f67e44
remove outline
78e90ea
don't manage filter input value
63fb124
clean up some state
f356308
remove unneeded onchange
0e72654
make tabs more reusable
8c5805e
update docs
e095471
update docs
2cd5619
close menu when clicking on item
c0278b3
update docs
0da3c30
update tests
c038e01
tests
4a03f84
remove extra components
9817535
remove other components
e583321
update types
ba4aa9f
lint + skip failing tests for now
06b2463
update nav yml
f8ebf52
clean up some type definitions, add some comments
1faf1db
fix up MenuContext types
2c70bc5
omit as prop from select menu item
1235efd
move SelectMenu.Header out of modal
447c26d
remove filter prop from modal styles
2a1f757
clean up tab function
a2920d9
tweak filter docs
73d239b
add filter docs
9071bec
pass theme down
84f9c18
pass theme down
fdcdb22
tweak filter theme props
5738109
pass theme down in modal
3538187
Update src/SelectMenu/SelectMenuTabs.js
eb2022d
Update src/SelectMenu/hooks/KeyboardHook.js
f1e3ab5
props fix
dfa4238
lint
fed5694
Merge branch 'major' into select-menu
a2001f8
update snaps
350b74c
fix code examples
fdec085
update background color
fdbe53f
fix spacing
b94b0bc
rename keyboard nav hook file
8bb7892
move styles into component files
2c44f59
update keyboard hook to use state instead of dom attributes
ddc309c
spread as out on select menu
e8dca25
test updates
c7122c5
test clicking on items works
8f6013c
update "as" test, fix theme errors
96d3309
lint
05174f5
Update SelectMenu.js
573f5d1
removed unused snapshot
364cf60
Merge branch 'major' into select-menu
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
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,287 @@ | ||
| --- | ||
| title: SelectMenu | ||
| --- | ||
|
|
||
| The `SelectMenu` components are a suite of components which can be combined together to make several different variations of our GitHub select menu. At it's most basic form, a select menu is comprised of a `SelectMenu` wrapper, which contains a `summary` component of your choice and a `Select.Modal` which contains the select menu content. Use `SelectMenu.List` to wrap items in the select menu, and `SelectMenu.Item` to wrap each item. | ||
|
|
||
| Several additional components exist to provide even more functionality: `SelectMenu.Header`, `SelectMenu.Filter`, `SelectMenu.Tabs`, `SelectMenu.TabPanel` `SelectMenu.Footer` and `SelectMenu.Divider`. | ||
|
|
||
| ## Basic Example | ||
| ```jsx live | ||
| <SelectMenu> | ||
| <Button as="summary">Projects</Button> | ||
| <SelectMenu.Modal> | ||
| <SelectMenu.Header>Projects</SelectMenu.Header> | ||
| <SelectMenu.List> | ||
| <SelectMenu.Item href="#">Primer Components bugs</SelectMenu.Item> | ||
| <SelectMenu.Item href="#">Primer Components roadmap</SelectMenu.Item> | ||
| <SelectMenu.Item href="#"> Project 3</SelectMenu.Item> | ||
| <SelectMenu.Item href="#">Project 4</SelectMenu.Item> | ||
| </SelectMenu.List> | ||
| </SelectMenu.Modal> | ||
| </SelectMenu> | ||
| ``` | ||
|
|
||
| ## SelectMenu | ||
| Main wrapper component for select menu. | ||
|
|
||
| ```jsx | ||
| <SelectMenu> | ||
| {/* all other sub components are wrapped here*/} | ||
| </SelectMenu> | ||
| ``` | ||
|
|
||
| ### System props | ||
|
|
||
| SelectMenu components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props. | ||
|
|
||
| ### Component Props | ||
| | Name | Type | Default | Description | | ||
| | :- | :- | :-: | :- | | ||
| | initialTab | String | | If using the `SelectMenu.Tabs` component, you can use this prop to change the tab shown on open. By default, the first tab will be used. | ||
|
|
||
|
|
||
| ## SelectMenu.Modal | ||
| Used to wrap the content in a `SelectMenu`. | ||
|
|
||
| ```jsx | ||
| <SelectMenu.Modal> | ||
| {/* all menu content is wrapped in the modal*/} | ||
| </SelectMenu.Menu> | ||
| ``` | ||
|
|
||
| ### System Props | ||
|
|
||
| SelectMenu.Modal components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props. | ||
|
|
||
| ### Component Props | ||
| SelectMenu.Modal components do not get any additional props besides system props. | ||
|
|
||
|
|
||
| ## SelectMenu.List | ||
|
|
||
| Used to wrap the select menu list content. All menu items **must** be wrapped in a SelectMenu.List in order for the accessbility keyboard handling to function properly. If you are using the `SelectMenu.TabPanel` you do not need to provide a `SelectMenu.List` as that component renders a `SelectMenu.List` as a wrapper. | ||
|
|
||
| ```jsx | ||
| <SelectMenu.List> | ||
| {/* all menu list items are wrapped in the list*/} | ||
| </SelectMenu.List> | ||
| ``` | ||
|
|
||
| ### System Props | ||
|
|
||
| SelectMenu.List components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props. | ||
|
|
||
| ### Component Props | ||
| SelectMenu.List components do not get any additional props besides system props. | ||
|
|
||
|
|
||
| ## SelectMenu.Item | ||
|
|
||
| Individual items in a select menu. | ||
|
|
||
| ```jsx | ||
| <SelectMenu.Item selected={true}> | ||
| {/* wraps an individual list item*/} | ||
| </SelectMenu.Item> | ||
| ``` | ||
|
|
||
| ### System Props | ||
|
|
||
| SelectMenu.Item components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props. | ||
|
|
||
| ### Component Props | ||
| | Name | Type | Default | Description | | ||
| | :- | :- | :-: | :- | | ||
| | selected | boolean | | Used to apply styles to the selected items in the list. | | ||
| | onClick | function | | Function called when item is clicked. By default we also close the menu when items are clicked. If you would like the menu to stay open, pass an `e.preventDefault()` to your onClick handler. | | ||
|
|
||
| ## SelectMenu.Filter | ||
| Use a `SelectMenu.Filter` to add a filter UI to your select menu. Users are expected to implement their own filtering and manage the state of the `value` prop on the input. This gives users more flexibility over the type of filtering and type of content passed into each select menu item. | ||
|
|
||
| ```jsx live | ||
| <SelectMenu> | ||
| <Button as="summary">Projects</Button> | ||
| <SelectMenu.Modal> | ||
| <SelectMenu.Header>Filter by Project</SelectMenu.Header> | ||
| <SelectMenu.Filter placeholder="Filter projects" value="" aria-label="Filter Projects"/> | ||
| <SelectMenu.List> | ||
| <SelectMenu.Item href="#">Primer Components bugs</SelectMenu.Item> | ||
| <SelectMenu.Item href="#">Primer Components roadmap</SelectMenu.Item> | ||
| <SelectMenu.Divider>More Options</SelectMenu.Divider> | ||
| <SelectMenu.Item href="#"> Project 3</SelectMenu.Item> | ||
| <SelectMenu.Item href="#">Project 4</SelectMenu.Item> | ||
| </SelectMenu.List> | ||
| </SelectMenu.Modal> | ||
| </SelectMenu> | ||
| ``` | ||
|
|
||
|
|
||
| ### System Props | ||
| SelectMenu.Filter components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props. | ||
|
|
||
| ### Component Props | ||
| SelectMenu.Filter components receive all the props that the [TextInput](/TextInput) component gets. | ||
|
|
||
| | Name | Type | Default | Description | | ||
| | :- | :- | :-: | :- | | ||
| | value | String | | Users of this component must provide a value for the filter input that is managed in the consuming application | | ||
|
|
||
|
|
||
| ## SelectMenu.Tabs | ||
| Use `SelectMenu.Tabs` to wrap the the tab navigation and `SelectMenu.Tab` for each tab in the navigation. | ||
|
|
||
| `SelectMenu.TabPanel` should wrap each corresponding panel for each of the tabs. The `tabName` prop for each `SelectMenu.TabPanel` must match the name provided in the `tabName` prop on `SelectMenu.Tab`. | ||
|
|
||
| To set one of the tabs to be open by default, use `initialTab` on the main `SelectMenu` component. Otherwise, the first tab will be shown by default. | ||
|
|
||
| Each `Select.Menu` tab will need to have an `index` prop. The first tab should be at index `0`, the second at index `1` and so forth. The `index` prop is used to show the first tab by default. | ||
|
|
||
| If you need access to the selected tab state, you can find it in the MenuContext object exported from `SelectMenu` as `MenuContext.selectedTab`. | ||
|
|
||
| ```jsx live | ||
| <SelectMenu> | ||
| <Button as="summary">Projects</Button> | ||
| <SelectMenu.Modal> | ||
| <SelectMenu.Header>Projects</SelectMenu.Header> | ||
| <SelectMenu.Tabs> | ||
| <SelectMenu.Tab index={0} tabName="Repository"/> | ||
| <SelectMenu.Tab index={1} tabName="Organization"/> | ||
| </SelectMenu.Tabs> | ||
| <SelectMenu.TabPanel tabName="Repository"> | ||
| <SelectMenu.Item href="#">Primer Components bugs</SelectMenu.Item> | ||
| <SelectMenu.Item href="#">Primer Components roadmap</SelectMenu.Item> | ||
| <SelectMenu.Item href="#"> Project 3</SelectMenu.Item> | ||
| <SelectMenu.Item href="#">Project 4</SelectMenu.Item> | ||
| </SelectMenu.TabPanel> | ||
| <SelectMenu.TabPanel tabName="Organization"> | ||
| <SelectMenu.Item href="#"> Project 2</SelectMenu.Item> | ||
| </SelectMenu.TabPanel> | ||
| <SelectMenu.Footer>Showing 3 of 3</SelectMenu.Footer> | ||
| </SelectMenu.Modal> | ||
| </SelectMenu> | ||
| ``` | ||
|
|
||
| ### System Props | ||
|
|
||
| SelectMenu.Tabs components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props. | ||
|
|
||
| ### Component Props | ||
| SelectMenu.Tabs components do not get any additional props besides system props. | ||
|
|
||
| ## SelectMenu.Tab | ||
| Used for each individual tab inside of a `SelectMenu.Tabs`. Be sure to set the `index` prop to correspond to the order the tab is in. The `tabName` prop should correspond to the `tabName` set on the `SelectMenu.TabPanel`. | ||
|
|
||
| The `onClick` prop is optional and can be used for any events or data fetching you might need to trigger on tab clicks. | ||
|
|
||
| ```jsx | ||
| <SelectMenu.Tab index={0} tabName="Repository"/> | ||
| <SelectMenu.Tab index={1} tabName="Organization"/> | ||
| ``` | ||
|
|
||
| ### System Props | ||
| SelectMenu.Tab components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props. | ||
|
|
||
| ### Component Props | ||
| | Name | Type | Default | Description | | ||
| | :- | :- | :-: | :- | | ||
| | tabName | String | | Used to identify the corresponding tab. Must match the string used in the `tabs` array in the `SelectMenu.Tabs` component. | | ||
| | index | Number | | The index at which the tab is in the list of tabs | | ||
| | onClick | Function | | Function to be called when the tab is clicked. Optional. | | ||
|
|
||
| ## SelectMenu.TabPanel | ||
| Wraps the content for each tab. Make sure to use the `tabName` prop to identify each tab panel with the correct tab in the tab navigation. | ||
|
|
||
| **Note**: SelectMenu.TabPanel wraps content in a SelectMenu.List, so adding a SelectMenu.List manually is not necessary. | ||
|
|
||
| ```jsx | ||
| <SelectMenu.TabPanel tabName="Repository"> | ||
| {/* Wraps content for each tab */} | ||
| </SelectMenu.TabPanel> | ||
| ``` | ||
|
|
||
| ### System Props | ||
| SelectMenu.TabPanel components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props. | ||
|
|
||
| ### Component Props | ||
| | Name | Type | Default | Description | | ||
| | :- | :- | :-: | :- | | ||
| | tabName | String | | Used to identify the corresponding tab. Must match the string used in the `tabs` array in the `SelectMenu.Tabs` component. | ||
|
|
||
| ## SelectMenu.Divider | ||
| Use a `SelectMenu.Divider` to add information between items in a `SelectMenu.List`. | ||
|
|
||
| ```jsx live | ||
| <SelectMenu> | ||
| <Button as="summary">Projects</Button> | ||
| <SelectMenu.Modal> | ||
| <SelectMenu.Header>Projects</SelectMenu.Header> | ||
| <SelectMenu.List> | ||
| <SelectMenu.Item href="#">Primer Components bugs</SelectMenu.Item> | ||
| <SelectMenu.Item href="#">Primer Components roadmap</SelectMenu.Item> | ||
| <SelectMenu.Divider>More Options</SelectMenu.Divider> | ||
| <SelectMenu.Item href="#"> Project 3</SelectMenu.Item> | ||
| <SelectMenu.Item href="#">Project 4</SelectMenu.Item> | ||
| </SelectMenu.List> | ||
| </SelectMenu.Modal> | ||
| </SelectMenu> | ||
| ``` | ||
|
|
||
| ### System Props | ||
|
|
||
| SelectMenu.Divder components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props. | ||
|
|
||
| ### Component Props | ||
| SelectMenu.Divider components do not get any additional props besides system props. | ||
|
|
||
| ## SelectMenu.Footer | ||
| Use a `SelectMenu.Footer` to add content to the bottom of the select menu. | ||
|
|
||
| ```jsx live | ||
| <SelectMenu> | ||
| <Button as="summary">Projects</Button> | ||
| <SelectMenu.Modal> | ||
| <SelectMenu.Header>Projects</SelectMenu.Header> | ||
| <SelectMenu.List> | ||
| <SelectMenu.Item href="#">Primer Components bugs</SelectMenu.Item> | ||
| <SelectMenu.Item href="#">Primer Components roadmap</SelectMenu.Item> | ||
| <SelectMenu.Item href="#"> Project 3</SelectMenu.Item> | ||
| <SelectMenu.Item href="#">Project 4</SelectMenu.Item> | ||
| <SelectMenu.Footer>Use ⌥ + click/return to exclude labels.</SelectMenu.Footer> | ||
| </SelectMenu.List> | ||
| </SelectMenu.Modal> | ||
| </SelectMenu> | ||
| ``` | ||
|
|
||
| ### System Props | ||
|
|
||
| SelectMenu.Footer components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props. | ||
|
|
||
| ### Component Props | ||
| SelectMenu.Footer components do not get any additional props besides system props. | ||
|
|
||
| ## SelectMenu.Header | ||
| Use a `SelectMenu.Header` to add a header to the top of the select menu content. | ||
|
|
||
| ```jsx live | ||
| <SelectMenu> | ||
| <Button as="summary">Projects</Button> | ||
| <SelectMenu.Modal> | ||
| <SelectMenu.Header>Projects</SelectMenu.Header> | ||
| <SelectMenu.List> | ||
| <SelectMenu.Item href="#">Primer Components bugs</SelectMenu.Item> | ||
| <SelectMenu.Item href="#">Primer Components roadmap</SelectMenu.Item> | ||
| <SelectMenu.Item href="#"> Project 3</SelectMenu.Item> | ||
| <SelectMenu.Item href="#">Project 4</SelectMenu.Item> | ||
| <SelectMenu.Footer>Use ⌥ + click/return to exclude labels.</SelectMenu.Footer> | ||
| </SelectMenu.List> | ||
| </SelectMenu.Modal> | ||
| </SelectMenu> | ||
| ``` | ||
|
|
||
| ### System Props | ||
|
|
||
| SelectMenu.Header components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props. | ||
|
|
||
| ### Component Props | ||
| SelectMenu.Header components do not get any additional props besides system props. | ||
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
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.