Skip to content
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

feat: ENG-283 Nav update #638

Draft
wants to merge 101 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
d8ca04a
Rename styles for less confusion with other nav
AndyEPhipps Apr 9, 2024
14c171e
Remove functionality & styles re: cloning menu items
AndyEPhipps Apr 9, 2024
08dda45
Tidy-up
AndyEPhipps Apr 9, 2024
f02de1e
Lol I've done it all wrong
AndyEPhipps Apr 10, 2024
e433979
Use pre-existing data
AndyEPhipps Apr 10, 2024
dfd7f4a
Start updating styles
AndyEPhipps Apr 10, 2024
0663cf3
More hover styles
AndyEPhipps Apr 10, 2024
53c9be1
Breakpoint-dependent rendering of icons n buttons
AndyEPhipps Apr 10, 2024
de7a3fe
CSS3 animations
AndyEPhipps Apr 11, 2024
ae12782
Icon animations
AndyEPhipps Apr 11, 2024
c18969a
Target Header icons only
AndyEPhipps Apr 11, 2024
dc769c5
Ditch keyframes for lighter transitions
AndyEPhipps Apr 11, 2024
852fce1
Start on mobile specific styles
AndyEPhipps Apr 11, 2024
0ed89c9
Merge branch 'master' of https://github.com/comicrelief/component-lib…
AndyEPhipps Apr 11, 2024
7ff10dc
Fix rel property
AndyEPhipps Apr 12, 2024
3b24e7f
Clarify naming
AndyEPhipps Apr 12, 2024
c582e19
Add in cloned menu item for mobile only
AndyEPhipps Apr 12, 2024
41bfc6c
Prototype limit logic
AndyEPhipps Apr 15, 2024
9e896c0
Target logic
AndyEPhipps Apr 15, 2024
1cf645b
Unpicking logic nightmare
AndyEPhipps Apr 16, 2024
32fe731
Fix mobile nav
AndyEPhipps Apr 17, 2024
f94873f
Tidyup, bring in new markup logic
AndyEPhipps Apr 17, 2024
9423c07
Prototyping
AndyEPhipps Apr 17, 2024
29000e0
Sussed out nightmare nesting
AndyEPhipps Apr 18, 2024
b25eb61
Broken everything
AndyEPhipps Apr 18, 2024
29ad618
Merge branch 'master' of https://github.com/comicrelief/component-lib…
AndyEPhipps Apr 19, 2024
fdb9bc7
Debug
AndyEPhipps Apr 19, 2024
a004e44
Step back, but reintroduce new stuff to troubleshoot
AndyEPhipps Apr 19, 2024
dd8d9d2
Fix render logic
AndyEPhipps Apr 19, 2024
5f426d5
Towel throw-in for today:
AndyEPhipps Apr 19, 2024
3ce1f99
Process nav BEFORE render to circumnavigate state issues
AndyEPhipps Apr 22, 2024
1333ea2
Remove some now-necessary markup
AndyEPhipps Apr 22, 2024
5412098
Reupdate nonmobile nav re:firstchild
AndyEPhipps Apr 22, 2024
6ff9239
Comment through the nonsense
AndyEPhipps Apr 22, 2024
ac21ee1
Rename gibberish function
AndyEPhipps Apr 22, 2024
afc6e59
Tighten up keyevents
AndyEPhipps Apr 22, 2024
480d26c
Fix import
AndyEPhipps Apr 23, 2024
75415b2
Clearer naming, clone and extending components
AndyEPhipps Apr 23, 2024
13f154f
Tidyup
AndyEPhipps Apr 23, 2024
b2a1b0a
Fix More item markup
AndyEPhipps Apr 23, 2024
1a27839
Remove unncessary styles
AndyEPhipps Apr 23, 2024
a791312
Tidyup old markup
AndyEPhipps Apr 23, 2024
a0544c5
Handle endless mess of styles
AndyEPhipps Apr 23, 2024
cada661
Hover events
AndyEPhipps Apr 23, 2024
965923c
Merge branch 'master' of https://github.com/comicrelief/component-lib…
AndyEPhipps Apr 24, 2024
fd38d7e
Fix imports
AndyEPhipps Apr 24, 2024
6b82180
Trigger logo animation in correct place
AndyEPhipps Apr 24, 2024
49dc9c2
Animations
AndyEPhipps Apr 24, 2024
8852a58
Tidying
AndyEPhipps Apr 24, 2024
750dc4f
Update snaps
AndyEPhipps Apr 24, 2024
6c12550
Test fix 1
AndyEPhipps Apr 24, 2024
164b404
More useful data attributes
AndyEPhipps Apr 24, 2024
8fff74e
New data-attributes for tests
AndyEPhipps Apr 24, 2024
8430ba0
Improve icon data-attributes
AndyEPhipps Apr 24, 2024
c15e3f9
Test fix 2
AndyEPhipps Apr 24, 2024
f0c83e9
Fix shop selector with new markup
AndyEPhipps Apr 24, 2024
cb74dab
Test stuff
AndyEPhipps Apr 25, 2024
66e810e
Better tests
AndyEPhipps Apr 25, 2024
10e1b35
Update snaps
AndyEPhipps Apr 25, 2024
f728263
Mobile styles
AndyEPhipps Apr 25, 2024
e1b31c4
Yet more styling
AndyEPhipps Apr 26, 2024
31759b1
Fix WYMD carousel imgs
AndyEPhipps Apr 26, 2024
88e4811
Attempt to start resize stuff
AndyEPhipps Apr 26, 2024
15a2ee5
Midway thru animating opacity
AndyEPhipps Apr 29, 2024
1c71d96
Fix More dropdown
AndyEPhipps Apr 29, 2024
cd397b5
Fix mobile nav
AndyEPhipps Apr 29, 2024
910171c
Finesse animations
AndyEPhipps Apr 29, 2024
8a1b85e
Improve animation, sort out revealtext widths
AndyEPhipps Apr 29, 2024
de05490
Revealtext tweak
AndyEPhipps Apr 29, 2024
934e19a
Less full-on cR logo rotate
AndyEPhipps Apr 29, 2024
7a9b3de
Set-up header donate button animation
AndyEPhipps May 7, 2024
ad11da1
Bottom donate button too.
AndyEPhipps May 7, 2024
55d76e1
Handle keyboard focus issue
AndyEPhipps May 9, 2024
1ffdbe4
Tidyup
AndyEPhipps May 9, 2024
29728e9
Animation tweka
AndyEPhipps May 9, 2024
6feef0e
Still tryign to improve animations 🤷
AndyEPhipps May 9, 2024
9cc2d4b
cge branch 'master' of https://github.com/comicrelief/comicrelief-con…
AndyEPhipps Jun 24, 2024
c714210
Fix RevealText bug
AndyEPhipps Jun 25, 2024
1368092
BG colour inherit
AndyEPhipps Jun 25, 2024
e4484f2
Bg colour inheritance
AndyEPhipps Jun 25, 2024
8e593e0
Space fix
AndyEPhipps Jun 25, 2024
1d7e617
Change of plan
AndyEPhipps Jun 25, 2024
73d9599
Tweak Nav breakpoint to suit new design & functionality
AndyEPhipps Jun 25, 2024
22241cf
Snap update
AndyEPhipps Jun 26, 2024
fe7324d
Post-chat tweaks
AndyEPhipps Jun 26, 2024
0df457b
Tweak nav breakpoint to fit
AndyEPhipps Jun 26, 2024
ea53931
Snaps
AndyEPhipps Jun 26, 2024
f723975
Experimenting with nav scrolling
AndyEPhipps Jul 1, 2024
4afba05
Desktop fixes
AndyEPhipps Jul 1, 2024
4c094f1
Alt nav examples
AndyEPhipps Jul 1, 2024
337c676
Fix duplicated IDs
AndyEPhipps Jul 1, 2024
f57f4a6
Re-add bottom donate button now we can scroll
AndyEPhipps Jul 1, 2024
e038a91
Remove scrolling for testing
AndyEPhipps Jul 1, 2024
aeeefb8
Dropshadows
AndyEPhipps Jul 1, 2024
66ae171
Fix subsubmenu shadow bug
AndyEPhipps Jul 1, 2024
0529a86
Fix breakpoint changes
AndyEPhipps Jul 1, 2024
82a0958
Tidyup
AndyEPhipps Jul 1, 2024
35774bb
Chevron updates
AndyEPhipps Jul 1, 2024
05c2c43
Tweakz
AndyEPhipps Jul 1, 2024
3f44dce
Tweak More chevrons
AndyEPhipps Jul 2, 2024
c9bd4cb
Beef up CL style overrides
AndyEPhipps Jul 2, 2024
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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,15 @@ To publish
```
$ yarn publish:npm
```

### Testing

Install Playwright:
```
yarn playwright install
```

Run the tests
```
yarn test:e2e:local
```
22 changes: 12 additions & 10 deletions docs/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,20 @@ How to use in your styled component
`@media ${({ theme }) => theme.allBreakpoints('M')} {`

#### screen sizes:
```
import { breakpointValues } from '../../../theme/shared/allBreakpoints';
...
max-width: ${breakpointValues.M}px;
```
`import { breakpointValues } from '../../../theme/shared/allBreakpoints';`

`...`

`max-width: ${breakpointValues.M}px;`


### Usage within Component Library
```
import { breakpointValues } from '@comicrelief/component-library/src/theme/shared/allBreakpoints';
...
max-width: ${breakpointValues.M}px);
```
`import { breakpointValues } from '@comicrelief/component-library/src/theme/shared/allBreakpoints';`

`...`

`max-width: ${breakpointValues.M}px);`



## containers from containers.js
Expand Down
29 changes: 8 additions & 21 deletions playwright/components/organisms/header.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,80 +2,67 @@ const { test, expect } = require('@playwright/test');

test.describe('header component', () => {
test('Comic Relief header', async ({ page }) => {

await page.goto('/#header');

await expect(page.locator('[data-testid="Header-example-1"]')).toBeVisible();
// donate locator
await expect(page.locator('[data-testid="Header-example-1"] header[role="banner"] a[href="/donation"]')).toBeVisible();
await expect(page.locator('[data-testid="Header-example-1"] header[role="banner"] [data-testid="donate-button--desktop"] a[href="/donation"]')).toBeVisible();
// CR logo
await expect(page.locator('[data-testid="Header-example-1"] [title="Go to Comic Relief homepage"]')).toBeVisible();
// shop
await expect(page.locator('[data-testid="Header-example-1"] header[role="banner"] a[href*="/shop"]')).toBeVisible();

await page.close();
});

test('Sport Relief header', async ({ page }) => {

await page.goto('/#header');

await expect(page.locator('[data-testid="Header-example-3"]')).toBeVisible();
// donate locator
await expect(page.locator('[data-testid="Header-example-3"] header[role="banner"] a[href="/donation"]')).toBeVisible();
await expect(page.locator('[data-testid="Header-example-3"] header[role="banner"] [data-testid="donate-button--desktop"] a[href="/donation"]')).toBeVisible();
// SR logo
await expect(page.locator('[data-testid="Header-example-3"] header[role="banner"] a[href="/sportrelief"]')).toBeVisible();
// shop
await expect(page.locator('[data-testid="Header-example-3"] header[role="banner"] a[href*="/shop"]')).toBeVisible();

await page.close();
});

test('Pride header', async ({ page }) => {

await page.goto('/#header');

await expect(page.locator('[data-testid="Header-example-5"]')).toBeVisible();
// donate locator
await expect(page.locator('[data-testid="Header-example-5"] header[role="banner"] a[href="/donation"]')).toBeVisible();
await expect(page.locator('[data-testid="Header-example-5"] header[role="banner"] [data-testid="donate-button--desktop"] a[href="/donation"]')).toBeVisible();
// CR logo
await expect(page.locator('[data-testid="Header-example-5"] [title="Go to Comic Relief homepage"]')).toBeVisible();
// shop
await expect(page.locator('[data-testid="Header-example-5"] header[role="banner"] a[href*="/shop"]')).toBeVisible();

await page.close();
});

test('Comic Relief header with Search', async ({ page }) => {

await page.goto('/#header');

await expect(page.locator('[data-testid="Header-example-7"]')).toBeVisible();
// donate locator
await expect(page.locator('[data-testid="Header-example-7"] header[role="banner"] a[href="/donation"]')).toBeVisible();
await expect(page.locator('[data-testid="Header-example-7"] header[role="banner"] [data-testid="donate-button--desktop"] a[href="/donation"]')).toBeVisible();
// CR logo
await expect(page.locator('[data-testid="Header-example-7"] [title="Go to Comic Relief homepage"]')).toBeVisible();
// shop
await expect(page.locator('[data-testid="Header-example-7"] header[role="banner"] a[href*="/shop"]')).toBeVisible();
// search
await expect(page.locator('[data-testid="Header-example-7"] header[role="banner"] a[href="/search"]')).toBeVisible();
await expect(page.locator('[data-testid="Header-example-7"] header[role="banner"] [data-testid="meta-icons--desktop"] a[data-testid="header-search"]')).toBeVisible();

await page.close();
});

test('Comic Relief header with Search and Shop', async ({ page }) => {

await page.goto('/#header');

await expect(page.locator('[data-testid="Header-example-9"]')).toBeVisible();
// donate locator
await expect(page.locator('[data-testid="Header-example-9"] header[role="banner"] a[href="/donation"]')).toBeVisible();
await expect(page.locator('[data-testid="Header-example-9"] header[role="banner"] [data-testid="donate-button--desktop"] a[href="/donation"]')).toBeVisible();
// CR logo
await expect(page.locator('[data-testid="Header-example-9"] [title="Go to Comic Relief homepage"]')).toBeVisible();
// shop icon
await expect(page.locator('[data-testid="Header-example-9"] header[role="banner"] [title="Shop"]')).toBeVisible();
await expect(page.locator('[data-testid="Header-example-9"] header[role="banner"] [data-testid="meta-icons--desktop"] [title="Shop"]')).toBeVisible();
// search
await expect(page.locator('[data-testid="Header-example-9"] header[role="banner"] a[href="/search"]')).toBeVisible();
await expect(page.locator('[data-testid="Header-example-9"] header[role="banner"] [data-testid="meta-icons--desktop"] a[data-testid="header-search"]')).toBeVisible();

await page.close();
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/Atoms/Logo/Logo.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ Logo.propTypes = {

Logo.defaultProps = {
rotate: false,
sizeSm: '51px', // - to work with the header 75px height and 12px padding
sizeMd: '70px',
sizeSm: '51px',
sizeMd: '51px',
campaign: 'Comic Relief'
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/Atoms/Logo/Logo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ it("renders correctly", () => {
vertical-align: bottom;
}

@media (min-width:1150px) {
@media (min-width:1175px) {
.c0 {
width: 70px;
width: 51px;
}
}

Expand Down
86 changes: 77 additions & 9 deletions src/components/Atoms/SocialIcons/Icon/Icon.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,73 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import styled, { css } from 'styled-components';
import { kebabCase } from 'lodash';
import hideVisually from '../../../../theme/shared/hideVisually';
import Text from '../../Text/Text';

const RevealTextWidth = 58;
const RevealTextSpeed = 0.35;

const StyledLink = styled.a`
text-decoration: none;
cursor: pointer;
display: block;
transition: opacity 0.2s;
position: relative;

${({ isHeader }) => isHeader && css`
overflow: hidden;
padding-right: 0px;
transition: padding-right ${RevealTextSpeed}s cubic-bezier(0.5, 1.5, 0.5, 0.75);

&:hover,
&:focus {
img {
filter: invert(0.5) sepia(1) saturate(100) hue-rotate(20deg);
}
}

@media ${({ theme }) => theme.allBreakpoints('NavWithAnimations')} {
&:hover,
&:focus {
// Default
padding-right: ${RevealTextWidth}px;

// Tweak for ESU's longer text:
&[data-testid="header-esu"] {
padding-right: 95px;
}

// Tweak for Shop 's shorter text:
&[data-testid="header-shop"] {
padding-right: 52px;
}

// Show the Reveal text
img + span {
display: block;
}
}
`}
};
`;

const RevealText = styled(Text)`
width: auto;
color: ${({ theme }) => theme.color('black')};
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 70px;

&:hover,
&:focus {
opacity: 0.6;
@media ${({ theme }) => theme.allBreakpoints('Nav')} {
width: 100%;
text-align: center;
position: absolute;
top: 8px;
left: 15px;
transform: translateX(0);
display: none;
color: ${({ theme }) => theme.color('red')};
}
`;

Expand All @@ -24,29 +80,41 @@ const HelperText = styled.span`
`;

const Icon = ({
href, target, icon, brand, title, ...restProps
href, target, icon, brand, title, isHeader, id, ...restProps
}) => (
<StyledLink
href={href}
target={`_${target}`}
{...restProps}
title={title}
rel="noopener noreferrer"
data-test="header-esu-icon"
data-testid={`${isHeader ? 'header' : 'icon'}-${kebabCase(id)}`}
isHeader={isHeader}
>
<StyledImage src={icon} alt={brand} />
{title !== 'Sign up for emails' && (

{ isHeader && (
<RevealText>{title}</RevealText>
)}

{id === 'esu' && (
<HelperText>(opens in new window)</HelperText>
)}
</StyledLink>
);

Icon.defaultProps = {
isHeader: false
};

Icon.propTypes = {
brand: PropTypes.string.isRequired,
href: PropTypes.string.isRequired,
target: PropTypes.string.isRequired,
icon: PropTypes.string.isRequired,
title: PropTypes.string.isRequired
title: PropTypes.string.isRequired,
isHeader: PropTypes.bool,
id: PropTypes.string.isRequired
};

export default Icon;
1 change: 1 addition & 0 deletions src/components/Atoms/SocialIcons/SocialIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const SocialIcons = ({ campaign, ...restProps }) => {
href={links[brand].url}
title={links[brand].title}
brand={brand}
id={links[brand].id}
{...restProps}
/>
</StyledItem>
Expand Down
12 changes: 8 additions & 4 deletions src/components/Atoms/SocialIcons/Utils/Links.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@
export default campaign => ({
facebook: {
url: `https://www.facebook.com/${campaign}`,
title: 'Check out our Facebook page'
title: 'Check out our Facebook page',
id: 'facebook'
},
twitter: {
url: `https://twitter.com/${campaign}`,
title: 'Check out our Twitter account'
title: 'Check out our Twitter account',
id: 'twitter'
},
youtube: {
url: 'https://www.youtube.com/channel/UCdF5u0ggeSETozc8fsprjcw',
title: 'Check out our YouTube channel'
title: 'Check out our YouTube channel',
id: 'youtube'
},
instagram: {
url: `https://www.instagram.com/${campaign}`,
title: 'Check out our Instagram account'
title: 'Check out our Instagram account',
id: 'instagram'
}
});
Loading
Loading