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

Update psammead-navigation to require colours as props #4187

Merged
merged 23 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c7a0394
Make background colour a prop
jimjohnsonrollings Jan 6, 2021
17e0595
Correct default colour
jimjohnsonrollings Jan 6, 2021
51ecd32
Steps to take background colour from text-variants
jimjohnsonrollings Jan 6, 2021
e60f152
Merge branch 'latest' of github.com:bbc/psammead into navcolour
jimjohnsonrollings Jan 7, 2021
5a88ee7
Update test to include new prop
jimjohnsonrollings Jan 7, 2021
75112bd
Take the brandBackgroundColour from the knobs, maybe
jimjohnsonrollings Jan 7, 2021
ea25498
Merge in latest and resolve conflicts
jimjohnsonrollings Jan 7, 2021
27fff67
Merge branch 'latest' of github.com:bbc/psammead into navcolour
jimjohnsonrollings Jan 7, 2021
d4a2eb6
Fix some tests
jimjohnsonrollings Jan 7, 2021
ae76ccd
Fix conflicts and merge in latest
jimjohnsonrollings Jan 11, 2021
3066ca6
Make scrollable navigation take the correct colours and use the corre…
jimjohnsonrollings Jan 11, 2021
499735f
Makes the border colour work
jimjohnsonrollings Jan 11, 2021
7774c61
Update tests
jimjohnsonrollings Jan 11, 2021
20cd4c9
Update tests and snapshots
jimjohnsonrollings Jan 11, 2021
a8a7391
Fix storybook default colour back
jimjohnsonrollings Jan 11, 2021
4138ac9
Merge branch 'latest' of github.com:bbc/psammead into navcolour
jimjohnsonrollings Jan 11, 2021
8903ba1
Bump version to 9.0.0
jimjohnsonrollings Jan 11, 2021
97c2644
Update readme
jimjohnsonrollings Jan 12, 2021
f2beccd
Remove comment
jimjohnsonrollings Jan 13, 2021
ed5b9d5
Update hex to rgb function
jimjohnsonrollings Jan 13, 2021
0276bd9
Merge branch 'navcolour' of github.com:bbc/psammead into navcolour
jimjohnsonrollings Jan 13, 2021
a6564f7
Merge branch 'latest' into navcolour
joshcoventry Jan 14, 2021
e67592c
Merge branch 'latest' into navcolour
paruchurisilpa Jan 14, 2021
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 |
|---------|-------------|
| 9.0.0 | [PR#4187](https://github.com/bbc/psammead/pull/4187) Require colours to be passed in as props |
| 8.0.9 | [PR#4189](https://github.com/bbc/psammead/pull/4189) Talos - Bump Dependencies - @bbc/psammead-assets, @bbc/psammead-styles |
| 8.0.8 | [PR#4087](https://github.com/bbc/psammead/pull/4087) Talos - Bump Dependencies - @bbc/psammead-assets |
| 8.0.7 | [PR#4072](https://github.com/bbc/psammead/pull/4072) Talos - Bump Dependencies - @bbc/psammead-styles |
Expand Down
42 changes: 38 additions & 4 deletions packages/components/psammead-navigation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ The `@bbc/psammead-navigation` package is a set of two components, `NavigationUl
| dir | string | No | `'ltr'` | `'rtl'` |
| isOpen | boolean | No | `false` | `true` |
| ampOpenClass | string | No | `null` | `'open'` |
| brandBackgroundColour | string | Yes | N/A | `'#B80000'` |
| brandForegroundColour | string | Yes | N/A | `'#FDFDFD'` |
| brandBorderColour | string | Yes | N/A | `'#EAB3B3'` |
| brandHighlightColour | string YesNo | N/A | `'#FFFFFF'` |

### NavigationUl

Expand All @@ -43,6 +47,9 @@ The `@bbc/psammead-navigation` package is a set of two components, `NavigationUl
| currentPageText | string | No | `null` | `Current page` |
| service | string | Yes | N/A | `'news'` |
| dir | string | No | `'ltr'` | `'rtl'` |
| brandForegroundColour | string | Yes | N/A | `'#FDFDFD'` |
| brandBorderColour | string | Yes | N/A | `'#EAB3B3'` |
| brandHighlightColour | string YesNo | N/A | `'#FFFFFF'` |

### ScrollableNavigation

Expand All @@ -51,6 +58,8 @@ 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'` |
| brandBackgroundColour | string | Yes | N/A | `'#B80000'` |
| brandHighlightColour | string YesNo | N/A | `'#FFFFFF'` |

### CanonicalDropdown

Expand Down Expand Up @@ -112,22 +121,47 @@ import Navigation, {
} from '@bbc/psammead-navigation';
import { latin } from '@bbc/gel-foundations/scripts';

<Navigation>
<ScrollableNavigation>
<Navigation
brandBackgroundColour='#B80000'
brandForegroundColour='#FDFDFD'
brandBorderColour='#EAB3B3'
brandHighlightColour='#FFFFFF'
>
<ScrollableNavigation
brandBackgroundColour='#B80000'
brandHighlightColour='#FFFFFF'
>
<NavigationUl>
<NavigationLi
url="/"
script={latin}
active
currentPageText="Current Page"
service="news"
brandForegroundColour='#FDFDFD'
brandBorderColour='#EAB3B3'
brandHighlightColour='#FFFFFF'
>
Home
</NavigationLi>
<NavigationLi url="/sport" script={latin} service="news">
<NavigationLi
url="/sport"
script={latin}
service="news"
brandForegroundColour='#FDFDFD'
brandBorderColour='#EAB3B3'
brandHighlightColour='#FFFFFF'
>
{Sport}
</NavigationLi>
<NavigationLi url="/weather" script={latin} service="news">
<NavigationLi
url="/weather"
script={latin}
service="news"
brandForegroundColour='#FDFDFD'
brandBorderColour='#EAB3B3'
brandHighlightColour='#FFFFFF'
>
{Weather}
</NavigationLi>
</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": "8.0.9",
"version": "9.0.0",
"description": "A navigation bar to use on index pages",
"main": "dist/index.js",
"module": "esm/index.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import React from 'react';
import styled from '@emotion/styled';
import { node, oneOf } from 'prop-types';
import { node, oneOf, string } from 'prop-types';
import { GEL_SPACING_SEXT } from '@bbc/gel-foundations/spacings';
import {
GEL_GROUP_2_SCREEN_WIDTH_MIN,
GEL_GROUP_2_SCREEN_WIDTH_MAX,
} from '@bbc/gel-foundations/breakpoints';

/* Convert C_POSTBOX to rgba as IE doesn't like 8 digit hex */
const C_POSTBOX_TRANSPARENT = `rgba(184, 0, 0, 0)`;
const C_POSTBOX_OPAQUE = `rgba(184, 0, 0, 1)`;
// Because IE11 can't handle 8-digit hex, need to convert to rgba
const convertHexColourToDecimal = (hexColour, opacity = 1) => {
const hexChars = hexColour.split('');
const red = parseInt(hexChars[1], 16) * 16 + parseInt(hexChars[2], 16);
const green = parseInt(hexChars[3], 16) * 16 + parseInt(hexChars[4], 16);
const blue = parseInt(hexChars[5], 16) * 16 + parseInt(hexChars[6], 16);
return `rgba(${red}, ${green}, ${blue}, ${opacity})`;
};
joshcoventry marked this conversation as resolved.
Show resolved Hide resolved

const StyledScrollableNav = styled.div`
@media (max-width: ${GEL_GROUP_2_SCREEN_WIDTH_MAX}) {
Expand Down Expand Up @@ -44,22 +49,39 @@ const StyledScrollableNav = styled.div`
pointer-events: none;
background: linear-gradient(
${({ dir }) => (dir === 'ltr' ? 'to right' : 'to left')},
${C_POSTBOX_TRANSPARENT} 0%,
${C_POSTBOX_OPAQUE} 100%
andrewscfc marked this conversation as resolved.
Show resolved Hide resolved
${({ brandBackgroundColour }) =>
convertHexColourToDecimal(brandBackgroundColour, 0)}
0%,
${({ brandBackgroundColour }) =>
convertHexColourToDecimal(brandBackgroundColour, 1)}
100%
);
}
}
`;

export const ScrollableNavigation = ({ children, dir, ...props }) => (
<StyledScrollableNav dir={dir} {...props}>
export const ScrollableNavigation = ({
children,
dir,
brandBackgroundColour,
brandHighlightColour,
...props
}) => (
<StyledScrollableNav
dir={dir}
brandBackgroundColour={brandBackgroundColour}
brandHighlightColour={brandHighlightColour}
{...props}
>
{children}
</StyledScrollableNav>
);

ScrollableNavigation.propTypes = {
children: node.isRequired,
dir: oneOf(['ltr', 'rtl']),
brandBackgroundColour: string.isRequired,
brandHighlightColour: string.isRequired,
};

ScrollableNavigation.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ exports[`Navigation should render correctly 1`] = `
position: absolute;
bottom: -1px;
width: 80rem;
border-bottom: 0.0625rem solid #eab3b3;
border-bottom: 0.0625rem solid #EAB3B3;
z-index: -1;
}
}
Expand Down Expand Up @@ -303,7 +303,7 @@ exports[`Navigation should render correctly when ampOpenClass prop is provided 1
position: absolute;
bottom: -1px;
width: 80rem;
border-bottom: 0.0625rem solid #eab3b3;
border-bottom: 0.0625rem solid #EAB3B3;
z-index: -1;
}
}
Expand Down Expand Up @@ -574,7 +574,7 @@ exports[`Navigation should render correctly when isOpen is true 1`] = `
position: absolute;
bottom: -1px;
width: 80rem;
border-bottom: 0.0625rem solid #eab3b3;
border-bottom: 0.0625rem solid #EAB3B3;
z-index: -1;
}
}
Expand Down Expand Up @@ -849,7 +849,7 @@ exports[`Scrollable Navigation should render correctly 1`] = `
position: absolute;
bottom: -1px;
width: 80rem;
border-bottom: 0.0625rem solid #eab3b3;
border-bottom: 0.0625rem solid #EAB3B3;
z-index: -1;
}
}
Expand Down
Loading