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

Add prop isOpen to Navigation #2769

Merged
merged 13 commits into from
Dec 5, 2019
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.6 | [PR#2769](https://github.com/bbc/psammead/pull/2769) Add `changeBackground` prop to `Navigation` |
Bopchy marked this conversation as resolved.
Show resolved Hide resolved
| 6.0.0-alpha.5 | [PR#2759](https://github.com/bbc/psammead/pull/2759) Change size of menu button depending on script |
| 6.0.0-alpha.4 | [PR#2747](https://github.com/bbc/psammead/pull/2747) Fix MenuButton not acting as a block element |
| 6.0.0-alpha.3 | [PR#2745](https://github.com/bbc/psammead/pull/2745) Add dir prop to Amp and Canonical MenuButton |
Expand Down
5 changes: 3 additions & 2 deletions packages/components/psammead-navigation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ The `@bbc/psammead-navigation` package is a set of two components, `NavigationUl
<!-- prettier-ignore -->
| Argument | Type | Required | Default | Example |
| -------- | ---- | -------- | ------- | ------- |
| children | node | Yes | N/A | `<ScrollableNavigation dir={dir}><NavigationUl><NavigationLi url="/" script={latin} active="true">Home</NavigationLi><NavigationLi url="/sport" script={latin}>{Sport}</NavigationLi></NavigationUl><ScrollableNavigation/>` |
| dir | string | No | `'ltr'` | `'rtl'` |
| children | node | Yes | N/A | `<ScrollableNavigation dir={dir}><NavigationUl><NavigationLi url="/" script={latin} active="true">Home</NavigationLi><NavigationLi url="/sport" script={latin}>{Sport}</NavigationLi></NavigationUl><ScrollableNavigation/>` |
| dir | string | No | `'ltr'` | `'rtl'` |
| changeBackground | boolean | No | `false` | `true` |
Bopchy marked this conversation as resolved.
Show resolved Hide resolved

### NavigationUl

Expand Down
2 changes: 1 addition & 1 deletion packages/components/psammead-navigation/package-lock.json

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

2 changes: 1 addition & 1 deletion 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": "6.0.0-alpha.5",
"version": "6.0.0-alpha.6",
"description": "A navigation bar to use on index pages",
"main": "dist/index.js",
"module": "esm/index.js",
Expand Down
20 changes: 15 additions & 5 deletions packages/components/psammead-navigation/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import React from 'react';
import styled, { css } from 'styled-components';
import { shape, string, node, bool, oneOf } from 'prop-types';
import VisuallyHiddenText from '@bbc/psammead-visually-hidden-text';
import { C_WHITE, C_POSTBOX, C_GHOST } from '@bbc/psammead-styles/colours';
import {
C_WHITE,
C_POSTBOX,
C_EBON,
C_GHOST,
} from '@bbc/psammead-styles/colours';
import {
GEL_SPACING_HLF,
GEL_SPACING,
Expand Down Expand Up @@ -214,7 +219,8 @@ NavigationLi.defaultProps = {

const StyledNav = styled.nav`
position: relative;
background-color: ${C_POSTBOX};
${({ isOpen }) =>
isOpen ? `background-color: ${C_EBON};` : `background-color: ${C_POSTBOX};`}
This conversation was marked as resolved.
Show resolved Hide resolved
border-top: 0.0625rem solid ${C_WHITE};

${StyledListItem} {
Expand All @@ -226,9 +232,9 @@ const StyledNav = styled.nav`
}
`;

const Navigation = ({ children, dir }) => {
const Navigation = ({ children, dir, isOpen }) => {
return (
<StyledNav role="navigation" dir={dir}>
<StyledNav role="navigation" dir={dir} isOpen={isOpen}>
<NavWrapper>{children}</NavWrapper>
</StyledNav>
);
Expand All @@ -237,8 +243,12 @@ const Navigation = ({ children, dir }) => {
Navigation.propTypes = {
children: node.isRequired,
dir: oneOf(['ltr', 'rtl']),
isOpen: bool,
};

Navigation.defaultProps = { dir: 'ltr' };
Navigation.defaultProps = {
dir: 'ltr',
isOpen: false,
};

export default Navigation;