-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Page navigation component * Add page navigation component to project * hoc to anchor, file name only * asAnchor => Anchor component * yarn lock * as-nav-link fixtures and snapshot * update usage instructions * Separate React Router example from standard usage * Remove `exact` from fixture links * Snapshot update following `exact` change * Change `let` for `const` in test * Update non react router fixture to use non react router props
- Loading branch information
Showing
11 changed files
with
669 additions
and
7 deletions.
There are no files selected for viewing
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,52 @@ | ||
PageNavigation | ||
============== | ||
|
||
### Import | ||
```js | ||
import PageNavigation from '@govuk-frederic/page-navigation'; | ||
``` | ||
<!-- STORY --> | ||
|
||
### Usage | ||
|
||
Default example | ||
|
||
```jsx | ||
import { Link } from 'react-router-dom'; | ||
import PageNavigation, { asAnchor } from '@govuk-frederic/page-navigation'; | ||
|
||
const NavLink = asAnchor(Link); | ||
const NavigationItems = [ | ||
{ | ||
url: '/', | ||
title: 'Home', | ||
}, | ||
{ | ||
url: '/section-01', | ||
title: 'Section 01', | ||
}, | ||
{ | ||
url: '/section-02', | ||
title: 'Section 02', | ||
}, | ||
]; | ||
|
||
… | ||
|
||
<PageNavigation> | ||
{NavigationItems.map(({url, title}, index) => ( | ||
<NavLink key={index} to={url}>{title}</NavLink> | ||
))} | ||
</PageNavigation> | ||
``` | ||
|
||
### TODO: | ||
- Add responsive considerations | ||
- Replace magic numbers from HOC items with constants | ||
|
||
### Properties | ||
Prop | Required | Default | Type | Description | ||
:--- | :------- | :------ | :--- | :---------- | ||
`children` | | ```null``` | node | Navigation items | ||
|
||
|
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,34 @@ | ||
{ | ||
"name": "@govuk-frederic/page-navigation", | ||
"version": "0.1.1", | ||
"dependencies": { | ||
"@govuk-react/constants": "^0.2.7", | ||
"govuk-colours": "^1.0.3" | ||
}, | ||
"devDependencies": { | ||
"@govuk-react/storybook-components": "^0.2.4", | ||
"as-nav-link": "^0.1.4" | ||
}, | ||
"peerDependencies": { | ||
"emotion": ">=9", | ||
"prop-types": ">=15", | ||
"react": ">=16.2.0", | ||
"react-emotion": ">=9" | ||
}, | ||
"scripts": { | ||
"build": "npm run build:lib && npm run build:es", | ||
"build:lib": "rimraf lib && babel src -d lib --source-maps", | ||
"build:es": "rimraf es && cross-env BABEL_ENV=es babel src -d es --source-maps", | ||
"docs": "doc-component ./lib/index.js ./README.md" | ||
}, | ||
"main": "lib/index.js", | ||
"module": "es/index.js", | ||
"author": "Toby Brancher", | ||
"license": "MIT", | ||
"homepage": "https://github.com/stevesims/govuk-frederic/tree/master/components/page-navigation", | ||
"description": "Page navigation component", | ||
"private": false, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
Oops, something went wrong.