@comicrelief/component-library 8.87.1 → 8.89.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 (27) hide show
  1. package/dist/index.cjs.js +1000 -790
  2. package/dist/index.es.js +8091 -7623
  3. package/package.json +1 -1
  4. package/src/components/Atoms/Button/ButtonExample.jsx +3 -3
  5. package/src/components/Atoms/Icons/CrossRoundedCorners.js +43 -0
  6. package/src/components/Atoms/Icons/GiftAidLogo.js +37 -0
  7. package/src/components/Atoms/Icons/IconsExample.jsx +4 -1
  8. package/src/components/Atoms/Icons/Padlock.js +42 -0
  9. package/src/components/Atoms/Icons/index.js +2 -0
  10. package/src/components/Atoms/Link/Link.js +7 -2
  11. package/src/components/Atoms/Link/Link.style.js +54 -1
  12. package/src/components/Atoms/Link/Link.test.js +5 -1
  13. package/src/components/Atoms/Link/LinkExample.jsx +38 -11
  14. package/src/components/Molecules/CardDs/__snapshots__/CardDs.test.js.snap +52 -14
  15. package/src/components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAid.js +103 -0
  16. package/src/components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAid.test.js +38 -0
  17. package/src/components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAidExample.jsx +46 -0
  18. package/src/components/Molecules/PopUp/PopUpGiftAid/__snapshots__/PopUpGiftAid.test.js.snap +168 -0
  19. package/src/components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePayment.js +102 -0
  20. package/src/components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePayment.test.js +38 -0
  21. package/src/components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePaymentExample.jsx +46 -0
  22. package/src/components/Molecules/PopUp/PopUpSecurePayment/__snapshots__/PopUpSecurePayment.test.js.snap +204 -0
  23. package/src/components/Molecules/PopUp/PopUpShared.style.js +144 -0
  24. package/src/components/Molecules/PopUp/PopUpShared.utils.js +67 -0
  25. package/src/components/Molecules/SingleMessageDS/__snapshots__/SingleMessageDs.test.js.snap +26 -7
  26. package/src/demos/index.jsx +6 -0
  27. package/src/index.js +2 -0
@@ -0,0 +1,204 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`renders coral_light variant 1`] = `
4
+ .c4 {
5
+ font-family: 'Montserrat',Helvetica,Arial,sans-serif;
6
+ font-weight: 400;
7
+ text-transform: inherit;
8
+ letter-spacing: 0;
9
+ font-size: 1rem;
10
+ line-height: 1.25rem;
11
+ }
12
+
13
+ .c4 span {
14
+ font-size: inherit;
15
+ line-height: inherit;
16
+ }
17
+
18
+ .c3 {
19
+ fill: #000000;
20
+ }
21
+
22
+ .c0 {
23
+ position: relative;
24
+ width: 100%;
25
+ }
26
+
27
+ .c1 {
28
+ visibility: visible;
29
+ }
30
+
31
+ .c2 {
32
+ display: flex;
33
+ flex-direction: row;
34
+ align-items: center;
35
+ gap: 0.5rem;
36
+ margin: 0 auto;
37
+ padding: 1rem;
38
+ border: none;
39
+ background: none;
40
+ cursor: pointer;
41
+ color: #000000;
42
+ }
43
+
44
+ .c2:hover span,
45
+ .c2:focus span {
46
+ text-decoration: underline;
47
+ }
48
+
49
+ @media (min-width: 740px) {
50
+ .c4 {
51
+ font-size: 1rem;
52
+ line-height: 1.25rem;
53
+ }
54
+ }
55
+
56
+ @media (min-width: 1024px) {
57
+ .c4 {
58
+ font-size: 1.125rem;
59
+ line-height: 1.375rem;
60
+ }
61
+ }
62
+
63
+ @media (min-width: 1024px) {
64
+ .c3 {
65
+ fill: #000000;
66
+ }
67
+ }
68
+
69
+ <div
70
+ backgroundColor="coral_light"
71
+ className="c0"
72
+ data-open="false"
73
+ data-testid="pop-up-secure-payment"
74
+ >
75
+ <div
76
+ className="c1"
77
+ >
78
+ <button
79
+ aria-expanded="false"
80
+ className="c2"
81
+ onClick={[Function]}
82
+ type="button"
83
+ >
84
+ <svg
85
+ className="c3"
86
+ height={17.6}
87
+ viewBox="0 0 10 11"
88
+ width={16}
89
+ xmlns="http://www.w3.org/2000/svg"
90
+ >
91
+ <path
92
+ d="M4.99985 0.5C6.61236 0.5 7.92429 1.81187 7.92429 3.42444V5.09466C7.92429 5.11364 7.94771 5.14562 7.96611 5.15173C8.12425 5.20447 8.25269 5.25017 8.37026 5.29549C8.51046 5.34954 8.61621 5.50492 8.61621 5.65693V9.49463C8.61621 9.64559 8.51115 9.80111 8.37183 9.85632C7.2939 10.2835 6.15941 10.5 4.99987 10.5C3.84033 10.5 2.70584 10.2834 1.62786 9.85627C1.48859 9.80107 1.38358 9.64559 1.38358 9.49463V5.65693C1.38358 5.50492 1.48931 5.34954 1.62958 5.29544C1.74721 5.25012 1.87562 5.20442 2.03365 5.15168C2.052 5.14556 2.07542 5.11357 2.07542 5.09459V3.42438C2.0755 1.81187 3.38734 0.5 4.99985 0.5ZM5.7964 6.82576C5.7964 6.38553 5.43977 6.02929 4.9999 6.02929C4.56007 6.02929 4.20345 6.3855 4.20345 6.82576C4.20345 7.11747 4.36794 7.36169 4.60168 7.50014V8.81697C4.60168 9.03711 4.7798 9.2152 4.99992 9.2152C5.22006 9.2152 5.39816 9.03711 5.39816 8.81697V7.50014C5.63188 7.36169 5.7964 7.11747 5.7964 6.82576ZM3.081 3.42438V4.86548C3.71026 4.73007 4.35583 4.6615 4.9996 4.66145C5.64307 4.66145 6.28851 4.73004 6.91874 4.86532V3.42438C6.91874 2.36631 6.05796 1.50555 4.9999 1.50555C3.94186 1.50553 3.081 2.36631 3.081 3.42438Z"
93
+ />
94
+ </svg>
95
+ <span
96
+ className="c4"
97
+ >
98
+ Your donation is secure and encrypted
99
+ </span>
100
+ </button>
101
+ </div>
102
+ </div>
103
+ `;
104
+
105
+ exports[`renders default blue_light variant 1`] = `
106
+ .c4 {
107
+ font-family: 'Montserrat',Helvetica,Arial,sans-serif;
108
+ font-weight: 400;
109
+ text-transform: inherit;
110
+ letter-spacing: 0;
111
+ font-size: 1rem;
112
+ line-height: 1.25rem;
113
+ }
114
+
115
+ .c4 span {
116
+ font-size: inherit;
117
+ line-height: inherit;
118
+ }
119
+
120
+ .c3 {
121
+ fill: #000000;
122
+ }
123
+
124
+ .c0 {
125
+ position: relative;
126
+ width: 100%;
127
+ }
128
+
129
+ .c1 {
130
+ visibility: visible;
131
+ }
132
+
133
+ .c2 {
134
+ display: flex;
135
+ flex-direction: row;
136
+ align-items: center;
137
+ gap: 0.5rem;
138
+ margin: 0 auto;
139
+ padding: 1rem;
140
+ border: none;
141
+ background: none;
142
+ cursor: pointer;
143
+ color: #000000;
144
+ }
145
+
146
+ .c2:hover span,
147
+ .c2:focus span {
148
+ text-decoration: underline;
149
+ }
150
+
151
+ @media (min-width: 740px) {
152
+ .c4 {
153
+ font-size: 1rem;
154
+ line-height: 1.25rem;
155
+ }
156
+ }
157
+
158
+ @media (min-width: 1024px) {
159
+ .c4 {
160
+ font-size: 1.125rem;
161
+ line-height: 1.375rem;
162
+ }
163
+ }
164
+
165
+ @media (min-width: 1024px) {
166
+ .c3 {
167
+ fill: #000000;
168
+ }
169
+ }
170
+
171
+ <div
172
+ className="c0"
173
+ data-open="false"
174
+ data-testid="pop-up-secure-payment"
175
+ >
176
+ <div
177
+ className="c1"
178
+ >
179
+ <button
180
+ aria-expanded="false"
181
+ className="c2"
182
+ onClick={[Function]}
183
+ type="button"
184
+ >
185
+ <svg
186
+ className="c3"
187
+ height={17.6}
188
+ viewBox="0 0 10 11"
189
+ width={16}
190
+ xmlns="http://www.w3.org/2000/svg"
191
+ >
192
+ <path
193
+ d="M4.99985 0.5C6.61236 0.5 7.92429 1.81187 7.92429 3.42444V5.09466C7.92429 5.11364 7.94771 5.14562 7.96611 5.15173C8.12425 5.20447 8.25269 5.25017 8.37026 5.29549C8.51046 5.34954 8.61621 5.50492 8.61621 5.65693V9.49463C8.61621 9.64559 8.51115 9.80111 8.37183 9.85632C7.2939 10.2835 6.15941 10.5 4.99987 10.5C3.84033 10.5 2.70584 10.2834 1.62786 9.85627C1.48859 9.80107 1.38358 9.64559 1.38358 9.49463V5.65693C1.38358 5.50492 1.48931 5.34954 1.62958 5.29544C1.74721 5.25012 1.87562 5.20442 2.03365 5.15168C2.052 5.14556 2.07542 5.11357 2.07542 5.09459V3.42438C2.0755 1.81187 3.38734 0.5 4.99985 0.5ZM5.7964 6.82576C5.7964 6.38553 5.43977 6.02929 4.9999 6.02929C4.56007 6.02929 4.20345 6.3855 4.20345 6.82576C4.20345 7.11747 4.36794 7.36169 4.60168 7.50014V8.81697C4.60168 9.03711 4.7798 9.2152 4.99992 9.2152C5.22006 9.2152 5.39816 9.03711 5.39816 8.81697V7.50014C5.63188 7.36169 5.7964 7.11747 5.7964 6.82576ZM3.081 3.42438V4.86548C3.71026 4.73007 4.35583 4.6615 4.9996 4.66145C5.64307 4.66145 6.28851 4.73004 6.91874 4.86532V3.42438C6.91874 2.36631 6.05796 1.50555 4.9999 1.50555C3.94186 1.50553 3.081 2.36631 3.081 3.42438Z"
194
+ />
195
+ </svg>
196
+ <span
197
+ className="c4"
198
+ >
199
+ Your donation is secure and encrypted
200
+ </span>
201
+ </button>
202
+ </div>
203
+ </div>
204
+ `;
@@ -0,0 +1,144 @@
1
+ import styled, { css, keyframes } from 'styled-components';
2
+ import zIndex from '../../../theme/shared/zIndex';
3
+ import { CLOSE_DURATION } from './PopUpShared.utils';
4
+
5
+ /**
6
+ * The overlay mounts when opened, so an entrance animation covers the transition
7
+ */
8
+ const openOverlay = keyframes`
9
+ from {
10
+ opacity: 0;
11
+ transform: translateY(-0.5rem);
12
+ }
13
+
14
+ to {
15
+ opacity: 1;
16
+ transform: translateY(0);
17
+ }
18
+ `;
19
+
20
+ /**
21
+ * Plays when the popup closes, before it is unmounted (see CLOSE_DURATION)
22
+ */
23
+ const closeOverlay = keyframes`
24
+ from {
25
+ opacity: 1;
26
+ transform: translateY(0);
27
+ }
28
+
29
+ to {
30
+ opacity: 0;
31
+ transform: translateY(-0.5rem);
32
+ }
33
+ `;
34
+
35
+ const PopUpWindow = styled.div`
36
+ font-family: ${({ theme }) => theme.fontFamilies('Montserrat')};
37
+ background-color: ${({ theme, $backgroundColour }) => theme.color($backgroundColour)};
38
+ color: ${({ theme, $textColour }) => theme.color($textColour)};
39
+ display: flex;
40
+ flex-direction: column;
41
+ width: 100%;
42
+ box-sizing: border-box;
43
+ border-radius: 1rem;
44
+
45
+ /* Keeps the heading clear of the close button */
46
+ h3 {
47
+ margin-right: 16px;
48
+ }
49
+
50
+ ${({ $isOpen }) => $isOpen && css`
51
+ font-size: 0.875rem;
52
+ @media ${({ theme }) => theme.allBreakpoints('M')} {
53
+ font-size: 1rem;
54
+ }
55
+
56
+ padding: 1.5rem;
57
+ @media ${({ theme }) => theme.allBreakpoints('L')} {
58
+ padding: 2rem;
59
+ }
60
+
61
+ position: absolute;
62
+ top: 0;
63
+ left: 0;
64
+ ${zIndex('high')}
65
+ box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.2);
66
+ animation: ${openOverlay} 250ms ease-out;
67
+
68
+ @media (prefers-reduced-motion: reduce) {
69
+ animation: none;
70
+ }
71
+ `}
72
+
73
+ ${({ $isClosing }) => $isClosing && css`
74
+ animation: ${closeOverlay} ${CLOSE_DURATION}ms ease-in forwards;
75
+
76
+ @media (prefers-reduced-motion: reduce) {
77
+ animation: none;
78
+ }
79
+ `}
80
+ `;
81
+
82
+ const Container = styled.div`
83
+ position: relative;
84
+ width: 100%;
85
+ `;
86
+
87
+ /**
88
+ * Hidden rather than unmounted when open, so the closed trigger keeps its
89
+ * space and content below the popup doesn't do the janky move around when it overlays/opens
90
+ */
91
+ const Trigger = styled.div`
92
+ visibility: ${({ $hidden }) => ($hidden ? 'hidden' : 'visible')};
93
+ `;
94
+
95
+ const CloseButton = styled.button`
96
+ align-self: flex-end;
97
+ display: flex;
98
+ padding: 0;
99
+ margin: 0;
100
+ border: none;
101
+ background: none;
102
+ cursor: pointer;
103
+ position: absolute;
104
+ right: 0.7rem;
105
+ top: 0.7rem;
106
+
107
+ @media ${({ theme }) => theme.allBreakpoints('L')} {
108
+ right: 1rem;
109
+ top: 1rem;
110
+ }
111
+
112
+ svg {
113
+ width: 18px;
114
+ height: 18px;
115
+ }
116
+
117
+ @media ${({ theme }) => theme.allBreakpoints('M')} {
118
+ svg {
119
+ width: 22px;
120
+ height: 22px;
121
+ }
122
+ }
123
+ `;
124
+
125
+ const PopUpHeading = styled.h3`
126
+ font-weight: 700;
127
+ margin-bottom: 1rem;
128
+ font-size: 0.875rem;
129
+ @media ${({ theme }) => theme.allBreakpoints('M')} {
130
+ font-size: 1rem;
131
+ }
132
+ `;
133
+
134
+ const PopUpBodyText = styled.p`
135
+ margin: 0 0 1rem;
136
+ font-size: 0.875rem;
137
+ @media ${({ theme }) => theme.allBreakpoints('M')} {
138
+ font-size: 1rem;
139
+ }
140
+ `;
141
+
142
+ export {
143
+ Container, Trigger, CloseButton, PopUpWindow, PopUpHeading, PopUpBodyText
144
+ };
@@ -0,0 +1,67 @@
1
+ import {
2
+ useCallback, useEffect, useRef, useState
3
+ } from 'react';
4
+
5
+ /* Keep in step with the closeOverlay animation in PopUpShared.style.js */
6
+ export const CLOSE_DURATION = 200;
7
+
8
+ /**
9
+ * Tracks open state and reports changes to the parent via onOpenChange
10
+ */
11
+ export const usePopUpOpen = onOpenChange => {
12
+ // 'closed' -> 'open' -> 'closing' -> 'closed'; 'closing' keeps the popup
13
+ // mounted long enough to play its exit animation
14
+ const [phase, setPhase] = useState('closed');
15
+ const containerRef = useRef(null);
16
+
17
+ const isOpen = phase === 'open';
18
+
19
+ const openPopUp = () => {
20
+ setPhase('open');
21
+ if (onOpenChange) {
22
+ onOpenChange(true);
23
+ }
24
+ };
25
+
26
+ const closePopUp = useCallback(() => {
27
+ setPhase('closing');
28
+ if (onOpenChange) {
29
+ onOpenChange(false);
30
+ }
31
+ }, [onOpenChange]);
32
+
33
+ // Unmount once the exit animation has finished
34
+ useEffect(() => {
35
+ if (phase !== 'closing') {
36
+ return undefined;
37
+ }
38
+
39
+ const timer = setTimeout(() => setPhase('closed'), CLOSE_DURATION);
40
+ return () => clearTimeout(timer);
41
+ }, [phase]);
42
+
43
+ // Close when a press lands outside the popup while it is open
44
+ useEffect(() => {
45
+ if (!isOpen) {
46
+ return undefined;
47
+ }
48
+
49
+ const handlePointerDown = event => {
50
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
51
+ closePopUp();
52
+ }
53
+ };
54
+
55
+ document.addEventListener('pointerdown', handlePointerDown);
56
+ return () => document.removeEventListener('pointerdown', handlePointerDown);
57
+ }, [isOpen, closePopUp]);
58
+
59
+ return {
60
+ isOpen,
61
+ isClosing: phase === 'closing',
62
+ isRendered: phase !== 'closed',
63
+ containerRef,
64
+ openPopUp,
65
+ closePopUp
66
+ };
67
+ };
@@ -56,7 +56,7 @@ exports[`renders correctly 1`] = `
56
56
  line-height: inherit;
57
57
  }
58
58
 
59
- .c12 {
59
+ .c13 {
60
60
  display: inline-flex;
61
61
  margin-left: 1rem;
62
62
  align-self: center;
@@ -85,6 +85,11 @@ exports[`renders correctly 1`] = `
85
85
  letter-spacing: 0;
86
86
  font-size: 1rem;
87
87
  line-height: 1.25rem;
88
+ display: inline-grid;
89
+ grid-template-columns: 1fr repeat(1,auto) 1fr;
90
+ grid-column-gap: 0.6rem;
91
+ grid-template-rows: auto;
92
+ justify-items: center;
88
93
  }
89
94
 
90
95
  .c11:hover,
@@ -101,7 +106,17 @@ exports[`renders correctly 1`] = `
101
106
  opacity: 0.35;
102
107
  }
103
108
 
104
- .c13 {
109
+ .c11 >.{
110
+ grid-column-start: 2;
111
+ padding-right: 1.5rem;
112
+ }
113
+
114
+ .c11 >.c12 {
115
+ margin-left: auto;
116
+ height: 1.25rem;
117
+ }
118
+
119
+ .c14 {
105
120
  fill: #FFFFFF;
106
121
  }
107
122
 
@@ -187,7 +202,7 @@ exports[`renders correctly 1`] = `
187
202
  }
188
203
 
189
204
  @media (min-width: 740px) {
190
- .c12 {
205
+ .c13 {
191
206
  width: auto;
192
207
  right: auto;
193
208
  position: relative;
@@ -221,7 +236,7 @@ exports[`renders correctly 1`] = `
221
236
  }
222
237
 
223
238
  @media (min-width: 1024px) {
224
- .c13 {
239
+ .c14 {
225
240
  fill: #FFFFFF;
226
241
  }
227
242
  }
@@ -330,13 +345,17 @@ exports[`renders correctly 1`] = `
330
345
  target="_self"
331
346
  type="button"
332
347
  >
333
- Check out the shop
334
348
  <span
335
- className="c12"
349
+ className=""
350
+ >
351
+ Check out the shop
352
+ </span>
353
+ <span
354
+ className="c12 c13"
336
355
  type="button"
337
356
  >
338
357
  <svg
339
- className="c13"
358
+ className="c14"
340
359
  fill="#FFFFFF"
341
360
  height={24}
342
361
  viewBox="0 0 96 96"
@@ -50,6 +50,10 @@ import ButtonWithStatesExample from '../components/Atoms/ButtonWithStates/Button
50
50
  import buttonWithStatesExampleSrc from '../components/Atoms/ButtonWithStates/ButtonWithStatesExample.jsx?raw';
51
51
  import InfoMessageExample from '../components/Atoms/InfoMessage/InfoMessageExample.jsx';
52
52
  import infoMessageExampleSrc from '../components/Atoms/InfoMessage/InfoMessageExample.jsx?raw';
53
+ import PopUpSecurePaymentExample from '../components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePaymentExample.jsx';
54
+ import popUpSecurePaymentExampleSrc from '../components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePaymentExample.jsx?raw';
55
+ import PopUpGiftAidExample from '../components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAidExample.jsx';
56
+ import popUpGiftAidExampleSrc from '../components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAidExample.jsx?raw';
53
57
 
54
58
  // Molecule examples
55
59
  import InfoBannerExample from '../components/Molecules/InfoBanner/InfoBannerExample.jsx';
@@ -222,6 +226,8 @@ export const molecules = [
222
226
  { name: 'Lookup', demo: demo(LookupExample, lookupExampleSrc) },
223
227
  { name: 'PartnerLink', demo: demo(PartnerLinkExample, partnerLinkExampleSrc) },
224
228
  { name: 'PictureOrVideo', demo: demo(PictureOrVideoExample, pictureOrVideoExampleSrc) },
229
+ { name: 'PopUpGiftAid', demo: demo(PopUpGiftAidExample, popUpGiftAidExampleSrc) },
230
+ { name: 'PopUpSecurePayment', demo: demo(PopUpSecurePaymentExample, popUpSecurePaymentExampleSrc) },
225
231
  { name: 'Promo', demo: demo(PromoExample, promoExampleSrc) },
226
232
  { name: 'QuoteSlice', demo: demo(QuoteSliceExample, quoteSliceExampleSrc) },
227
233
  { name: 'SchoolLookup', demo: demo(SchoolLookupExample, schoolLookupExampleSrc) },
package/src/index.js CHANGED
@@ -58,6 +58,8 @@ export { default as LogoLinked } from './components/Molecules/LogoLinked/LogoLin
58
58
  export { default as Lookup } from './components/Molecules/Lookup/Lookup';
59
59
  export { default as PartnerLink } from './components/Molecules/PartnerLink/PartnerLink';
60
60
  export { default as PictureOrVideo } from './components/Molecules/PictureOrVideo/PictureOrVideo';
61
+ export { default as PopUpSecurePayment } from './components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePayment';
62
+ export { default as PopUpGiftAid } from './components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAid';
61
63
  export { default as Promo } from './components/Molecules/Promo/Promo';
62
64
  export { default as QuoteSlice } from './components/Molecules/QuoteSlice/QuoteSlice';
63
65
  export { default as SchoolLookup } from './components/Molecules/SchoolLookup/SchoolLookup';