Skip to content
This repository has been archived by the owner on Aug 13, 2023. It is now read-only.

Create dropdown navigation #2613

Merged
merged 121 commits into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from 94 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
61e02c3
Import psammead-assets icons
OlgaLyubin Nov 11, 2019
4bcfa4f
Add menu open button
OlgaLyubin Nov 11, 2019
5f09a5d
Bump up component version
OlgaLyubin Nov 11, 2019
6566e7d
Merge branch 'latest' of github.com:bbc/psammead into burger-dropdown…
OlgaLyubin Nov 11, 2019
0827fab
Add dropdown navigation
OlgaLyubin Nov 12, 2019
57c5440
Add story for dropdown navigation
OlgaLyubin Nov 12, 2019
b1a2c37
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 12, 2019
60abd2e
Update PR version in changelog
OlgaLyubin Nov 12, 2019
c76e77a
Small refactoring tweaks
OlgaLyubin Nov 12, 2019
d75f487
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 12, 2019
67ed851
Add snapshot testing for dropdown navigation
OlgaLyubin Nov 12, 2019
0bb78fe
Move dropdown navigation to a subfolder
OlgaLyubin Nov 13, 2019
b785412
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 13, 2019
5c7df7c
Merge branch 'latest' of github.com:bbc/psammead into burger-dropdown…
OlgaLyubin Nov 13, 2019
70db1a0
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 13, 2019
f3d8432
Merge branch 'burger-dropdown-nav' of github.com:bbc/psammead into bu…
OlgaLyubin Nov 13, 2019
764cafe
Refactoring for screen readers
OlgaLyubin Nov 13, 2019
2012b0b
Fix console warnings in stories
OlgaLyubin Nov 13, 2019
2d2b6ac
Update tests
OlgaLyubin Nov 13, 2019
36e7601
Update snapshots
OlgaLyubin Nov 13, 2019
1ad86a5
Update readme
OlgaLyubin Nov 13, 2019
d241859
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 13, 2019
50cda6e
Move hamburger inside the navigation
OlgaLyubin Nov 14, 2019
ed15bdd
Update snapshots
OlgaLyubin Nov 14, 2019
70f2107
Remove unneeded css styling
OlgaLyubin Nov 14, 2019
0c7e60b
Move dir-dependant styling into a function
OlgaLyubin Nov 14, 2019
7e43d99
Props renaming
OlgaLyubin Nov 14, 2019
14aa659
Refactor readme
OlgaLyubin Nov 14, 2019
4c4e64c
Readme update
OlgaLyubin Nov 14, 2019
168fee1
Readme update 2
OlgaLyubin Nov 14, 2019
240aeac
Fix navigation on Safari
OlgaLyubin Nov 15, 2019
cbc241d
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 18, 2019
6e4bf39
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 18, 2019
b19bf1e
Merge branch 'latest' into burger-dropdown-nav
rhenshaw56 Nov 18, 2019
4a5264d
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 18, 2019
9c805f5
Fix aria attributes
OlgaLyubin Nov 18, 2019
647c835
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 19, 2019
8305e8a
Create variables for constants
OlgaLyubin Nov 19, 2019
4e0be0f
Remove hamburger from navigation component
OlgaLyubin Nov 19, 2019
e218a30
Update snapshots
OlgaLyubin Nov 19, 2019
ab56340
Rename tests
OlgaLyubin Nov 19, 2019
0613b14
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 19, 2019
554f307
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 19, 2019
6c922d9
Update readme
OlgaLyubin Nov 19, 2019
fc4583d
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 19, 2019
a439210
Refactoring
OlgaLyubin Nov 19, 2019
7b1310f
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 19, 2019
0c7eb18
Update prop types for hamburger
OlgaLyubin Nov 20, 2019
5430284
Update prop types for dropdown
OlgaLyubin Nov 20, 2019
2214dde
Fix mistake
OlgaLyubin Nov 20, 2019
5938ef4
Rearrange propTypes
OlgaLyubin Nov 20, 2019
cbfd261
Update propTypes and usage info in README
OlgaLyubin Nov 20, 2019
e7b772c
Deal with imports/exports
OlgaLyubin Nov 21, 2019
d1c4d66
Pull in new version of nav icons
OlgaLyubin Nov 21, 2019
89de616
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 21, 2019
fbe200b
Update snapshots
OlgaLyubin Nov 21, 2019
503afa1
Merge branch 'burger-dropdown-nav' of github.com:bbc/psammead into bu…
OlgaLyubin Nov 21, 2019
4872885
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 21, 2019
f5d73ef
Update readme
OlgaLyubin Nov 21, 2019
28ad015
Refactoring
OlgaLyubin Nov 21, 2019
b8c94a0
Update snapshots
OlgaLyubin Nov 21, 2019
5ffd659
Refactoring 2
OlgaLyubin Nov 21, 2019
d3b9516
Refactor props
OlgaLyubin Nov 21, 2019
0aa3a29
Refactor DropdownNavigationLi
OlgaLyubin Nov 21, 2019
01514b0
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 21, 2019
1b4db55
Refactor stories
OlgaLyubin Nov 21, 2019
7350675
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 21, 2019
7832f8a
Change how we export dropdown nav
OlgaLyubin Nov 21, 2019
fe24ecd
Merge branch 'burger-dropdown-nav' of github.com:bbc/psammead into bu…
OlgaLyubin Nov 21, 2019
778e11c
Linting error
OlgaLyubin Nov 21, 2019
bc10692
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 21, 2019
c313095
Change composition of dropdowns
OlgaLyubin Nov 21, 2019
d166050
Refactor attributes
OlgaLyubin Nov 21, 2019
612126a
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 25, 2019
4a6a52f
Fix firefox high contrast issue
OlgaLyubin Nov 25, 2019
451e7c7
Fix FF high contrast for hamburger icon
OlgaLyubin Nov 25, 2019
b3999b3
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 25, 2019
ad13e4f
Renaming export and component
OlgaLyubin Nov 25, 2019
2d07525
Update readme
OlgaLyubin Nov 25, 2019
c6992ee
Fix amp dropdown
OlgaLyubin Nov 25, 2019
3cfc1e1
Add AMP tests
OlgaLyubin Nov 25, 2019
365ea51
Fix prop type warning
OlgaLyubin Nov 25, 2019
66f8927
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 25, 2019
1b31971
Add handler tests. Update snapshots.
Nov 25, 2019
9459d76
Merge branch 'burger-dropdown-nav' of github.com:bbc/psammead into bu…
Nov 25, 2019
9135564
Add nested describe().
Nov 25, 2019
9e62942
Add AMP stories
OlgaLyubin Nov 26, 2019
bbd6823
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 26, 2019
5269f65
Fix borders for icons
OlgaLyubin Nov 26, 2019
1369a26
Merge branch 'latest' into burger-dropdown-nav
DenisHdz Nov 26, 2019
a50ba57
Merge branch 'latest' into burger-dropdown-nav
PriyaKR Nov 26, 2019
901bfee
Merge branch 'latest' into burger-dropdown-nav
PriyaKR Nov 26, 2019
d9c057b
Add hover styling
OlgaLyubin Nov 26, 2019
04983c1
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 27, 2019
ab2f103
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 27, 2019
35597e8
Make two buttons into one
OlgaLyubin Nov 27, 2019
dba8555
Update stories
OlgaLyubin Nov 27, 2019
1045efa
Update tests
OlgaLyubin Nov 27, 2019
5f2fc21
Merge branch 'burger-dropdown-nav' of github.com:bbc/psammead into bu…
OlgaLyubin Nov 27, 2019
cadda87
Fix failing test
OlgaLyubin Nov 27, 2019
ee7f2ef
Add visibility hidden
OlgaLyubin Nov 27, 2019
4540169
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 27, 2019
a297ccb
Pull in new version of icons
OlgaLyubin Nov 27, 2019
ceea472
Change how canonical/amp dropdown works
OlgaLyubin Nov 27, 2019
f3d7c8d
Test that clicks are not called
OlgaLyubin Nov 27, 2019
67a3b5b
Refactor stories
OlgaLyubin Nov 27, 2019
1fc0eb6
Readme update
OlgaLyubin Nov 27, 2019
9f9ea1a
Refactoring
OlgaLyubin Nov 28, 2019
28853f9
Add comma after Current page text
OlgaLyubin Nov 28, 2019
5a94dfb
Add aria-expanded tests
OlgaLyubin Nov 28, 2019
1f14745
Merge branch 'latest' into burger-dropdown-nav
DenisHdz Nov 28, 2019
132dec4
Add role attribute
OlgaLyubin Nov 28, 2019
078bc81
Merge branch 'latest' into burger-dropdown-nav
Nov 28, 2019
d947fc7
Merge branch 'latest' into burger-dropdown-nav
DenisHdz Nov 28, 2019
217941a
Separate stories into canonical and AMP
OlgaLyubin Nov 28, 2019
b9f66b0
Merge branch 'latest' into burger-dropdown-nav
DenisHdz Nov 28, 2019
79310e8
Merge branch 'latest' into burger-dropdown-nav
DenisHdz Nov 28, 2019
57c3509
Merge branch 'latest' into burger-dropdown-nav
OlgaLyubin Nov 29, 2019
5b2b045
Readme update
OlgaLyubin Nov 29, 2019
a2da363
Merge branch 'latest' into burger-dropdown-nav
PriyaKR Nov 29, 2019
8e426ad
Merge branch 'latest' into burger-dropdown-nav
PriyaKR Nov 29, 2019
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
1 change: 1 addition & 0 deletions packages/components/psammead-navigation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- prettier-ignore -->
| Version | Description |
|---------|-------------|
| 6.0.0-alpha.1 | [PR#2613](https://github.com/bbc/psammead/pull/2613) Add dropdown menu with a hamburger button |
| 5.0.0-alpha.1 | [PR#2577](https://github.com/bbc/psammead/pull/2577) Add scrollable navigation |
| 4.0.0-alpha.2 | [PR#2697](https://github.com/bbc/psammead/pull/2697) Talos - Bump Dependencies - @bbc/psammead-styles |
| 4.0.0-alpha.1 | [PR#2563](https://github.com/bbc/psammead/pull/2563) Remove skip to content link |
Expand Down
129 changes: 126 additions & 3 deletions packages/components/psammead-navigation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ This component is currently tagged as alpha and is not suitable for production u

## Description

The `@bbc/psammead-navigation` package is a set of two components, `NavigationUl` and `NavigationLi`. They use `ul` and `li` HTML elements respectively.
The `@bbc/psammead-navigation` package is a set of two components, `NavigationUl` and `NavigationLi`. They use `ul` and `li` HTML elements respectively. The package also includes a Hamburger Menu and a Dropdown Navigation which are visible for breakpoints under 600px.
OlgaLyubin marked this conversation as resolved.
Show resolved Hide resolved

## Exports

`/dropdown` - adds a dropdown navigation with hamburger menu which is visible for breakpoints under 600px

## Exports

Expand Down Expand Up @@ -64,7 +68,54 @@ The `@bbc/psammead-navigation` package is a set of two components, `NavigationUl
| children | node | Yes | N/A | `<NavigationUl><NavigationLi url="/" script={latin} active="true">Home</NavigationLi><NavigationLi url="/sport" script={latin}>{Sport}</NavigationLi></NavigationUl>` |
| dir | string | No | `'ltr'` | `'rtl'` |

## Usage
### CanonicalDropdown
AlistairGempf marked this conversation as resolved.
Show resolved Hide resolved

<!-- prettier-ignore -->
| Argument | Type | Required | Default | Example |
| -------- | ---- | -------- | ------- | ------- |
| children | node | Yes | N/A | `<DropdownUl><DropdownLi script={latin} service='news' key='sport' url='/sport' active="false"> Sport </DropdownLi></DropdownUl>` |
| announcedText | string | Yes | N/A | `'Menu'` |
| onClose | function | Yes | N/A | `() => { console.log("Handle close action"); }` |

### AmpDropdown

<!-- prettier-ignore -->
| Argument | Type | Required | Default | Example |
| -------- | ---- | -------- | ------- | ------- |
| children | node | Yes | N/A | `<DropdownUl><DropdownLi script={latin} service='news' key='sport' url='/sport' active="false"> Sport </DropdownLi></DropdownUl>` |
| announcedText | string | Yes | N/A | `'Menu'` |
| onClose | string | Yes | N/A | `"tap:menu.toggleVisibility"` |

### DropdownLi

<!-- prettier-ignore -->
| Argument | Type | Required | Default | Example |
| -------- | ------- | -------- | ------- | -------- |
| children | string | Yes | N/A | `'Sport'` |
| url | string | Yes | N/A | `/sport` |
| script | object | Yes | N/A | `{ canon: { groupA: { fontSize: '28', lineHeight: '32',}, groupB: { fontSize: '32', lineHeight: '36', }, groupD: { fontSize: '44', lineHeight: '48', }, }, trafalgar: { groupA: { fontSize: '20', lineHeight: '24', }, groupB: { fontSize: '24', lineHeight: '28', }, groupD: { fontSize: '32', lineHeight: '36', }, }, }` |
| service | string | Yes | N/A | `'news'` |
| active | boolean | No | `false` | `true` |
| currentPageText | string | No | `null` | `Current page` |
| dir | string | No | `ltr` | `rtl` |

### CanonicalHamburgerMenu

<!-- prettier-ignore -->
| Argument | Type | Required | Default | Example |
| -------- | ---- | -------- | ------- | ------- |
| announcedText | string | Yes | N/A | `'Menu'` |
| onOpen | function | Yes | N/A | `() => { console.log("Handle open action"); }` |

### AmpHamburgerMenu

<!-- prettier-ignore -->
| Argument | Type | Required | Default | Example |
| -------- | ---- | -------- | ------- | ------- |
| announcedText | string | Yes | N/A | `'Menu'` |
| onOpen | string | Yes | N/A | `"tap:menu.toggleVisibility"` |

## Navigation Usage

```jsx
import React from 'react';
Expand Down Expand Up @@ -98,6 +149,76 @@ import { latin } from '@bbc/gel-foundations/scripts';
</Navigation>;
```

## Canonical Dropdown Navigation Usage

```jsx
import React from 'react';
import { CanonicalDropdown, DropdownUl, DropdownLi } from '@bbc/psammead-navigation/dropdown';
import { latin } from '@bbc/gel-foundations/scripts';

<CanonicalDropdown announcedText="Menu" onClose={() => {}}>
<DropdownUl>
<DropdownLi
script={latin}
service="news"
key="Home"
url="/"
active
currentPageText="Current page"
>
Home
</DropdownLi>
<DropdownLi script={latin} service="news" key="Sport" url="/sport">
Sport
</DropdownLi>
</DropdownUl>
</CanonicalDropdown>
```

## Amp Dropdown Navigation Usage

```jsx
import React from 'react';
import { AmpDropdown, DropdownUl, DropdownLi } from '@bbc/psammead-navigation/dropdown';
import { latin } from '@bbc/gel-foundations/scripts';

<AmpDropdown announcedText="Menu" onClose="tap:menu.toggleVisibility">
<DropdownUl>
<DropdownLi
script={latin}
service="news"
key="Home"
url="/"
active
currentPageText="Current page"
>
Home
</DropdownLi>
<DropdownLi script={latin} service="news" key="Sport" url="/sport">
Sport
</DropdownLi>
</DropdownUl>
</AmpDropdown>
```

## Canonical Hamburger Menu Usage

```jsx
import React from 'react';
import { CanonicalHamburgerMenu } from '@bbc/psammead-navigation/dropdown';

<CanonicalHamburgerMenu announcedText="Menu" onOpen={() => { console.log("Handle open action"); }} />
```

## Amp Hamburger Menu Usage

```jsx
import React from 'react';
import { AmpHamburgerMenu } from '@bbc/psammead-navigation/dropdown';

<AmpHamburgerMenu announcedText="Menu" onOpen="tap:menu.toggleVisibility" />
```

### When to use this component

The `Navigation` is designed to show a navigation bar on `index` pages, which will show all sections on a site. If there are too many items to fit on one line, the items will wrap to the next lines.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just index pages?

Expand All @@ -110,7 +231,9 @@ The Navigation has a [`navigation` landmark](https://www.w3.org/TR/wai-aria-prac

We have added the role `list` and `listitem` to the `NavigationUl` and `NavigationList` respectively, due to a VoiceOver bug to reinstate the list semantics.

We have also added visually hidden text to let the user know which item in the Navigation is the current page. Note the use of visually hidden text here is due to lack of support at this time for the aria-current page attribute. Also note the use of `role="text"` to stop splitting in VoiceOver.
We have also added visually hidden text to let the user know which item in both regular and dropdown Navigation is the current page. Note the use of visually hidden text here is due to lack of support at this time for the aria-current page attribute. Also note the use of `role="text"` to stop text splitting in VoiceOver.

We have added an `aria-expanded` attribute to both Hamburger and Cross menu buttons to indicate whether the menu is collapsed or expanded.

In the screen reader UX only the menu button and its content should be available to assistive technology, meaning the scrollable navigation will be hidden. To achieve this we add `aria-hidden:true` to the exposed scrollable navigation so that this is not visible to these users and also add `tabindex=-1` to the links contained within this to remove them from the tab order.

Expand Down
7 changes: 7 additions & 0 deletions packages/components/psammead-navigation/dropdown/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@bbc/psammead-navigation/dropdown",
"private": true,
"main": "../dist/DropdownNavigation",
"module": "../esm/DropdownNavigation",
"sideEffects": false
}
5 changes: 5 additions & 0 deletions packages/components/psammead-navigation/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions packages/components/psammead-navigation/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bbc/psammead-navigation",
"version": "5.0.0-alpha.1",
"version": "6.0.0-alpha.1",
"description": "A navigation bar to use on index pages",
"main": "dist/index.js",
"module": "esm/index.js",
Expand All @@ -21,7 +21,8 @@
"dependencies": {
"@bbc/gel-foundations": "^3.4.1",
"@bbc/psammead-styles": "^4.1.1",
"@bbc/psammead-visually-hidden-text": "^1.2.3"
"@bbc/psammead-visually-hidden-text": "^1.2.3",
"@bbc/psammead-assets": "^2.10.1"
},
"peerDependencies": {
"react": "^16.9.0",
Expand Down
Loading