@comicrelief/component-library 8.45.0 → 8.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Atoms/Icons/CtaArrow.js +74 -0
- package/dist/components/Atoms/Icons/index.js +8 -1
- package/dist/components/Atoms/Link/Link.style.js +27 -21
- package/dist/components/Atoms/Link/Link.test.js +24 -1
- package/dist/components/Molecules/CardDs/__snapshots__/CardDs.test.js.snap +48 -2
- package/dist/components/Molecules/HeroBanner/HeroBanner.js +75 -31
- package/dist/components/Molecules/HeroBanner/HeroBanner.md +176 -6
- package/dist/components/Molecules/HeroBanner/HeroBanner.style.js +232 -0
- package/dist/components/Molecules/HeroBanner/HeroBanner.test.js +67 -0
- package/dist/components/Molecules/HeroBanner/__snapshots__/HeroBanner.test.js.snap +882 -0
- package/dist/components/Molecules/HeroBanner/_variants.js +12 -0
- package/dist/components/Molecules/HeroBanner/assets/Pause--black.svg +3 -0
- package/dist/components/Molecules/HeroBanner/assets/Pause--white.svg +3 -0
- package/dist/components/Molecules/HeroBanner/assets/Play--black.svg +3 -0
- package/dist/components/Molecules/HeroBanner/assets/Play--white.svg +3 -0
- package/dist/components/Molecules/HeroBanner/assets/alt_cta_underline.svg +3 -0
- package/dist/components/Molecules/HeroBanner/assets/arrow-right.svg +3 -0
- package/dist/components/Molecules/HeroBanner/assets/loader.svg +1 -0
- package/dist/components/Molecules/HeroBanner/assets/video--play-icon.svg +1 -0
- package/dist/components/Molecules/HeroBanner/assets/video--play-icon__hover.svg +1 -0
- package/dist/components/Molecules/HeroBanner/local-preview-layout-fixes.css +6 -0
- package/dist/components/Molecules/Promo/__snapshots__/Promo.test.js.snap +48 -2
- package/dist/components/Molecules/SingleMessage/__snapshots__/SingleMessage.test.js.snap +64 -2
- package/dist/components/Molecules/SingleMessageDS/__snapshots__/SingleMessageDs.test.js.snap +24 -1
- package/dist/components/Organisms/CookieBanner/CookieBanner.test.js +24 -1
- package/dist/index.js +1 -1
- package/dist/styleguide/assets/PromoLW.jpg +0 -0
- package/dist/styleguide/data/data.js +1 -0
- package/dist/theme/shared/animations.js +23 -2
- package/dist/theme/shared/global.css +1 -1
- package/package.json +1 -1
- package/src/components/Atoms/Icons/CtaArrow.js +55 -0
- package/src/components/Atoms/Icons/index.js +1 -0
- package/src/components/Atoms/Link/Link.js +1 -1
- package/src/components/Atoms/Link/Link.style.js +8 -1
- package/src/components/Atoms/Link/Link.test.js +24 -1
- package/src/components/Molecules/CardDs/__snapshots__/CardDs.test.js.snap +48 -2
- package/src/components/Molecules/HeroBanner/HeroBanner.js +145 -49
- package/src/components/Molecules/HeroBanner/HeroBanner.md +176 -6
- package/src/components/Molecules/HeroBanner/HeroBanner.style.js +239 -0
- package/src/components/Molecules/HeroBanner/HeroBanner.test.js +89 -0
- package/src/components/Molecules/HeroBanner/__snapshots__/HeroBanner.test.js.snap +882 -0
- package/src/components/Molecules/HeroBanner/_variants.js +7 -0
- package/src/components/Molecules/HeroBanner/assets/Pause--black.svg +3 -0
- package/src/components/Molecules/HeroBanner/assets/Pause--white.svg +3 -0
- package/src/components/Molecules/HeroBanner/assets/Play--black.svg +3 -0
- package/src/components/Molecules/HeroBanner/assets/Play--white.svg +3 -0
- package/src/components/Molecules/HeroBanner/assets/alt_cta_underline.svg +3 -0
- package/src/components/Molecules/HeroBanner/assets/arrow-right.svg +3 -0
- package/src/components/Molecules/HeroBanner/assets/loader.svg +1 -0
- package/src/components/Molecules/HeroBanner/assets/video--play-icon.svg +1 -0
- package/src/components/Molecules/HeroBanner/assets/video--play-icon__hover.svg +1 -0
- package/src/components/Molecules/HeroBanner/local-preview-layout-fixes.css +6 -0
- package/src/components/Molecules/Promo/__snapshots__/Promo.test.js.snap +48 -2
- package/src/components/Molecules/SingleMessage/__snapshots__/SingleMessage.test.js.snap +64 -2
- package/src/components/Molecules/SingleMessageDS/__snapshots__/SingleMessageDs.test.js.snap +24 -1
- package/src/components/Organisms/CookieBanner/CookieBanner.test.js +24 -1
- package/src/index.js +1 -1
- package/src/styleguide/assets/PromoLW.jpg +0 -0
- package/src/styleguide/data/data.js +1 -0
- package/src/theme/shared/animations.js +29 -1
- package/src/theme/shared/global.css +1 -1
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import zIndex from '../../../theme/shared/zIndex';
|
|
3
|
+
import variants from './_variants';
|
|
4
|
+
import { bounceUpAnimation } from '../../../theme/shared/animations';
|
|
5
|
+
import Text from '../../Atoms/Text/Text';
|
|
6
|
+
|
|
7
|
+
// Lil helper function to streamline things somewhat:
|
|
8
|
+
const handleVariant = variant => {
|
|
9
|
+
switch (variant) {
|
|
10
|
+
case variants.FULL_HEIGHT:
|
|
11
|
+
return `
|
|
12
|
+
height: 75vh;
|
|
13
|
+
min-height: 600px;
|
|
14
|
+
max-height: 750px;`;
|
|
15
|
+
case variants.HALF_HEIGHT:
|
|
16
|
+
return `
|
|
17
|
+
height: auto;
|
|
18
|
+
min-height: 450px;`;
|
|
19
|
+
// No tweaks needed for the remaining 'text_banner' variant:
|
|
20
|
+
default:
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const Container = styled.div`
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: auto;
|
|
28
|
+
display: flex;
|
|
29
|
+
position: relative;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
background: ${({ theme, pageBackgroundColour }) => theme.color(pageBackgroundColour)};
|
|
32
|
+
justify-content: center;
|
|
33
|
+
|
|
34
|
+
@media ${({ theme }) => theme.breakpoints2026('L')} {
|
|
35
|
+
${({ paddingTop, paddingBottom }) => css`padding: ${paddingTop} 2rem ${paddingBottom};`}
|
|
36
|
+
align-items: center;
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const OuterWrapper = styled.div`
|
|
41
|
+
width: 100%;
|
|
42
|
+
max-width: none;
|
|
43
|
+
position: relative;
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
align-items: center;
|
|
47
|
+
|
|
48
|
+
@media ${({ theme }) => theme.breakpoints2026('L')} {
|
|
49
|
+
width: 100%;
|
|
50
|
+
max-width: 1500px;
|
|
51
|
+
border-radius: 1rem;
|
|
52
|
+
overflow: hidden;
|
|
53
|
+
|
|
54
|
+
${({ variant }) => (variant && css`
|
|
55
|
+
${handleVariant(variant)}
|
|
56
|
+
`)}
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
const MediaWrapper = styled.div`
|
|
60
|
+
width: 100%;
|
|
61
|
+
height: 100%;
|
|
62
|
+
|
|
63
|
+
@media ${({ theme }) => theme.breakpoints2026('L')} {
|
|
64
|
+
position: absolute;
|
|
65
|
+
top: 0;
|
|
66
|
+
left: 0;
|
|
67
|
+
|
|
68
|
+
img {
|
|
69
|
+
object-position: top center;
|
|
70
|
+
height: 100%;
|
|
71
|
+
|
|
72
|
+
// Zoom the image in slightly by default so the 'bounce' animation doesn't cause issues
|
|
73
|
+
transform: scale(1.02);
|
|
74
|
+
transition: transform ${0.4}s cubic-bezier(0.68, ${-1.15}, 0.265, ${2.35});
|
|
75
|
+
|
|
76
|
+
${({ variant }) => (variant === variants.HALF_HEIGHT && 'min-height: 450px;')};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&:has(+ div a:hover) {
|
|
80
|
+
> div > img {
|
|
81
|
+
transform: scale(1.04);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
const CopyOuterWrapper = styled.div`
|
|
88
|
+
position: relative;
|
|
89
|
+
height: 100%;
|
|
90
|
+
left: 0;
|
|
91
|
+
right: 0;
|
|
92
|
+
display: flex;
|
|
93
|
+
width: calc(100% - (2 * 1rem));
|
|
94
|
+
|
|
95
|
+
${({ variant }) => (variant !== variants.TEXT_BANNER ? 'margin: -2rem 1rem 2rem;' : 'margin: 2rem 1rem;')}
|
|
96
|
+
|
|
97
|
+
@media ${({ theme }) => theme.breakpoints2026('M')} {
|
|
98
|
+
width: calc(100% - 4rem);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@media ${({ theme }) => theme.breakpoints2026('L')} {
|
|
102
|
+
position: relative;
|
|
103
|
+
top: auto;
|
|
104
|
+
left: auto;
|
|
105
|
+
height: 100%;
|
|
106
|
+
width: 100%;
|
|
107
|
+
${({ variant }) => (variant !== variants.TEXT_BANNER && 'max-width: 1200px;')}
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
margin: 0 auto;
|
|
111
|
+
|
|
112
|
+
justify-content: ${({ variant, copyLeft }) => {
|
|
113
|
+
if (variant === variants.TEXT_BANNER) return 'center';
|
|
114
|
+
return copyLeft ? 'flex-start' : 'flex-end';
|
|
115
|
+
}};
|
|
116
|
+
|
|
117
|
+
${({ variant }) => (variant && css`
|
|
118
|
+
${handleVariant(variant)}
|
|
119
|
+
`)}
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
|
|
123
|
+
const Copy = styled.div`
|
|
124
|
+
width: 100%;
|
|
125
|
+
${zIndex('low')};
|
|
126
|
+
border-radius: 1rem;
|
|
127
|
+
padding: ${({ variant }) => (variant === variants.TEXT_BANNER ? '3rem 1.5rem' : '1.5rem')};
|
|
128
|
+
color: ${({ theme, copyColour }) => theme.color(copyColour)};
|
|
129
|
+
|
|
130
|
+
background-color: ${({ theme, variant, textBannerCopyBackgroundColour }) => (variant === variants.TEXT_BANNER
|
|
131
|
+
? theme.color(textBannerCopyBackgroundColour)
|
|
132
|
+
: theme.color('white')
|
|
133
|
+
)};
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
${({ variant, theme }) => (variant !== variants.TEXT_BANNER && `
|
|
137
|
+
@media ${theme.breakpoints2026('L')} {
|
|
138
|
+
padding: 2rem 2rem 1.75rem;
|
|
139
|
+
}
|
|
140
|
+
`)};
|
|
141
|
+
|
|
142
|
+
${({ variant, theme }) => (variant === variants.TEXT_BANNER && `
|
|
143
|
+
text-align: center;
|
|
144
|
+
@media ${theme.breakpoints2026('M')} {
|
|
145
|
+
padding: 4rem 11%;
|
|
146
|
+
}
|
|
147
|
+
`)};
|
|
148
|
+
|
|
149
|
+
@media ${({ theme }) => theme.breakpoints2026('L')} {
|
|
150
|
+
width: ${({ variant }) => (variant !== variants.TEXT_BANNER ? '92%' : '100%')};
|
|
151
|
+
}
|
|
152
|
+
`;
|
|
153
|
+
|
|
154
|
+
const CopyInnerWrapper = styled.div`
|
|
155
|
+
width: 100%;
|
|
156
|
+
height: 100%;
|
|
157
|
+
display: flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
|
|
160
|
+
@media ${({ theme }) => theme.breakpoints2026('L')} {
|
|
161
|
+
height: auto;
|
|
162
|
+
|
|
163
|
+
${({ variant }) => (variant === variants.TEXT_BANNER ? css`width: 100%;` : css`width: 50%;`)};
|
|
164
|
+
|
|
165
|
+
${({ variant }) => (variant === variants.TEXT_BANNER ? css`margin: 0;` : css`margin: 2rem 0;`)};
|
|
166
|
+
|
|
167
|
+
justify-content: ${({ copyLeft }) => (copyLeft
|
|
168
|
+
? css` flex-end;`
|
|
169
|
+
: css` flex-start;`
|
|
170
|
+
)};
|
|
171
|
+
}
|
|
172
|
+
`;
|
|
173
|
+
|
|
174
|
+
const CTAWrapper = styled.div`
|
|
175
|
+
width: 100%;
|
|
176
|
+
height: auto;
|
|
177
|
+
position: relative;
|
|
178
|
+
padding: 0.5rem 0;
|
|
179
|
+
margin-top: 1.25rem;
|
|
180
|
+
|
|
181
|
+
${({ variant }) => (variant !== variants.TEXT_BANNER && css`
|
|
182
|
+
span {
|
|
183
|
+
font-weight: bold;
|
|
184
|
+
color: ${({ theme }) => theme.color('red')};
|
|
185
|
+
}
|
|
186
|
+
`)}
|
|
187
|
+
`;
|
|
188
|
+
|
|
189
|
+
const CtaIconWrapper = styled.div`
|
|
190
|
+
height: 2rem;
|
|
191
|
+
position: absolute;
|
|
192
|
+
top: 50%;
|
|
193
|
+
right: 0;
|
|
194
|
+
transform: translateY(-50%);
|
|
195
|
+
content: "";
|
|
196
|
+
`;
|
|
197
|
+
|
|
198
|
+
const CtaText = styled(Text)`
|
|
199
|
+
position: relative;
|
|
200
|
+
`;
|
|
201
|
+
|
|
202
|
+
const CtaTextUnderline = styled.img`
|
|
203
|
+
height: 4px;
|
|
204
|
+
width: 100%;
|
|
205
|
+
position: absolute;
|
|
206
|
+
left: 0;
|
|
207
|
+
bottom: -5px;
|
|
208
|
+
transition: opacity 0.15s 0.1s;
|
|
209
|
+
opacity: 0;
|
|
210
|
+
`;
|
|
211
|
+
|
|
212
|
+
const HeroBannerLink = styled.a`
|
|
213
|
+
text-decoration: none;
|
|
214
|
+
|
|
215
|
+
@media ${({ theme }) => theme.breakpoints2026('L')} {
|
|
216
|
+
|
|
217
|
+
${bounceUpAnimation(true, 10, 2)}
|
|
218
|
+
|
|
219
|
+
// As the link is now wrapping the content, it'll take over width duties from 'Copy':
|
|
220
|
+
width: ${({ variant }) => (variant !== variants.TEXT_BANNER ? '92%' : '100%')};
|
|
221
|
+
|
|
222
|
+
> div {
|
|
223
|
+
width: 100%;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Fade in the 'Alt CTA'-style squiggley underline:
|
|
227
|
+
&:hover {
|
|
228
|
+
img.cta-text-underline {
|
|
229
|
+
opacity: 1;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
`;
|
|
234
|
+
|
|
235
|
+
export {
|
|
236
|
+
Container, CopyOuterWrapper, Copy, MediaWrapper,
|
|
237
|
+
CopyInnerWrapper, OuterWrapper, CTAWrapper, HeroBannerLink,
|
|
238
|
+
CtaIconWrapper, CtaText, CtaTextUnderline
|
|
239
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import 'jest-styled-components';
|
|
3
|
+
import renderWithTheme from '../../../../tests/hoc/shallowWithTheme';
|
|
4
|
+
import HeroBanner from './HeroBanner';
|
|
5
|
+
import Text from '../../Atoms/Text/Text';
|
|
6
|
+
import Link from '../../Atoms/Link/Link';
|
|
7
|
+
import variants from './_variants';
|
|
8
|
+
|
|
9
|
+
const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
10
|
+
|
|
11
|
+
it('renders "Full Height Media" Hero Banner correctly', () => {
|
|
12
|
+
const tree = renderWithTheme(
|
|
13
|
+
<HeroBanner
|
|
14
|
+
pageBackgroundColour="teal_light"
|
|
15
|
+
imageSet={defaultData.heroBannerImage}
|
|
16
|
+
image={defaultData.heroBannerImage}
|
|
17
|
+
imageLow={defaultData.heroBannerImage}
|
|
18
|
+
imageAltText="Image alt text"
|
|
19
|
+
variant={variants.FULL_HEIGHT}
|
|
20
|
+
ctaText="Test CTA Label"
|
|
21
|
+
ctaLink="http://www.google.com"
|
|
22
|
+
copyLeft
|
|
23
|
+
>
|
|
24
|
+
<Text
|
|
25
|
+
tag="h1"
|
|
26
|
+
color="black"
|
|
27
|
+
>
|
|
28
|
+
Curabitur pretium tincidunt lacus
|
|
29
|
+
</Text>
|
|
30
|
+
<Text tag="p" color="black">
|
|
31
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
32
|
+
</Text>
|
|
33
|
+
</HeroBanner>
|
|
34
|
+
).toJSON();
|
|
35
|
+
|
|
36
|
+
expect(tree).toMatchSnapshot();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('renders "Half Height Media" Hero Banner correctly', () => {
|
|
40
|
+
const tree = renderWithTheme(
|
|
41
|
+
<HeroBanner
|
|
42
|
+
pageBackgroundColour="teal_light"
|
|
43
|
+
imageSet={defaultData.heroBannerImage}
|
|
44
|
+
image={defaultData.heroBannerImage}
|
|
45
|
+
imageLow={defaultData.heroBannerImage}
|
|
46
|
+
imageAltText="Image alt text"
|
|
47
|
+
variant={variants.HALF_HEIGHT}
|
|
48
|
+
ctaText="Test CTA Label"
|
|
49
|
+
ctaLink="http://www.google.com"
|
|
50
|
+
copyLeft={false}
|
|
51
|
+
>
|
|
52
|
+
<Text
|
|
53
|
+
tag="h1"
|
|
54
|
+
color="black"
|
|
55
|
+
>
|
|
56
|
+
Curabitur pretium tincidunt lacus
|
|
57
|
+
</Text>
|
|
58
|
+
<Text tag="p" color="black">
|
|
59
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
60
|
+
</Text>
|
|
61
|
+
</HeroBanner>
|
|
62
|
+
).toJSON();
|
|
63
|
+
|
|
64
|
+
expect(tree).toMatchSnapshot();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('renders "Text Banner" Hero Banner correctly', () => {
|
|
68
|
+
const tree = renderWithTheme(
|
|
69
|
+
<HeroBanner
|
|
70
|
+
pageBackgroundColour="teal_light"
|
|
71
|
+
variant={variants.TEXT_BANNER}
|
|
72
|
+
ctaText="Test CTA Label"
|
|
73
|
+
ctaLink="http://www.google.com"
|
|
74
|
+
copyLeft={false}
|
|
75
|
+
>
|
|
76
|
+
<Text
|
|
77
|
+
tag="h1"
|
|
78
|
+
color="black"
|
|
79
|
+
>
|
|
80
|
+
Curabitur pretium tincidunt lacus
|
|
81
|
+
</Text>
|
|
82
|
+
<Text tag="p" color="black">
|
|
83
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
84
|
+
</Text>
|
|
85
|
+
</HeroBanner>
|
|
86
|
+
).toJSON();
|
|
87
|
+
|
|
88
|
+
expect(tree).toMatchSnapshot();
|
|
89
|
+
});
|