-
Notifications
You must be signed in to change notification settings - Fork 587
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
Implement NavList component (part 1) #2058
Changes from 9 commits
28cd204
343156d
ded93ee
9519adf
8a09b07
2583f2a
8f2856a
fa0fa0e
9bb2354
b3178d5
ca73b51
a47ce1f
f9d35dd
b1c569c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@primer/react": patch | ||
--- | ||
|
||
Add draft of `NavList` component |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,44 +2,30 @@ | |
title: NavList | ||
status: Draft | ||
description: Use nav list to render a vertical list of navigation links. | ||
source: https://github.com/primer/react/tree/main/src/NavList | ||
--- | ||
|
||
<Note variant="warning">Not implemented yet</Note> | ||
|
||
To render a horizontal list of navigation links, consider using [UnderlineNav](/UnderlineNav). | ||
```js | ||
import {NavList} from '@primer/react/drafts' | ||
``` | ||
|
||
## Examples | ||
|
||
### Simple | ||
|
||
```jsx | ||
```jsx live drafts | ||
<NavList> | ||
<NavList.Item href="/" aria-current="page"> | ||
Dashboard | ||
Home | ||
</NavList.Item> | ||
<NavList.Item href="/pulls">Pull requests</NavList.Item> | ||
<NavList.Item href="/issues">Issues</NavList.Item> | ||
<NavList.Item href="/about">About</NavList.Item> | ||
<NavList.Item href="/contact">Contact</NavList.Item> | ||
</NavList> | ||
``` | ||
|
||
<details> | ||
<summary>Rendered HTML</summary> | ||
|
||
```html | ||
<nav> | ||
<ul role="list"> | ||
<li><a href="/" aria-current="page">Dashboard</a></li> | ||
<li><a href="/about">Pull requests</a></li> | ||
<li><a href="/contact">Issues</a></li> | ||
</ul> | ||
</nav> | ||
``` | ||
|
||
</details> | ||
|
||
### With leading icons | ||
|
||
```jsx | ||
```jsx live drafts | ||
<NavList> | ||
<NavList.Item href="/" aria-current="page"> | ||
<NavList.LeadingVisual> | ||
|
@@ -62,88 +48,34 @@ To render a horizontal list of navigation links, consider using [UnderlineNav](/ | |
</NavList> | ||
``` | ||
|
||
<details> | ||
<summary>Rendered HTML</summary> | ||
|
||
```html | ||
<nav> | ||
<ul role="list"> | ||
<li> | ||
<a href="/" aria-current="page"> | ||
<span><svg aria-hidden="true">...</svg></span> | ||
<span>Dashboard</span> | ||
</a> | ||
</li> | ||
<li> | ||
<a href="/pulls"> | ||
<span><svg aria-hidden="true">...</svg></span> | ||
<span>Pull requests</span> | ||
</a> | ||
</li> | ||
<li> | ||
<a href="/issues"> | ||
<span><svg aria-hidden="true">...</svg></span> | ||
<span>Issues</span> | ||
</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
``` | ||
|
||
</details> | ||
|
||
### With other leading visuals | ||
|
||
```jsx | ||
```jsx live drafts | ||
<NavList> | ||
<NavList.Item href="/general" aria-current="page"> | ||
<NavList.LeadingVisual>#️⃣</NavList.LeadingVisual> | ||
<NavList.LeadingVisual> | ||
<span aria-hidden>#️⃣</span> | ||
</NavList.LeadingVisual> | ||
General | ||
</NavList.Item> | ||
<NavList.Item href="/q-a"> | ||
<NavList.LeadingVisual>🙏</NavList.LeadingVisual> | ||
<NavList.LeadingVisual> | ||
<span aria-hidden>🙏</span> | ||
</NavList.LeadingVisual> | ||
Q&A | ||
</NavList.Item> | ||
<NavList.Item href="/show-and-tell"> | ||
<NavList.LeadingVisual>🙌</NavList.LeadingVisual> | ||
<NavList.LeadingVisual> | ||
<span aria-hidden>🙌</span> | ||
</NavList.LeadingVisual> | ||
Show and tell | ||
</NavList.Item> | ||
</NavList> | ||
``` | ||
|
||
<details> | ||
<summary>Rendered HTML</summary> | ||
|
||
```html | ||
<nav> | ||
<ul role="list"> | ||
<li> | ||
<a href="/" aria-current="page"> | ||
<span>#️⃣</span> | ||
<span>General</span> | ||
</a> | ||
</li> | ||
<li> | ||
<a href="/pulls"> | ||
<span>🙏</span> | ||
<span>Q&A</span> | ||
</a> | ||
</li> | ||
<li> | ||
<a href="/issues"> | ||
<span>🙌</span> | ||
<span>Show and tell</span> | ||
</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
``` | ||
|
||
</details> | ||
|
||
### With trailing visuals | ||
|
||
```jsx | ||
```jsx live drafts | ||
<NavList> | ||
<NavList.Item href="/inbox" aria-current="page"> | ||
Inbox | ||
|
@@ -154,31 +86,13 @@ To render a horizontal list of navigation links, consider using [UnderlineNav](/ | |
</NavList> | ||
``` | ||
|
||
<details> | ||
<summary>Rendered HTML</summary> | ||
|
||
```html | ||
<nav> | ||
<ul role="list"> | ||
<li> | ||
<a href="/inbox" aria-current="page"> | ||
<span>Inbox</span> | ||
<span>1,234</span> | ||
</a> | ||
</li> | ||
<li><a href="/saved">Saved</a></li> | ||
<li><a href="/done">Done</a></li> | ||
</ul> | ||
</nav> | ||
``` | ||
|
||
</details> | ||
|
||
### With a heading | ||
|
||
```jsx | ||
```jsx live drafts | ||
<> | ||
<h3 id="workflows-heading">Workflows</h3> | ||
<Heading as="h3" id="workflows-heading" sx={{fontSize: 2}}> | ||
Workflows | ||
</Heading> | ||
<NavList aria-labelledby="workflows-heading"> | ||
<NavList.Item href="/" aria-current="page"> | ||
All workflows | ||
|
@@ -190,26 +104,9 @@ To render a horizontal list of navigation links, consider using [UnderlineNav](/ | |
</> | ||
``` | ||
|
||
<details> | ||
<summary>Rendered HTML</summary> | ||
|
||
```html | ||
<h3 id="workflows-heading">Workflows</h3> | ||
<nav aria-labelledby="workflows-heading"> | ||
<ul role="list"> | ||
<li><a href="/" aria-current="page">All workflows</a></li> | ||
<li><a href="/ci">CI</a></li> | ||
<li><a href="/deploy">Deploy</a></li> | ||
<li><a href="/release">Release</a></li> | ||
</ul> | ||
</nav> | ||
``` | ||
|
||
</details> | ||
|
||
### With aria-label | ||
|
||
```jsx | ||
```jsx live drafts | ||
<NavList aria-label="Security"> | ||
<NavList.Item href="/" aria-current="page"> | ||
Overview | ||
|
@@ -219,24 +116,9 @@ To render a horizontal list of navigation links, consider using [UnderlineNav](/ | |
</NavList> | ||
``` | ||
|
||
<details> | ||
<summary>Rendered HTML</summary> | ||
|
||
```html | ||
<nav aria-label="Security"> | ||
<ul role="list"> | ||
<li><a href="/" aria-current="page">Overview</a></li> | ||
<li><a href="/policy">Security policy</a></li> | ||
<li><a href="/advisories">Security advisories</a></li> | ||
</ul> | ||
</nav> | ||
``` | ||
|
||
</details> | ||
|
||
### With groups | ||
|
||
```jsx | ||
```jsx live drafts | ||
<NavList> | ||
<NavList.Group title="Overview"> | ||
<NavList.Item href="/getting-started" aria-current="page"> | ||
|
@@ -251,34 +133,10 @@ To render a horizontal list of navigation links, consider using [UnderlineNav](/ | |
</NavList> | ||
``` | ||
|
||
<details> | ||
<summary>Rendered HTML</summary> | ||
|
||
```html | ||
<nav> | ||
<ul role="list"> | ||
<li> | ||
<div role="presentation" id="generated-id-1">Overview</div> | ||
<ul role="list" aria-labelledby="generated-id-1"> | ||
<li><a href="/getting-started" aria-current="page">Getting started</a></li> | ||
</ul> | ||
</li> | ||
<li> | ||
<div role="presentation" id="generated-id-2">Components</div> | ||
<ul role="list" aria-labelledby="generated-id-2"> | ||
<li><a href="/Avatar">Avatar</a></li> | ||
<li><a href="/Button">Button</a></li> | ||
<li><a href="/Label">Label</a></li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</nav> | ||
``` | ||
|
||
</details> | ||
|
||
### With sub-items | ||
|
||
<Note variant="danger">Not implemented yet</Note> | ||
|
||
```jsx | ||
<NavList> | ||
<NavList.Item href="/branches">Branches</NavList.Item> | ||
|
@@ -325,9 +183,11 @@ If a `NavList.Item` contains a `NavList.SubNav`, the `NavList.Item` will render | |
|
||
### With a divider | ||
|
||
```jsx | ||
```jsx live drafts | ||
<NavList> | ||
<NavList.Item href="/">Dashboard</NavList.Item> | ||
<NavList.Item href="/" aria-current="page"> | ||
Dashboard | ||
</NavList.Item> | ||
<NavList.Item href="/pulls">Pull requests</NavList.Item> | ||
<NavList.Item href="/issues">Issues</NavList.Item> | ||
<NavList.Divider /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is interesting 🤔 Would we also want to support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think dividers in between individual items is part of the NavList design cc @vdepizzol |
||
|
@@ -336,26 +196,10 @@ If a `NavList.Item` contains a `NavList.SubNav`, the `NavList.Item` will render | |
</NavList> | ||
``` | ||
|
||
<details> | ||
<summary>Rendered HTML</summary> | ||
|
||
```html | ||
<nav> | ||
<ul role="list"> | ||
<li><a href="/">Dashboard</a></li> | ||
<li><a href="/pulls">Pull requests</a></li> | ||
<li><a href="/issues">Issues</a></li> | ||
<div role="separator"></div> | ||
<li><a href="/marketplace">Marketplace</a></li> | ||
<li><a href="/explore">Explore</a></li> | ||
</ul> | ||
</nav> | ||
``` | ||
|
||
</details> | ||
|
||
### With React Router | ||
|
||
<Note variant="danger">Not implemented yet</Note> | ||
|
||
```jsx | ||
import {Link, useMatch, useResolvedPath} from 'react-router-dom' | ||
import {NavList} from '@primer/react' | ||
|
@@ -383,6 +227,8 @@ function App() { | |
|
||
### With Next.js | ||
|
||
<Note variant="danger">Not implemented yet</Note> | ||
|
||
```jsx | ||
import {useRouter} from 'next/router' | ||
import Link from 'next/link' | ||
|
@@ -506,10 +352,10 @@ function App() { | |
<ComponentChecklist | ||
items={{ | ||
propsDocumented: true, | ||
noUnnecessaryDeps: false, | ||
adaptsToThemes: false, | ||
adaptsToScreenSizes: false, | ||
fullTestCoverage: false, | ||
noUnnecessaryDeps: true, | ||
adaptsToThemes: true, | ||
adaptsToScreenSizes: true, | ||
fullTestCoverage: true, | ||
usedInProduction: false, | ||
usageExamplesDocumented: true, | ||
hasStorybookStories: false, | ||
|
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.
Good example!