-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
ActionList Component: Primer CSS Implementation #1657
Merged
Merged
Changes from 80 commits
Commits
Show all changes
86 commits
Select commit
Hold shift + click to select a range
1f7d08e
add storybook, start actionlist
langermank 5eb8831
story composition, some katie edits
langermank 20c18e9
Merge branch 'main' of https://github.com/primer/css into actionlist
langermank 5867862
auto grid test
langermank 26f4464
one grid option
langermank b39f941
you win flexbox, you win
langermank 7734667
back on that grid grind
langermank 9c70c46
story for each item context
langermank a7967fe
import stories
langermank a375fef
add CSS friendly args for controls
langermank 6fcbe26
more conditionals
langermank f98f7ce
push
langermank 32bbc68
fix import
langermank e7e5eac
clean up deps
langermank bb73c0f
fix borders + hover state
langermank 8f4c3e5
add navigational to story
langermank a518486
primitive-ize
langermank 71ef4a3
break out files
langermank 138b596
a11y fix
langermank 5fc9181
list stories
langermank 2f8018a
add all theme viewer, more css edge cases
langermank 60b0047
story cleanup
langermank f76d9a4
actionList becomes ActionList
langermank 0f5d3cf
story syntax improvements
langermank a8aadc4
bind stories, organize
langermank 937c41f
nested nav exploration
langermank 688b4cb
pseudo hover to support nested lists
langermank 591b33c
cleanup
langermank 58962ca
Merge branch 'main' of https://github.com/primer/css into actionlist
langermank 87987ed
organize pattern stories
langermank d6dee96
finding a better way to deal with state/nesting
langermank d851f3b
move state up one level
langermank 5bcd780
handle single level nesting
langermank b0248c6
collapsible
langermank 4caf59e
collapse story in sub item nav
langermank a0494c6
new collapse icon position, grid refactor
langermank ae75710
toggle expanded state
langermank 188a387
cleanup
langermank edc0bf3
rename classes, better nesting, single select
langermank fc3d68d
multi select support
langermank 300adf8
start docs!
langermank 6e81c36
new animations
langermank 142497c
docs
langermank 6570ce2
Merge branch 'main' of https://github.com/primer/css into actionlist
langermank 6963255
more docs
langermank 1086ccc
action item features docs
langermank 75c8e64
a11y docs (storybook)
langermank 7874e76
fix docs codeblocks
langermank cc233fc
format code snippet (a little)
langermank b57e9f8
Merge branch 'main' of https://github.com/primer/css into actionlist
langermank 59d6f11
pull in pre-release primitives
langermank 77d98cd
fix danger primitive
langermank 879b4b4
cleanup
langermank 43829fe
linting playing tricks on me
langermank a816d75
linty fresh
langermank 1d3a5eb
renaming classes fun times
langermank 800a180
add disabled variant
langermank b0280f1
formatting struggles
langermank fa041cc
danger visual danger color
langermank f1f129e
add viewport maps to layout vars
langermank df652e8
test stylelint
langermank 1f9c579
finish docs
langermank f67dbea
revert primitive upgrade
langermank ce906f7
Merge branch 'main' of https://github.com/primer/css into actionlist
langermank ce0e4cc
Merge branch 'main' into actionlist
jonrohan 3a4c91b
primitives patch take 2, sidebar story
langermank 5787b3a
Merge branch 'actionlist' of https://github.com/primer/css into actio…
langermank 9249695
Merge branch 'main' into actionlist
jonrohan 5b28b0b
change calc function
langermank d358672
Merge branch 'main' of https://github.com/primer/css into actionlist
langermank 6770fe7
remove fix script
langermank 32a1e12
lint, docs fixes
langermank 7ac2cca
Stylelint auto-fixes
actions-user 6a68c22
guessing the storybook link for docs
langermank e442b62
Merge branch 'actionlist' of https://github.com/primer/css into actio…
langermank 7c793ed
testing scss imports
langermank e421409
Merge branch 'main' of https://github.com/primer/css into actionlist
langermank e7344cb
lint
langermank 27d7ac4
default background
langermank c67690e
handle padding for sizes
langermank a7ac5e1
remove comments
langermank 8474859
Stylelint auto-fixes
actions-user a1eb1ba
Merge branch 'main' of https://github.com/primer/css into actionlist
langermank ea5f71b
Merge branch 'main' into actionlist
jonrohan 73090da
Create poor-walls-occur.md
jonrohan d6dd77c
Update poor-walls-occur.md
jonrohan 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
180 changes: 180 additions & 0 deletions
180
docs/src/stories/components/ActionList/Accessibility.stories.mdx
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,180 @@ | ||
import {Meta, Story, Canvas} from '@storybook/addon-docs' | ||
|
||
<Meta title="Components/ActionList/Accessibility" /> | ||
|
||
### Action List | ||
|
||
An action list is a vertical list of interactive <strong>actions</strong> or <strong>options</strong>. | ||
|
||
| | | | ||
| :------ | :------------------------------------ | | ||
| Actions | links `a href` or events `onclick` | | ||
| Options | checkbox role `checked` or `selected` | | ||
|
||
### Semantic markup | ||
|
||
The markup for Action List changes depending on the intended use case. | ||
|
||
In all cases, the basic structure is as follows: | ||
|
||
```html | ||
<ul> | ||
<li><span>Content with action</span></li> | ||
<li><a href="/">Content as link</a></li> | ||
<li> | ||
<ul> | ||
<li>Nested list</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
``` | ||
|
||
Pay close attention to `role` attributes throughout the documentation, and find the use case that best suits your needs. | ||
|
||
### Menu | ||
|
||
[Menu spec](https://www.w3.org/TR/wai-aria-practices-1.1/#menu) | ||
|
||
Note: JS is required for to provide keyboard handling along with [tab-index](https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_roving_tabindex) | ||
|
||
| Element | Role | | ||
| :------ | :------------------------------ | | ||
| `ul` | `role="menu"` | | ||
| `li` | no child link `role="menuitem"` | | ||
| `li` | has child link `role="none"` | | ||
| `a` | `role="menuitem"` | | ||
|
||
#### Example | ||
|
||
<Canvas> | ||
<Story id="components-actionlist-patterns--menu-with-section-divider" /> | ||
</Canvas> | ||
|
||
### Navigational menu | ||
|
||
[Menu spec](https://www.w3.org/TR/wai-aria-practices-1.1/#menu) | ||
|
||
Note: JS is required for to provide keyboard handling along with [tab-index](https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_roving_tabindex) | ||
|
||
| Element | Role | | ||
| :------ | :--------------------------------------- | | ||
| `nav` | no role needed | | ||
| `ul` | `role="menu"` | | ||
| `li` | no child link `role="menuitem"` | | ||
| `li` | has child link `role="none"` | | ||
| `li` | nested menu `aria-haspopup="true"` | | ||
| `li` | nested menu `aria-expanded="true/false"` | | ||
| `a` | `role="menuitem"` | | ||
|
||
#### Example | ||
|
||
<Canvas> | ||
<Story id="components-actionlist-patterns--nav-with-sub-items" /> | ||
</Canvas> | ||
|
||
### Multi select menu | ||
|
||
[Menu spec](https://www.w3.org/TR/wai-aria-practices-1.1/examples/menubar/menubar-2/menubar-2.html) | ||
|
||
Note: JS is required for to provide keyboard handling along with [tab-index](https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_roving_tabindex) | ||
|
||
| Element | Role | | ||
| :------ | :-------------------------------------- | | ||
| `ul` | `role="menu"` | | ||
| `li` | no child link `role="menuitemcheckbox"` | | ||
| `li` | `aria-checked="true/false"` | | ||
|
||
#### Example | ||
|
||
<Canvas> | ||
<Story id="components-actionlist-patterns--menu-multi-select" /> | ||
</Canvas> | ||
|
||
### Single select menu | ||
|
||
[Menu spec](https://www.w3.org/TR/wai-aria-practices-1.1/examples/menubar/menubar-2/menubar-2.html) | ||
|
||
Note: JS is required for to provide keyboard handling along with [tab-index](https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_roving_tabindex) | ||
|
||
| Element | Role | | ||
| :------ | :----------------------------------- | | ||
| `ul` | `role="menu"` | | ||
| `li` | no child link `role="menuitemradio"` | | ||
| `li` | `aria-checked="true/false"` | | ||
|
||
#### Example | ||
|
||
<Canvas> | ||
<Story id="components-actionlist-patterns--menu-single-select" /> | ||
</Canvas> | ||
|
||
### Multi select listbox | ||
|
||
[Menu spec](https://www.w3.org/TR/wai-aria-practices-1.1/#Listbox) | ||
|
||
Note: JS is required for to provide [keyboard handling](https://www.w3.org/TR/wai-aria-practices-1.1/#listbox_kbd_interaction) | ||
|
||
| Element | Role | | ||
| :------ | :---------------------------- | | ||
| `ul` | `role="listbox"` | | ||
| `ul` | `aria-multiselectable="true"` | | ||
| `li` | `role="option"` | | ||
| `li` | `aria-selected="true/false"` | | ||
|
||
#### Example | ||
|
||
<Canvas> | ||
<Story id="components-actionlist-patterns--list-multi-select" /> | ||
</Canvas> | ||
|
||
### Single select listbox | ||
|
||
[Menu spec](https://www.w3.org/TR/wai-aria-practices-1.1/#Listbox) | ||
|
||
Note: JS is required for to provide [keyboard handling](https://www.w3.org/TR/wai-aria-practices-1.1/#listbox_kbd_interaction) | ||
|
||
| Element | Role | | ||
| :------ | :--------------------------- | | ||
| `ul` | `role="listbox"` | | ||
| `li` | `role="option"` | | ||
| `li` | `aria-selected="true/false"` | | ||
|
||
#### Example | ||
|
||
<Canvas> | ||
<Story id="components-actionlist-patterns--list-single-select" /> | ||
</Canvas> | ||
|
||
### List of links | ||
|
||
No roles needed | ||
|
||
#### Example | ||
|
||
<Canvas> | ||
<Story id="components-actionlist-patterns--list" /> | ||
</Canvas> | ||
|
||
### Dividers | ||
|
||
| Element | Role | | ||
| :------ | :----------------- | | ||
| `li` | `role="separator"` | | ||
|
||
#### Empty example | ||
|
||
<Canvas> | ||
<Story id="components-actionlist-actionlistitem-features--divider-empty" /> | ||
</Canvas> | ||
|
||
| Element | Role | | ||
| :------ | :------------------------------------------ | | ||
| `li` | `role="presentation"` | | ||
| `li` | id for nested group `id="group-id"` | | ||
| `li` | if it has id for group `aria-hidden="true"` | | ||
|
||
#### With title example | ||
|
||
<Canvas> | ||
<Story id="components-actionlist-actionlistitem-features--divider-text" /> | ||
</Canvas> |
113 changes: 113 additions & 0 deletions
113
docs/src/stories/components/ActionList/ActionList.stories.jsx
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,113 @@ | ||
import React from 'react' | ||
import clsx from 'clsx' | ||
import {ListItemTemplate} from './ActionListItem.stories' | ||
|
||
export default { | ||
title: 'Components/ActionList', | ||
excludeStories: ['ListTemplate'], | ||
parameters: { | ||
design: { | ||
type: 'figma', | ||
url: 'https://www.figma.com/file/oMiRuexZW6gqVbMhQd6lwP/Storybook-Docs?node-id=23%3A30843' | ||
} | ||
}, | ||
argTypes: { | ||
showDividers: { | ||
control: {type: 'boolean'}, | ||
description: 'Show dividers between items', | ||
table: { | ||
category: 'CSS' | ||
} | ||
}, | ||
role: { | ||
options: [0, 1, 2, 3, 4, 5, 6], // iterator | ||
mapping: ['menu', 'group', 'listbox', 'menubar', 'none', 'radiogroup', 'list'], // values | ||
control: { | ||
type: 'select', | ||
labels: ['menu', 'group', 'listbox', 'menubar', 'none', 'radiogroup', 'list'] | ||
}, | ||
description: 'Semantic list role', | ||
table: { | ||
category: 'HTML' | ||
} | ||
}, | ||
ariaLabel: { | ||
name: 'ariaLabel', | ||
type: 'string', | ||
description: 'Descriptive label for menu contents', | ||
table: { | ||
category: 'HTML' | ||
} | ||
}, | ||
ariaLabelledBy: { | ||
name: 'ariaLabelledBy', | ||
type: 'string', | ||
description: 'Reference ID of section divider', | ||
table: { | ||
category: 'HTML' | ||
} | ||
}, | ||
groupId: { | ||
name: 'groupId', | ||
type: 'string', | ||
description: 'Menu group id', | ||
table: { | ||
category: 'HTML' | ||
} | ||
}, | ||
children: { | ||
table: { | ||
category: 'HTML' | ||
} | ||
}, | ||
subGroup: { | ||
control: {type: 'boolean'}, | ||
description: 'If ActionList is nested within an ActionList', | ||
table: { | ||
category: 'CSS' | ||
} | ||
}, | ||
listboxMultiSelect: { | ||
name: 'listboxMultiSelect', | ||
type: 'string', | ||
description: 'If ActionList has listbox role + multiselect children', | ||
table: { | ||
category: 'HTML' | ||
} | ||
} | ||
} | ||
} | ||
|
||
export const ListTemplate = ({ | ||
showDividers, | ||
children, | ||
role, | ||
ariaLabel, | ||
ariaLabelledBy, | ||
subGroup, | ||
listboxMultiSelect | ||
}) => ( | ||
<ul | ||
className={clsx('ActionList', showDividers && 'ActionList--divided', subGroup && 'ActionList--subGroup')} | ||
role={role} | ||
aria-label={ariaLabel && ariaLabel} | ||
aria-labelledby={ariaLabelledBy && ariaLabelledBy} | ||
aria-multiselectable={listboxMultiSelect ? 'true' : undefined} | ||
> | ||
<>{children}</> | ||
</ul> | ||
) | ||
|
||
export const Playground = ListTemplate.bind({}) | ||
Playground.args = { | ||
role: 'menu', | ||
ariaLabel: 'Menu description', | ||
subGroup: false, | ||
showDividers: false, | ||
children: ( | ||
<> | ||
<ListItemTemplate text="Action list item" /> | ||
<ListItemTemplate text="Action list item" /> | ||
</> | ||
) | ||
} |
81 changes: 81 additions & 0 deletions
81
docs/src/stories/components/ActionList/ActionListDivider.stories.jsx
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,81 @@ | ||
import React from 'react' | ||
import clsx from 'clsx' | ||
|
||
export default { | ||
title: 'Components/ActionList/ActionListDivider', | ||
excludeStories: ['DividerTemplate'], | ||
parameters: { | ||
design: { | ||
type: 'figma', | ||
url: 'https://www.figma.com/file/oMiRuexZW6gqVbMhQd6lwP/Storybook?node-id=2%3A2' | ||
} | ||
}, | ||
argTypes: { | ||
variant: { | ||
options: [0, 1], // iterator | ||
mapping: ['', 'ActionList-sectionDivider--filled'], // values | ||
control: { | ||
type: 'select', | ||
labels: ['subtle', 'filled'] | ||
}, | ||
table: { | ||
category: 'CSS' | ||
} | ||
}, | ||
title: { | ||
defaultValue: '', | ||
type: 'string', | ||
name: 'title', | ||
description: 'string', | ||
table: { | ||
category: 'HTML' | ||
} | ||
}, | ||
description: { | ||
defaultValue: '', | ||
type: 'string', | ||
name: 'description', | ||
description: 'string', | ||
table: { | ||
category: 'HTML' | ||
} | ||
}, | ||
id: { | ||
defaultValue: '', | ||
type: 'string', | ||
name: 'id', | ||
description: 'Used for aria-labelledby', | ||
table: { | ||
category: 'HTML' | ||
} | ||
} | ||
}, | ||
decorators: [ | ||
Story => ( | ||
<ul className="ActionList" role="menu"> | ||
<Story /> | ||
</ul> | ||
) | ||
] | ||
} | ||
|
||
export const DividerTemplate = ({title, description, variant, id}) => ( | ||
<> | ||
<li | ||
className={clsx('ActionList-sectionDivider', variant && `${variant}`)} | ||
role={title ? 'presentation' : 'separator'} | ||
id={id} | ||
aria-hidden={title ? true : undefined} | ||
> | ||
{title} | ||
{description && <span className="ActionList-item-description">{description}</span>} | ||
</li> | ||
</> | ||
) | ||
|
||
export const Playground = DividerTemplate.bind({}) | ||
Playground.args = { | ||
title: 'Section title', | ||
description: 'Section description', | ||
variant: 'subtle' | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Temporary- will update with next release