@comicrelief/component-library 8.88.0 → 8.89.1

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 (22) hide show
  1. package/dist/index.cjs.js +975 -812
  2. package/dist/index.es.js +7919 -7496
  3. package/package.json +1 -1
  4. package/src/components/Atoms/Icons/CrossRoundedCorners.js +43 -0
  5. package/src/components/Atoms/Icons/GiftAidLogo.js +37 -0
  6. package/src/components/Atoms/Icons/IconsExample.jsx +4 -1
  7. package/src/components/Atoms/Icons/Padlock.js +42 -0
  8. package/src/components/Atoms/Icons/index.js +2 -0
  9. package/src/components/Molecules/ExpandedButton/ExpandedButton.style.js +5 -1
  10. package/src/components/Molecules/ExpandedButton/__snapshots__/ExpandedButton.test.js.snap +7 -1
  11. package/src/components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAid.js +103 -0
  12. package/src/components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAid.test.js +38 -0
  13. package/src/components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAidExample.jsx +46 -0
  14. package/src/components/Molecules/PopUp/PopUpGiftAid/__snapshots__/PopUpGiftAid.test.js.snap +168 -0
  15. package/src/components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePayment.js +102 -0
  16. package/src/components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePayment.test.js +38 -0
  17. package/src/components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePaymentExample.jsx +46 -0
  18. package/src/components/Molecules/PopUp/PopUpSecurePayment/__snapshots__/PopUpSecurePayment.test.js.snap +204 -0
  19. package/src/components/Molecules/PopUp/PopUpShared.style.js +144 -0
  20. package/src/components/Molecules/PopUp/PopUpShared.utils.js +67 -0
  21. package/src/demos/index.jsx +6 -0
  22. package/src/index.js +2 -0
@@ -0,0 +1,102 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+
5
+ import Text from '../../../Atoms/Text/Text';
6
+ import Cross from '../../../Atoms/Icons/CrossRoundedCorners';
7
+ import Padlock from '../../../Atoms/Icons/Padlock';
8
+ import {
9
+ Container, Trigger, CloseButton, PopUpWindow, PopUpHeading, PopUpBodyText
10
+ } from '../PopUpShared.style';
11
+ import { usePopUpOpen } from '../PopUpShared.utils';
12
+
13
+ const DEFAULT_TRIGGER_TEXT = 'Your donation is secure and encrypted';
14
+
15
+ const DEFAULT_HEADING = 'How we keep your donations secure and encrypted';
16
+
17
+ const DEFAULT_PARAGRAPHS = [
18
+ 'We’ve partnered with trusted payment services like Braintree, Stripe, GoCardless, PayPal, Google, and Apple to keep your payment information safe and sound. Every transaction is fully encrypted.',
19
+ 'We also use a secure server and follow best practices to protect your data, like your name and address. Our systems get checked every year by the NCC Group, and we regularly chat with AWS to stay ahead of any potential issues.'
20
+ ];
21
+
22
+ const SecureButton = styled.button`
23
+ display: flex;
24
+ flex-direction: row;
25
+ align-items: center;
26
+ gap: 0.5rem;
27
+ margin: 0 auto;
28
+ padding: 1rem;
29
+ border: none;
30
+ background: none;
31
+ cursor: pointer;
32
+ color: ${({ theme }) => theme.color('black')};
33
+
34
+ &:hover span,
35
+ &:focus span {
36
+ text-decoration: underline;
37
+ }
38
+ `;
39
+
40
+ const PopUpSecurePayment = ({
41
+ triggerText = DEFAULT_TRIGGER_TEXT,
42
+ heading = DEFAULT_HEADING,
43
+ paragraphs = DEFAULT_PARAGRAPHS,
44
+ onOpenChange,
45
+ ...rest
46
+ }) => {
47
+ const {
48
+ isOpen, isClosing, isRendered, containerRef, openPopUp, closePopUp
49
+ } = usePopUpOpen(onOpenChange);
50
+
51
+ return (
52
+ <Container
53
+ ref={containerRef}
54
+ data-testid="pop-up-secure-payment"
55
+ data-open={isOpen ? 'true' : 'false'}
56
+ {...rest}
57
+ >
58
+ <Trigger $hidden={isRendered}>
59
+ <SecureButton
60
+ type="button"
61
+ onClick={openPopUp}
62
+ aria-expanded={isOpen ? 'true' : 'false'}
63
+ >
64
+ <Padlock colour="black" size={16} />
65
+ <Text>{triggerText}</Text>
66
+ </SecureButton>
67
+ </Trigger>
68
+
69
+ {isRendered && (
70
+ <PopUpWindow
71
+ $backgroundColour="white"
72
+ $isOpen={isRendered}
73
+ $isClosing={isClosing}
74
+ >
75
+ <CloseButton
76
+ type="button"
77
+ onClick={closePopUp}
78
+ aria-label="Close"
79
+ >
80
+ <Cross colour="black" size={24} />
81
+ </CloseButton>
82
+
83
+ <PopUpHeading>{heading}</PopUpHeading>
84
+
85
+ {paragraphs.map((paragraph, index) => (
86
+ // eslint-disable-next-line react/no-array-index-key
87
+ <PopUpBodyText key={index}>{paragraph}</PopUpBodyText>
88
+ ))}
89
+ </PopUpWindow>
90
+ )}
91
+ </Container>
92
+ );
93
+ };
94
+
95
+ PopUpSecurePayment.propTypes = {
96
+ triggerText: PropTypes.string,
97
+ heading: PropTypes.string,
98
+ paragraphs: PropTypes.arrayOf(PropTypes.string),
99
+ onOpenChange: PropTypes.func
100
+ };
101
+
102
+ export default PopUpSecurePayment;
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import 'jest-styled-components';
3
+ import { act } from 'react-test-renderer';
4
+
5
+ import renderWithTheme from '../../../../../tests/hoc/shallowWithTheme';
6
+ import PopUpSecurePayment from './PopUpSecurePayment';
7
+
8
+ it('renders default blue_light variant', () => {
9
+ const renderer = renderWithTheme(<PopUpSecurePayment />);
10
+ expect(renderer.toJSON()).toMatchSnapshot();
11
+ });
12
+
13
+ it('renders coral_light variant', () => {
14
+ const renderer = renderWithTheme(<PopUpSecurePayment backgroundColor="coral_light" />);
15
+ expect(renderer.toJSON()).toMatchSnapshot();
16
+ });
17
+
18
+ it('starts collapsed, opens on row click and closes again with the cross', () => {
19
+ jest.useFakeTimers();
20
+ const renderer = renderWithTheme(<PopUpSecurePayment />);
21
+ expect(renderer.root.findAll(node => node.type === 'button' && node.props['aria-label'] === 'Close')).toHaveLength(0);
22
+
23
+ act(() => {
24
+ renderer.root.find(node => node.type === 'button' && node.props['aria-expanded'] === 'false').props.onClick();
25
+ });
26
+ expect(renderer.root.findAll(node => node.type === 'button' && node.props['aria-label'] === 'Close')).toHaveLength(1);
27
+
28
+ act(() => {
29
+ renderer.root.find(node => node.type === 'button' && node.props['aria-label'] === 'Close').props.onClick();
30
+ });
31
+
32
+ // Wait for the 200ms exit animation before the popup unmounts
33
+ act(() => {
34
+ jest.advanceTimersByTime(200);
35
+ });
36
+ expect(renderer.root.findAll(node => node.type === 'button' && node.props['aria-label'] === 'Close')).toHaveLength(0);
37
+ expect(renderer.root.find(node => node.type === 'button' && node.props['aria-expanded'] === 'false')).toBeTruthy();
38
+ });
@@ -0,0 +1,46 @@
1
+ import React, { useState } from 'react';
2
+ import PopUpSecurePayment from './PopUpSecurePayment';
3
+ import styled from 'styled-components';
4
+
5
+ /**
6
+ * Parent styling from the JS state (onOpenChange) uses data-open attribute
7
+ * on the popup's container to fire CSS styles via :has()
8
+ */
9
+ const Wrapper = styled.div`
10
+ position: relative;
11
+ padding: 1rem;
12
+ background: ${({ $isOpen }) => ($isOpen ? 'orange' : 'green')};
13
+
14
+ &:has([data-open="true"]) {
15
+ outline: 2px solid black;
16
+ }
17
+
18
+ /* Shade over the wrapper's content while the popup is open */
19
+ &:before {
20
+ content: '';
21
+ position: absolute;
22
+ top: 0;
23
+ right: 0;
24
+ bottom: 0;
25
+ left: 0;
26
+ background-color: rgba(0, 0, 0, 0.4);
27
+ pointer-events: none;
28
+ display: ${({ $isOpen }) => ($isOpen ? 'block' : 'none')};
29
+ }
30
+ `;
31
+
32
+ const Status = styled.p`
33
+ margin: 0 0 0.5rem;
34
+ color: white;
35
+ `;
36
+
37
+ export default function PopUpSecurePaymentExample() {
38
+ const [isOpen, setIsOpen] = useState(false);
39
+
40
+ return (
41
+ <Wrapper $isOpen={isOpen}>
42
+ <Status>{isOpen ? 'Popup is open' : 'popup is closed'}</Status>
43
+ <PopUpSecurePayment onOpenChange={setIsOpen} />
44
+ </Wrapper>
45
+ );
46
+ }
@@ -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
+ };
@@ -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';