Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
1b22a98
add web component dep
Oct 7, 2019
d25c1f0
add docs page
Oct 8, 2019
541007a
Add Modal & Summary
Oct 8, 2019
4a9e197
add Header, Title, and breakpoints
Oct 8, 2019
7b38b65
start adding filter
Oct 8, 2019
a1be8ff
don't need to import CE package in file
Oct 8, 2019
edc436c
add @binarymuse TextInput updates
Oct 10, 2019
4e9ae38
fixes
Oct 11, 2019
de73a7e
refactor styles
Oct 11, 2019
144a232
tab styles
Oct 14, 2019
83e1523
move CSS
Oct 14, 2019
d2dfcf8
add footer
Oct 14, 2019
784fef3
add loading state
Oct 15, 2019
870360a
add checked styles
Oct 15, 2019
0700fcc
add Animation component
Oct 15, 2019
8a86781
refactor
Oct 15, 2019
bedca12
move into separate files
Oct 15, 2019
c7e70b1
tabs refactoring
Oct 15, 2019
7be9d9a
first pass at documentation
Oct 15, 2019
6ae68d2
add SelectMenu.Item docs
Oct 16, 2019
a75cb7f
update docs
Oct 16, 2019
bc7bfef
typo
Oct 16, 2019
7a75fe4
Merge branch 'master' into select-menu
Oct 16, 2019
8239ba4
lint & snapshots
Oct 16, 2019
8fb6bcb
update types
Oct 16, 2019
3753b45
rename Animation component
Oct 16, 2019
954051c
typo
Oct 16, 2019
a573a19
fix typings
Oct 17, 2019
f427141
Update index.d.ts
Oct 17, 2019
3a932c1
Update index.d.ts
Oct 17, 2019
3c2a919
add theme to SelectMenu
Oct 17, 2019
c5af58b
fix Button system props
Oct 17, 2019
4851f30
add ButtonTableList component
Oct 17, 2019
e4072ae
lint it up
Oct 17, 2019
edf5e35
types typo
Oct 17, 2019
a588ca6
ButtonTableList tweaks
Oct 17, 2019
05fc7c8
fix up SelectMenu.Item
Oct 17, 2019
2b59e42
lint
Oct 17, 2019
699d591
use display to show/hide selected icon
Oct 17, 2019
85f2aaa
add selected prop
Oct 17, 2019
9dc0bcb
switch up details-menu ordering
Oct 17, 2019
d5c5cf9
lint
Oct 18, 2019
00472b5
don't import CE
Oct 18, 2019
774f54c
remove text decoration
Oct 18, 2019
3a33e97
add link
Oct 21, 2019
e19df84
merge in master
Oct 31, 2019
27bbef0
Merge branch 'release-15.1.0' into select-menu
Nov 5, 2019
4feab80
fix up px
Nov 6, 2019
3fef875
Merge branch 'master' of github.com:primer/components into select-menu
Nov 13, 2019
66a48ba
tab navigation
Nov 14, 2019
051b944
initial filter work
Nov 14, 2019
9ef1ccf
typos
Nov 14, 2019
e00bab1
filtering
Nov 14, 2019
f2e19aa
refactor panels + list
Nov 14, 2019
55d0c5a
lint
Nov 14, 2019
130fadf
update snaps
Nov 14, 2019
73de961
typo in types
Nov 14, 2019
4ea2e23
add fragment component
Nov 15, 2019
e014a10
lint
Nov 15, 2019
be14646
update deps
Nov 15, 2019
4f02f97
add new types
Nov 16, 2019
9340a98
add static filter
Nov 19, 2019
1e26ef2
lint
Nov 19, 2019
c84f9aa
fix failing test
Nov 19, 2019
ffcc83e
type typo
Nov 19, 2019
f48bd11
add types packages
Nov 20, 2019
14c13ee
remove filter input
Nov 20, 2019
6562514
delete static filter
Nov 20, 2019
b6af090
refactor all the things lol
Nov 21, 2019
c554f25
add link styles for nested links
Nov 21, 2019
4d7e885
fix text input type
Nov 21, 2019
448fe11
add autofocus to Filter types
Nov 21, 2019
e47cc6f
update text input
Nov 21, 2019
d279932
remove unnecessary prop on filter
Nov 21, 2019
071aef6
KeyboardNav hook
Nov 21, 2019
cd010f4
fix linting errors
Nov 21, 2019
8b1b66d
Expose MenuContext and track filterText in context
dmarcey Nov 21, 2019
2866e50
Remove unused import.
dmarcey Nov 21, 2019
7670755
typo
Nov 21, 2019
6eef60f
Merge branch 'select-menu' of github.com:primer/components into selec…
Nov 21, 2019
d4bd9e5
update hook
Nov 22, 2019
f5382fa
remove e.Handled
Nov 22, 2019
8cbbf78
refactor styles
Nov 22, 2019
d094741
open menu if not open yet
Nov 22, 2019
167ea40
add event listener to details in useKeyboardNav
dmarcey Nov 22, 2019
a1ee357
Prettier lint fix.
dmarcey Nov 22, 2019
37293f6
add hooks folder, export filter hook
Nov 23, 2019
496f0bb
remove details-menu
Nov 23, 2019
6640706
new hooks folder
Nov 23, 2019
bb4da83
move context into top level component
Nov 23, 2019
5267dfb
Move Context into separate file to fix circular dependency
dmarcey Nov 25, 2019
02cd588
Don't store extra filterText state in useFilter
dmarcey Nov 25, 2019
3fdac49
Merge branch 'master' into select-menu
dmarcey Nov 25, 2019
3980d31
Fix SelectMenuFilterProps
dmarcey Nov 25, 2019
cb9e952
Change Select Item to link
Nov 25, 2019
85416a8
autofocus filter for select menu
Nov 25, 2019
04df0b9
fix docs
Nov 25, 2019
8b56618
hide items with hidden attribute
Nov 25, 2019
c2483b9
add comment
Nov 25, 2019
0ebffeb
refactor modal a bit
Nov 27, 2019
b557400
rename filter -> menuFilter
Dec 3, 2019
5bbd404
style fixes
Dec 3, 2019
c037c2a
lint fix
Dec 3, 2019
a883599
use non strict versions
Dec 3, 2019
990918b
fix types for tabs
Dec 10, 2019
7576427
add prop types to TabPanel
Dec 10, 2019
d4518c9
types typo
Dec 10, 2019
bf13579
fix types
Dec 10, 2019
7387c6f
add initial tab to select menu type
Dec 12, 2019
f8e6bc4
tab style fixes
Dec 12, 2019
397e3d4
lint
Dec 12, 2019
ced2f37
log menu context
Dec 19, 2019
71aadc3
lint
Dec 19, 2019
97faf21
lintntntntntnt
Dec 19, 2019
56e4ef5
put initial tab in context
Dec 20, 2019
df0bda4
lint
Dec 20, 2019
43c3010
use data attribute
Dec 20, 2019
515f758
remove data attribute
Dec 20, 2019
4646aba
Merge branch 'master' into select-menu
Feb 6, 2020
11b5585
update snaps
Feb 6, 2020
392d0ef
rename context provider
Feb 6, 2020
d9475c0
update focus styles
Feb 6, 2020
8fef8d9
rename SelectMenu.Loading to LoadingOctoface
Feb 7, 2020
bac293a
add code comment to TextInput
Feb 7, 2020
730a864
use ul and li for menu + clean up styles
Feb 13, 2020
8292da6
update box shadow
Feb 13, 2020
ecd3dc4
match selected styles to Primer CSS
Feb 13, 2020
31e98ae
update Divider
Feb 13, 2020
220cc91
add footer docs
Feb 13, 2020
e94ece2
update Divdier, Footer & tabs documentation
Feb 13, 2020
3590d78
refactor Tabs and Tab
Feb 14, 2020
2806f7b
lint
Feb 18, 2020
ad0dc0b
refactor Heading and List into wrapping components
Feb 18, 2020
1beadf6
remove SelectMenu.Summary
Feb 18, 2020
3d11e33
update docs
Feb 18, 2020
877dee7
update types
Feb 18, 2020
56bbce1
add List back
Feb 18, 2020
217d8ca
fix tab border issue
Feb 18, 2020
4595146
updat3e docs
Feb 18, 2020
b692ac5
props cleanup
Feb 18, 2020
7c15fde
remove export
Feb 18, 2020
31df2fa
linting
Feb 18, 2020
0252590
docs
Feb 18, 2020
58e8862
update filter docs
Feb 18, 2020
578d444
lint
Feb 18, 2020
31a1d9c
docs
Feb 18, 2020
368069d
move files around
Feb 18, 2020
1b0e628
fix tests
Feb 18, 2020
c0f0a61
spread out theme
Feb 19, 2020
5d8db4d
fix focus management
Mar 19, 2020
c9b6b4f
add code comment
Mar 19, 2020
ae04253
fix filter background color
Mar 19, 2020
309584d
dont use ul
Mar 19, 2020
1c5a4fd
fix uncontrolled input error
Mar 19, 2020
17b715f
rearrange docs
Mar 19, 2020
eed0eae
Merge branch 'master' into select-menu
Mar 19, 2020
bcb1664
update border radius and focus color
Mar 19, 2020
17bef76
fix tab border radius
Mar 19, 2020
4f67e44
remove outline
Mar 25, 2020
78e90ea
don't manage filter input value
Mar 25, 2020
63fb124
clean up some state
Mar 25, 2020
f356308
remove unneeded onchange
Mar 25, 2020
0e72654
make tabs more reusable
Mar 27, 2020
8c5805e
update docs
Mar 27, 2020
e095471
update docs
Mar 27, 2020
2cd5619
close menu when clicking on item
Mar 27, 2020
c0278b3
update docs
Mar 27, 2020
0da3c30
update tests
Mar 27, 2020
c038e01
tests
Mar 27, 2020
4a03f84
remove extra components
Mar 27, 2020
9817535
remove other components
Mar 27, 2020
e583321
update types
Mar 27, 2020
ba4aa9f
lint + skip failing tests for now
Mar 27, 2020
06b2463
update nav yml
Mar 27, 2020
f8ebf52
clean up some type definitions, add some comments
Mar 27, 2020
1faf1db
fix up MenuContext types
Mar 31, 2020
2c70bc5
omit as prop from select menu item
Mar 31, 2020
1235efd
move SelectMenu.Header out of modal
Mar 31, 2020
447c26d
remove filter prop from modal styles
Mar 31, 2020
2a1f757
clean up tab function
Mar 31, 2020
a2920d9
tweak filter docs
Mar 31, 2020
73d239b
add filter docs
Mar 31, 2020
9071bec
pass theme down
Mar 31, 2020
84f9c18
pass theme down
Mar 31, 2020
fdcdb22
tweak filter theme props
Mar 31, 2020
5738109
pass theme down in modal
Mar 31, 2020
3538187
Update src/SelectMenu/SelectMenuTabs.js
Mar 31, 2020
eb2022d
Update src/SelectMenu/hooks/KeyboardHook.js
Mar 31, 2020
f1e3ab5
props fix
Mar 31, 2020
dfa4238
lint
Mar 31, 2020
fed5694
Merge branch 'major' into select-menu
Mar 31, 2020
a2001f8
update snaps
Mar 31, 2020
350b74c
fix code examples
Mar 31, 2020
fdec085
update background color
Mar 31, 2020
fdbe53f
fix spacing
Mar 31, 2020
b94b0bc
rename keyboard nav hook file
Mar 31, 2020
8bb7892
move styles into component files
Mar 31, 2020
2c44f59
update keyboard hook to use state instead of dom attributes
Mar 31, 2020
ddc309c
spread as out on select menu
Mar 31, 2020
e8dca25
test updates
Mar 31, 2020
c7122c5
test clicking on items works
Apr 1, 2020
8f6013c
update "as" test, fix theme errors
Apr 1, 2020
96d3309
lint
Apr 1, 2020
05174f5
Update SelectMenu.js
Apr 2, 2020
573f5d1
removed unused snapshot
Apr 2, 2020
364cf60
Merge branch 'major' into select-menu
Apr 2, 2020
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
2 changes: 2 additions & 0 deletions docs/content/Buttons.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ To create a button group, wrap `Button` elements in the `ButtonGroup` element. `
<Button>Button</Button>
<Button>Button</Button>
</ButtonGroup>

<ButtonTableList>Button Table List </ButtonTableList>
```

## System props
Expand Down
287 changes: 287 additions & 0 deletions docs/content/SelectMenu.md
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.
2 changes: 2 additions & 0 deletions docs/src/@primer/gatsby-theme-doctocat/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
url: /Position
- title: ProgressBar
url: /ProgressBar
- title: SelectMenu
url: /SelectMenu
- title: SideNav
url: /SideNav
- title: StateLabel
Expand Down
Loading