@comicrelief/component-library 7.35.10 → 7.37.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.
Files changed (37) hide show
  1. package/dist/components/Atoms/Icons/Arrow.js +25 -4
  2. package/dist/components/Atoms/Icons/AtSign.js +32 -6
  3. package/dist/components/Atoms/Icons/Chevron.js +25 -3
  4. package/dist/components/Atoms/Icons/Download.js +31 -4
  5. package/dist/components/Atoms/Icons/External.js +31 -4
  6. package/dist/components/Atoms/Icons/Favourite.js +31 -4
  7. package/dist/components/Atoms/Icons/Internal.js +31 -4
  8. package/dist/components/Atoms/Link/Link.js +3 -0
  9. package/dist/components/Atoms/Link/Link.md +23 -21
  10. package/dist/components/Atoms/Link/Link.style.js +30 -13
  11. package/dist/components/Atoms/Link/Link.test.js +6 -6
  12. package/dist/components/Molecules/Accordion/__snapshots__/Accordion.test.js.snap +7 -0
  13. package/dist/components/Molecules/CardDs/__snapshots__/CardDs.test.js.snap +23 -0
  14. package/dist/components/Molecules/Promo/__snapshots__/Promo.test.js.snap +24 -0
  15. package/dist/components/Molecules/SingleMessage/__snapshots__/SingleMessage.test.js.snap +32 -0
  16. package/dist/components/Molecules/SingleMessageDS/__snapshots__/SingleMessageDs.test.js.snap +23 -0
  17. package/dist/components/Organisms/CookieBanner/CookieBanner.test.js +4 -4
  18. package/dist/theme/crTheme/buttonColors.js +1 -1
  19. package/package.json +1 -1
  20. package/src/components/Atoms/Icons/Arrow.js +13 -2
  21. package/src/components/Atoms/Icons/AtSign.js +20 -7
  22. package/src/components/Atoms/Icons/Chevron.js +13 -1
  23. package/src/components/Atoms/Icons/Download.js +18 -4
  24. package/src/components/Atoms/Icons/External.js +18 -4
  25. package/src/components/Atoms/Icons/Favourite.js +18 -4
  26. package/src/components/Atoms/Icons/Internal.js +18 -4
  27. package/src/components/Atoms/Link/Link.js +4 -0
  28. package/src/components/Atoms/Link/Link.md +23 -21
  29. package/src/components/Atoms/Link/Link.style.js +9 -0
  30. package/src/components/Atoms/Link/Link.test.js +32 -9
  31. package/src/components/Molecules/Accordion/__snapshots__/Accordion.test.js.snap +7 -0
  32. package/src/components/Molecules/CardDs/__snapshots__/CardDs.test.js.snap +23 -0
  33. package/src/components/Molecules/Promo/__snapshots__/Promo.test.js.snap +24 -0
  34. package/src/components/Molecules/SingleMessage/__snapshots__/SingleMessage.test.js.snap +32 -0
  35. package/src/components/Molecules/SingleMessageDS/__snapshots__/SingleMessageDs.test.js.snap +23 -0
  36. package/src/components/Organisms/CookieBanner/CookieBanner.test.js +21 -9
  37. package/src/theme/crTheme/buttonColors.js +1 -1
@@ -1,30 +1,44 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { withTheme } from 'styled-components';
3
+ import styled, { withTheme } from 'styled-components';
4
+
5
+ const StyledSVG = styled.svg`
6
+ // Mobile-colour if available, else use standard prop
7
+ fill: ${({ mobileColour, colour, theme }) => (mobileColour ? theme.color(mobileColour) : theme.color(colour))};
8
+
9
+ // Reinstate standard styles for 'desktop', adding a fallback for good measure:
10
+ @media ${({ theme }) => theme.breakpoint('medium')} {
11
+ fill: ${({ colour, theme }) => (colour ? theme.color(colour) : theme.color('white'))};
12
+ }
13
+ `;
4
14
 
5
15
  const Internal = ({
6
- colour, theme, size, ...rest
16
+ colour, mobileColour, theme, size, ...rest
7
17
  }) => (
8
- <svg
18
+ <StyledSVG
9
19
  {...rest}
10
20
  width={size}
11
21
  height={size}
12
22
  fill={theme.color(colour)}
23
+ colour={colour}
24
+ mobileColour={mobileColour}
13
25
  xmlns="http://www.w3.org/2000/svg"
14
26
  viewBox="0 0 96 96"
15
27
  >
16
28
  <path d="M90.871 50.776c-.016.016-.026.036-.043.052l-32 32C58.047 83.609 57.024 84 56 84s-2.047-.391-2.829-1.171a4 4 0 010-5.657L78.343 52H8a4 4 0 010-8h70.343L53.171 18.829a4 4 0 015.657-5.657l32 32c.016.016.027.036.043.052.167.172.321.357.455.557.069.104.118.216.176.325.065.121.138.236.191.364.057.137.09.279.13.42.032.109.074.214.097.327a4.017 4.017 0 010 1.568c-.023.113-.065.217-.097.327-.041.141-.074.283-.13.42-.053.128-.126.243-.191.364-.059.109-.107.221-.176.325a4.035 4.035 0 01-.455.555z" />
17
- </svg>
29
+ </StyledSVG>
18
30
  );
19
31
 
20
32
  Internal.propTypes = {
21
33
  colour: PropTypes.string,
34
+ mobileColour: PropTypes.string,
22
35
  size: PropTypes.number,
23
36
  theme: PropTypes.objectOf(PropTypes.shape).isRequired
24
37
  };
25
38
 
26
39
  Internal.defaultProps = {
27
40
  colour: 'white',
41
+ mobileColour: null,
28
42
  size: 24
29
43
  };
30
44
 
@@ -10,6 +10,7 @@ let window = '';
10
10
  const Link = ({
11
11
  children,
12
12
  color,
13
+ mobileColour,
13
14
  href,
14
15
  target,
15
16
  type,
@@ -54,6 +55,7 @@ const Link = ({
54
55
  <StyledLink
55
56
  {...rest}
56
57
  color={color}
58
+ mobileColour={mobileColour}
57
59
  href={href}
58
60
  target={window}
59
61
  type={type}
@@ -72,6 +74,7 @@ Link.propTypes = {
72
74
  type: PropTypes.oneOf(['button', 'standard', 'standard_white']),
73
75
  /** Color for button style link. See buttonColors in theme */
74
76
  color: PropTypes.string,
77
+ mobileColour: PropTypes.string,
75
78
  /** Link target */
76
79
  target: PropTypes.string,
77
80
  /** Set to true if link rel attribute should be home */
@@ -89,6 +92,7 @@ Link.propTypes = {
89
92
  Link.defaultProps = {
90
93
  type: 'standard',
91
94
  color: 'red',
95
+ mobileColour: null,
92
96
  target: null,
93
97
  home: false,
94
98
  underline: true,
@@ -40,24 +40,26 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
40
40
  <div style={{ display: 'block', marginBottom: '10px' }}>
41
41
  <Link
42
42
  color="red"
43
+ mobileColour="blue"
43
44
  href="#anchor"
44
45
  target="blank"
45
46
  type="button"
46
- icon={<Internal colour="white" />}
47
+ icon={<Internal colour="white" mobileColour="red"/>}
47
48
  >
48
- Internal link
49
+ Internal link, 'blue' with red icon on tablet and mobile
49
50
  </Link>
50
51
  </div>
51
52
 
52
53
  <div style={{ display: 'block', marginBottom: '10px' }}>
53
54
  <Link
54
- color="red"
55
+ color="blue"
56
+ mobileColour="black"
55
57
  href="#anchor"
56
58
  target="blank"
57
59
  type="button"
58
- icon={<External colour="white" />}
60
+ icon={<External colour="white" mobileColour="blue" />}
59
61
  >
60
- External link
62
+ External link (black on mobile, blue on desktop)
61
63
  </Link>
62
64
  </div>
63
65
 
@@ -67,9 +69,9 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
67
69
  href="#anchor"
68
70
  target="blank"
69
71
  type="button"
70
- icon={<Download colour="white" />}
72
+ icon={<Download colour="white" mobileColour="blue" />}
71
73
  >
72
- Download link
74
+ Download link (blue mobile-tablet icon, white desktop icon)
73
75
  </Link>
74
76
  </div>
75
77
 
@@ -79,9 +81,9 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
79
81
  href="#anchor"
80
82
  target="blank"
81
83
  type="button"
82
- icon={<Favourite colour="white" />}
84
+ icon={<Favourite colour="white" mobileColour="blue" />}
83
85
  >
84
- Favourite link
86
+ Favourite link (blue mobile-tablet icon, white desktop icon)
85
87
  </Link>
86
88
  </div>
87
89
 
@@ -91,9 +93,9 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
91
93
  href="#anchor"
92
94
  target="blank"
93
95
  type="button"
94
- icon={<Chevron direction="up" colour="white" />}
96
+ icon={<Chevron direction="up" colour="white" mobileColour="blue" />}
95
97
  >
96
- Chevron Up
98
+ Chevron Up (blue mobile-tablet icon, white desktop icon)
97
99
  </Link>
98
100
  </div>
99
101
 
@@ -103,9 +105,9 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
103
105
  href="#anchor"
104
106
  target="blank"
105
107
  type="button"
106
- icon={<Chevron direction="down" colour="white" />}
108
+ icon={<Chevron direction="down" colour="white" mobileColour="blue" />}
107
109
  >
108
- Chevron Down
110
+ Chevron Down (blue mobile-tablet icon, white desktop icon)
109
111
  </Link>
110
112
  </div>
111
113
 
@@ -115,9 +117,9 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
115
117
  href="#anchor"
116
118
  target="blank"
117
119
  type="button"
118
- icon={<Chevron direction="left" colour="white" />}
120
+ icon={<Chevron direction="left" colour="white" mobileColour="blue" />}
119
121
  >
120
- Chevron Left
122
+ Chevron Left (blue mobile-tablet icon, white desktop icon)
121
123
  </Link>
122
124
  </div>
123
125
 
@@ -127,9 +129,9 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
127
129
  href="#anchor"
128
130
  target="blank"
129
131
  type="button"
130
- icon={<Chevron direction="right" colour="white" />}
132
+ icon={<Chevron direction="right" colour="white" mobileColour="blue" />}
131
133
  >
132
- Chevron Right
134
+ Chevron Right (blue mobile-tablet icon, white desktop icon)
133
135
  </Link>
134
136
  </div>
135
137
 
@@ -140,9 +142,9 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
140
142
  target="blank"
141
143
  type="button"
142
144
  iconFirst
143
- icon={<Arrow direction="left" colour="white" />}
145
+ icon={<Arrow direction="left" colour="white" mobileColour="blue" />}
144
146
  >
145
- Arrow Left
147
+ Arrow Left (blue mobile-tablet icon, white desktop icon)
146
148
  </Link>
147
149
  </div>
148
150
 
@@ -152,9 +154,9 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
152
154
  href="#anchor"
153
155
  target="blank"
154
156
  type="button"
155
- icon={<AtSign />}
157
+ icon={<AtSign colour="white" mobileColour="blue" />}
156
158
  >
157
- At Sign
159
+ At Sign (blue mobile-tablet icon, white desktop icon)
158
160
  </Link>
159
161
  </div>
160
162
  </div>;
@@ -17,9 +17,18 @@ const buttonStyle = () => css`
17
17
  align-items: center;
18
18
  cursor: pointer;
19
19
  ${({ color, theme }) => (color ? theme.buttonColors(color) : theme.buttonColors('red'))};
20
+
21
+ // Override with mobile-specific colours where available:
22
+ ${({ mobileColour, theme }) => (mobileColour ? theme.buttonColors(mobileColour) : null)};
23
+
20
24
  @media ${({ theme }) => theme.breakpoint('small')} {
21
25
  width: auto;
22
26
  }
27
+
28
+ // Reinstate general styles for 'desktop':
29
+ @media ${({ theme }) => theme.breakpoint('medium')} {
30
+ ${({ color, theme }) => (color ? theme.buttonColors(color) : theme.buttonColors('red'))};
31
+ }
23
32
  `;
24
33
 
25
34
  const linkStyle = () => css`
@@ -1,10 +1,10 @@
1
- import React from 'react';
2
- import 'jest-styled-components';
3
- import renderWithTheme from '../../../hoc/shallowWithTheme';
4
- import Link from './Link';
5
- import { Internal } from '../Icons/index';
1
+ import React from "react";
2
+ import "jest-styled-components";
3
+ import renderWithTheme from "../../../hoc/shallowWithTheme";
4
+ import Link from "./Link";
5
+ import { Internal } from "../Icons/index";
6
6
 
7
- it('renders a standard styled link correctly', () => {
7
+ it("renders a standard styled link correctly", () => {
8
8
  const tree = renderWithTheme(
9
9
  <Link href="/test" type="standard">
10
10
  A standard link
@@ -40,7 +40,7 @@ it('renders a standard styled link correctly', () => {
40
40
  `);
41
41
  });
42
42
 
43
- it('renders a button with an icon', () => {
43
+ it("renders a button with an icon", () => {
44
44
  const tree = renderWithTheme(
45
45
  <Link
46
46
  href="/test"
@@ -85,6 +85,10 @@ it('renders a button with an icon', () => {
85
85
  border-bottom: 2px solid #000000;
86
86
  }
87
87
 
88
+ .c2 {
89
+ fill: #FFFFFF;
90
+ }
91
+
88
92
  @media (min-width:740px) {
89
93
  .c1 {
90
94
  width: auto;
@@ -97,6 +101,12 @@ it('renders a button with an icon', () => {
97
101
  }
98
102
  }
99
103
 
104
+ @media (min-width:1024px) {
105
+ .c2 {
106
+ fill: #FFFFFF;
107
+ }
108
+ }
109
+
100
110
  <a
101
111
  className="c0"
102
112
  color="red"
@@ -110,6 +120,7 @@ it('renders a button with an icon', () => {
110
120
  type="standard"
111
121
  >
112
122
  <svg
123
+ className="c2"
113
124
  fill="#FFFFFF"
114
125
  height={24}
115
126
  viewBox="0 0 96 96"
@@ -125,7 +136,7 @@ it('renders a button with an icon', () => {
125
136
  `);
126
137
  });
127
138
 
128
- it('renders a standard styled link correctly with target blank and assistive text', () => {
139
+ it("renders a standard styled link correctly with target blank and assistive text", () => {
129
140
  const tree = renderWithTheme(
130
141
  <Link href="/test" type="standard" target="blank">
131
142
  A standard link
@@ -181,7 +192,7 @@ it('renders a standard styled link correctly with target blank and assistive tex
181
192
  `);
182
193
  });
183
194
 
184
- it('renders link styled as button correctly', () => {
195
+ it("renders link styled as button correctly", () => {
185
196
  const tree = renderWithTheme(
186
197
  <Link href="/test" type="button" color="yellow">
187
198
  A yellow button
@@ -229,6 +240,18 @@ it('renders link styled as button correctly', () => {
229
240
  }
230
241
  }
231
242
 
243
+ @media (min-width:1024px) {
244
+ .c0 {
245
+ background-color: #FFE400;
246
+ color: #000000;
247
+ }
248
+
249
+ .c0:hover {
250
+ background-color: #FEFD5A;
251
+ color: #000000;
252
+ }
253
+ }
254
+
232
255
  <a
233
256
  className="c0"
234
257
  color="yellow"
@@ -20,6 +20,7 @@ exports[`renders correctly 1`] = `
20
20
  -webkit-transform: rotate(180deg);
21
21
  -ms-transform: rotate(180deg);
22
22
  transform: rotate(180deg);
23
+ fill: #000000;
23
24
  }
24
25
 
25
26
  .c0 {
@@ -88,6 +89,12 @@ exports[`renders correctly 1`] = `
88
89
  padding: 0 2rem;
89
90
  }
90
91
 
92
+ @media (min-width:1024px) {
93
+ .c4 {
94
+ fill: #000000;
95
+ }
96
+ }
97
+
91
98
  @media (min-width:740px) {
92
99
  .c1 {
93
100
  padding: 2rem 3rem;
@@ -115,6 +115,10 @@ exports[`renders correctly 1`] = `
115
115
  z-index: 2;
116
116
  }
117
117
 
118
+ .c9 {
119
+ fill: #FFFFFF;
120
+ }
121
+
118
122
  @media (min-width:740px) {
119
123
  .c8 {
120
124
  width: auto;
@@ -129,6 +133,18 @@ exports[`renders correctly 1`] = `
129
133
  }
130
134
  }
131
135
 
136
+ @media (min-width:1024px) {
137
+ .c7 {
138
+ background-color: #E52630;
139
+ color: #FFFFFF;
140
+ }
141
+
142
+ .c7:hover {
143
+ background-color: #890B11;
144
+ color: #FFFFFF;
145
+ }
146
+ }
147
+
132
148
  @media (min-width:740px) {
133
149
  .c0 {
134
150
  -webkit-flex-direction: row;
@@ -189,6 +205,12 @@ exports[`renders correctly 1`] = `
189
205
  }
190
206
  }
191
207
 
208
+ @media (min-width:1024px) {
209
+ .c9 {
210
+ fill: #FFFFFF;
211
+ }
212
+ }
213
+
192
214
  <div
193
215
  className="c0"
194
216
  >
@@ -246,6 +268,7 @@ exports[`renders correctly 1`] = `
246
268
  type="button"
247
269
  >
248
270
  <svg
271
+ className="c9"
249
272
  fill="#FFFFFF"
250
273
  height={24}
251
274
  viewBox="0 0 96 96"
@@ -159,6 +159,18 @@ exports[`renders Promo correctly 1`] = `
159
159
  }
160
160
  }
161
161
 
162
+ @media (min-width:1024px) {
163
+ .c9 {
164
+ background-color: #FFFFFF;
165
+ color: #000000;
166
+ }
167
+
168
+ .c9:hover {
169
+ background-color: #969598;
170
+ color: #000000;
171
+ }
172
+ }
173
+
162
174
  @media (min-width:1024px) {
163
175
  .c0 {
164
176
  -webkit-flex-direction: row;
@@ -425,6 +437,18 @@ exports[`renders Promo correctly end position 1`] = `
425
437
  }
426
438
  }
427
439
 
440
+ @media (min-width:1024px) {
441
+ .c9 {
442
+ background-color: #FFFFFF;
443
+ color: #000000;
444
+ }
445
+
446
+ .c9:hover {
447
+ background-color: #969598;
448
+ color: #000000;
449
+ }
450
+ }
451
+
428
452
  @media (min-width:1024px) {
429
453
  .c0 {
430
454
  -webkit-flex-direction: row;
@@ -284,6 +284,18 @@ exports[`renders Single Message with Image correctly 1`] = `
284
284
  }
285
285
  }
286
286
 
287
+ @media (min-width:1024px) {
288
+ .c8 {
289
+ background-color: #FFFFFF;
290
+ color: #000000;
291
+ }
292
+
293
+ .c8:hover {
294
+ background-color: #969598;
295
+ color: #000000;
296
+ }
297
+ }
298
+
287
299
  @media (min-width:740px) {
288
300
  .c0 {
289
301
  -webkit-flex-direction: row;
@@ -730,6 +742,18 @@ exports[`renders Single Message with full width correctly 1`] = `
730
742
  }
731
743
  }
732
744
 
745
+ @media (min-width:1024px) {
746
+ .c8 {
747
+ background-color: #FFFFFF;
748
+ color: #000000;
749
+ }
750
+
751
+ .c8:hover {
752
+ background-color: #969598;
753
+ color: #000000;
754
+ }
755
+ }
756
+
733
757
  @media (min-width:740px) {
734
758
  .c0 {
735
759
  -webkit-flex-direction: row;
@@ -920,6 +944,10 @@ exports[`renders Single Message with full width image and no text correctly 1`]
920
944
 
921
945
  }
922
946
 
947
+ @media (min-width:1024px) {
948
+
949
+ }
950
+
923
951
  @media (min-width:740px) {
924
952
  .c0 {
925
953
  -webkit-flex-direction: row;
@@ -1042,6 +1070,10 @@ exports[`renders Single Message with no Image correctly 1`] = `
1042
1070
 
1043
1071
  }
1044
1072
 
1073
+ @media (min-width:1024px) {
1074
+
1075
+ }
1076
+
1045
1077
  @media (min-width:740px) {
1046
1078
  .c0 {
1047
1079
  -webkit-flex-direction: row;
@@ -79,6 +79,10 @@ exports[`renders correctly 1`] = `
79
79
  color: #FFFFFF;
80
80
  }
81
81
 
82
+ .c13 {
83
+ fill: #FFFFFF;
84
+ }
85
+
82
86
  .c0 {
83
87
  display: -webkit-box;
84
88
  display: -webkit-flex;
@@ -163,6 +167,24 @@ exports[`renders correctly 1`] = `
163
167
  }
164
168
  }
165
169
 
170
+ @media (min-width:1024px) {
171
+ .c11 {
172
+ background-color: #2042AD;
173
+ color: #FFFFFF;
174
+ }
175
+
176
+ .c11:hover {
177
+ background-color: #274084;
178
+ color: #FFFFFF;
179
+ }
180
+ }
181
+
182
+ @media (min-width:1024px) {
183
+ .c13 {
184
+ fill: #FFFFFF;
185
+ }
186
+ }
187
+
166
188
  @media (min-width:740px) {
167
189
  .c0 {
168
190
  -webkit-flex-direction: row;
@@ -298,6 +320,7 @@ exports[`renders correctly 1`] = `
298
320
  type="button"
299
321
  >
300
322
  <svg
323
+ className="c13"
301
324
  fill="#FFFFFF"
302
325
  height={24}
303
326
  viewBox="0 0 96 96"
@@ -1,18 +1,18 @@
1
- import React from 'react';
2
- import 'jest-styled-components';
3
- import renderWithTheme from '../../../hoc/shallowWithTheme';
4
- import CookieBanner from './CookieBanner';
1
+ import React from "react";
2
+ import "jest-styled-components";
3
+ import renderWithTheme from "../../../hoc/shallowWithTheme";
4
+ import CookieBanner from "./CookieBanner";
5
5
 
6
- it('renders correctly', () => {
6
+ it("renders correctly", () => {
7
7
  const tree = renderWithTheme(
8
8
  <CookieBanner
9
- acceptCookie={e => {
9
+ acceptCookie={(e) => {
10
10
  e.preventDefault();
11
- return 'User accept';
11
+ return "User accept";
12
12
  }}
13
- denyCookie={e => {
13
+ denyCookie={(e) => {
14
14
  e.preventDefault();
15
- return 'User does not accept cookies';
15
+ return "User does not accept cookies";
16
16
  }}
17
17
  cookiePolicyUrl="https://www.comicrelief.com/cookies-policy"
18
18
  />
@@ -119,6 +119,18 @@ it('renders correctly', () => {
119
119
  }
120
120
  }
121
121
 
122
+ @media (min-width:1024px) {
123
+ .c5 {
124
+ background-color: #FFFFFF;
125
+ color: #000000;
126
+ }
127
+
128
+ .c5:hover {
129
+ background-color: #969598;
130
+ color: #000000;
131
+ }
132
+ }
133
+
122
134
  @media (min-width:740px) {
123
135
  .c2 {
124
136
  width: 75%;
@@ -3,7 +3,7 @@ import color from './colors';
3
3
 
4
4
  const buttonColors = {
5
5
  black: {
6
- background: color('grey_dark'),
6
+ background: color('black'),
7
7
  color: color('white'),
8
8
  hoverBackground: color('grey'),
9
9
  hoverColor: color('white')