@comicrelief/component-library 8.89.2 → 8.90.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/index.cjs.js +692 -642
- package/dist/index.es.js +5439 -5373
- package/package.json +1 -1
- package/src/components/Atoms/Icons/GiftAidLogo.js +11 -5
- package/src/components/Atoms/Icons/IconsExample.jsx +3 -1
- package/src/components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAid.js +36 -7
- package/src/components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAidExample.jsx +34 -33
- package/src/components/Molecules/PopUp/PopUpGiftAid/__snapshots__/PopUpGiftAid.test.js.snap +48 -32
- package/src/components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePayment.js +19 -3
- package/src/components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePaymentExample.jsx +23 -37
- package/src/components/Molecules/PopUp/PopUpShared.style.js +47 -1
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import styled, { withTheme } from 'styled-components';
|
|
3
|
+
import styled, { css, withTheme } from 'styled-components';
|
|
4
4
|
|
|
5
5
|
const StyledSVG = styled.svg`
|
|
6
|
-
|
|
6
|
+
display: block;
|
|
7
|
+
${({ $fluid }) => $fluid && css`
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: auto;
|
|
10
|
+
`}
|
|
11
|
+
fill: ${({ mobileColour, colour, theme }) => (mobileColour ? theme.color(mobileColour) : theme.color(colour))};
|
|
7
12
|
|
|
8
13
|
@media ${({ theme }) => theme.allBreakpoints('L')} {
|
|
9
14
|
fill: ${({ $colour, theme }) => ($colour ? theme.color($colour) : theme.color('white'))};
|
|
@@ -11,12 +16,13 @@ const StyledSVG = styled.svg`
|
|
|
11
16
|
`;
|
|
12
17
|
|
|
13
18
|
const GiftAidLogo = ({
|
|
14
|
-
colour = 'black', mobileColour = null,
|
|
19
|
+
colour = 'black', mobileColour = null, size = null, theme, ...rest
|
|
15
20
|
}) => (
|
|
16
21
|
<StyledSVG
|
|
17
22
|
{...rest}
|
|
18
|
-
width={size}
|
|
19
|
-
height={(size * 124) / 350}
|
|
23
|
+
width={size || undefined}
|
|
24
|
+
height={size ? (size * 124) / 350 : undefined}
|
|
25
|
+
$fluid={!size}
|
|
20
26
|
fill={theme.color(colour)}
|
|
21
27
|
$colour={colour}
|
|
22
28
|
$mobileColour={mobileColour}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
Arrow, AtSign, Chevron, CtaArrow, Download, External, Favourite, GiftAidLogo, Internal, Post, Filter, Undo
|
|
5
5
|
} from './index';
|
|
6
6
|
import Cross from './Cross';
|
|
7
|
+
import CrossRoundedCorners from './CrossRoundedCorners';
|
|
7
8
|
import Padlock from './Padlock';
|
|
8
9
|
import Curve from './Curve';
|
|
9
10
|
import { ExampleContainer } from '../../../demos/SharedStyles';
|
|
@@ -51,10 +52,11 @@ export default function IconsExample() {
|
|
|
51
52
|
['Internal', <Internal size={48} colour="black" />],
|
|
52
53
|
['AtSign', <AtSign size={48} colour="black" />],
|
|
53
54
|
['Cross', <Cross size={48} colour="black" />],
|
|
55
|
+
['CrossRoundedCorners', <CrossRoundedCorners size={48} colour="black" />],
|
|
54
56
|
['Padlock', <Padlock size={48} colour="black" />],
|
|
55
57
|
['Post', <Post size={48} colour="black" />],
|
|
56
58
|
['Filter', <Filter size={48} colour="black" />],
|
|
57
|
-
['GiftAidLogo', <GiftAidLogo size={
|
|
59
|
+
['GiftAidLogo', <GiftAidLogo size={130} colour="black" />],
|
|
58
60
|
['Undo', <Undo size={48} colour="black" />]
|
|
59
61
|
].map(([name, icon]) => (
|
|
60
62
|
<IconCard key={name}>
|
|
@@ -5,7 +5,7 @@ import styled, { css } from 'styled-components';
|
|
|
5
5
|
import Cross from '../../../Atoms/Icons/CrossRoundedCorners';
|
|
6
6
|
import GiftAidLogo from '../../../Atoms/Icons/GiftAidLogo';
|
|
7
7
|
import {
|
|
8
|
-
Container, Trigger, CloseButton, PopUpWindow, PopUpHeading, PopUpBodyText
|
|
8
|
+
Container, Trigger, CloseButton, PopUpWindow, PopUpHeading, PopUpBodyText, PageOverlay
|
|
9
9
|
} from '../PopUpShared.style';
|
|
10
10
|
import { usePopUpOpen } from '../PopUpShared.utils';
|
|
11
11
|
|
|
@@ -17,7 +17,29 @@ const DEFAULT_PARAGRAPHS = [
|
|
|
17
17
|
'In short, £1 + Gift Aid = £1.25, at no extra cost to you.'
|
|
18
18
|
];
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Not positioned itself, so the open popup is absolutely positioned against
|
|
22
|
+
* the parent container and centred within it
|
|
23
|
+
*/
|
|
24
|
+
const GiftAidContainer = styled(Container)`
|
|
25
|
+
position: static;
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The open popup is positioned over the parent container, so its width is set
|
|
30
|
+
* independently of the trigger's width (via openWindowWidth) and centred within it
|
|
31
|
+
*/
|
|
32
|
+
const OpenPopUpWindow = styled(PopUpWindow)`
|
|
33
|
+
width: ${({ $openWindowWidth }) => $openWindowWidth};
|
|
34
|
+
left: 50%;
|
|
35
|
+
right: auto;
|
|
36
|
+
margin-left: ${({ $openWindowWidth }) => `calc(${$openWindowWidth} / -2)`};
|
|
37
|
+
`;
|
|
38
|
+
|
|
20
39
|
const LogoWrapper = styled.button`
|
|
40
|
+
display: block;
|
|
41
|
+
width: 100%;
|
|
42
|
+
padding: 0;
|
|
21
43
|
border: none;
|
|
22
44
|
background: none;
|
|
23
45
|
cursor: pointer;
|
|
@@ -32,6 +54,8 @@ const LogoWrapper = styled.button`
|
|
|
32
54
|
const PopUpGiftAid = ({
|
|
33
55
|
textColour = 'black',
|
|
34
56
|
hoverColour = 'red',
|
|
57
|
+
backgroundColour = 'transparent',
|
|
58
|
+
openWindowWidth = '20rem',
|
|
35
59
|
heading = DEFAULT_HEADING,
|
|
36
60
|
paragraphs = DEFAULT_PARAGRAPHS,
|
|
37
61
|
onOpenChange,
|
|
@@ -42,15 +66,17 @@ const PopUpGiftAid = ({
|
|
|
42
66
|
} = usePopUpOpen(onOpenChange);
|
|
43
67
|
|
|
44
68
|
return (
|
|
45
|
-
<
|
|
69
|
+
<GiftAidContainer
|
|
46
70
|
ref={containerRef}
|
|
47
71
|
data-testid="pop-up-gift-aid"
|
|
48
72
|
data-open={isOpen ? 'true' : 'false'}
|
|
49
73
|
{...rest}
|
|
50
74
|
>
|
|
75
|
+
{isRendered && <PageOverlay aria-hidden="true" />}
|
|
76
|
+
|
|
51
77
|
<Trigger $hidden={isRendered}>
|
|
52
78
|
<PopUpWindow
|
|
53
|
-
$backgroundColour=
|
|
79
|
+
$backgroundColour={backgroundColour}
|
|
54
80
|
$textColour={textColour}
|
|
55
81
|
>
|
|
56
82
|
<LogoWrapper
|
|
@@ -60,17 +86,18 @@ const PopUpGiftAid = ({
|
|
|
60
86
|
aria-label="What is Gift Aid?"
|
|
61
87
|
$hoverColour={hoverColour}
|
|
62
88
|
>
|
|
63
|
-
<GiftAidLogo
|
|
89
|
+
<GiftAidLogo colour={textColour} />
|
|
64
90
|
</LogoWrapper>
|
|
65
91
|
</PopUpWindow>
|
|
66
92
|
</Trigger>
|
|
67
93
|
|
|
68
94
|
{isRendered && (
|
|
69
|
-
<
|
|
95
|
+
<OpenPopUpWindow
|
|
70
96
|
$backgroundColour="white"
|
|
71
97
|
$textColour={textColour}
|
|
72
98
|
$isOpen={isRendered}
|
|
73
99
|
$isClosing={isClosing}
|
|
100
|
+
$openWindowWidth={openWindowWidth}
|
|
74
101
|
>
|
|
75
102
|
<CloseButton
|
|
76
103
|
type="button"
|
|
@@ -86,15 +113,17 @@ const PopUpGiftAid = ({
|
|
|
86
113
|
{paragraphs.map(paragraph => (
|
|
87
114
|
<PopUpBodyText key={paragraph}>{paragraph}</PopUpBodyText>
|
|
88
115
|
))}
|
|
89
|
-
</
|
|
116
|
+
</OpenPopUpWindow>
|
|
90
117
|
)}
|
|
91
|
-
</
|
|
118
|
+
</GiftAidContainer>
|
|
92
119
|
);
|
|
93
120
|
};
|
|
94
121
|
|
|
95
122
|
PopUpGiftAid.propTypes = {
|
|
96
123
|
textColour: PropTypes.string,
|
|
97
124
|
hoverColour: PropTypes.string,
|
|
125
|
+
backgroundColour: PropTypes.string,
|
|
126
|
+
openWindowWidth: PropTypes.string,
|
|
98
127
|
heading: PropTypes.string,
|
|
99
128
|
paragraphs: PropTypes.arrayOf(PropTypes.string),
|
|
100
129
|
onOpenChange: PropTypes.func
|
|
@@ -1,46 +1,47 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import PopUpGiftAid from './PopUpGiftAid';
|
|
3
2
|
import styled from 'styled-components';
|
|
3
|
+
import PopUpGiftAid from './PopUpGiftAid';
|
|
4
|
+
import { ExampleContainer } from '../PopUpShared.style';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
const Wrapper = styled.div`
|
|
10
|
-
position: relative;
|
|
11
|
-
background: ${({ $isOpen }) => ($isOpen ? 'orange' : 'green')};
|
|
12
|
-
padding: 1rem;
|
|
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
|
-
}
|
|
6
|
+
const GiftExampleContainer = styled(ExampleContainer)`
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: space-between;
|
|
30
9
|
`;
|
|
31
10
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
11
|
+
const PopUpExampleWrapper = styled.div`
|
|
12
|
+
width: 150px;
|
|
13
|
+
height: auto;
|
|
35
14
|
`;
|
|
36
15
|
|
|
37
16
|
export default function PopUpGiftAidExample() {
|
|
38
17
|
const [isOpen, setIsOpen] = useState(false);
|
|
39
18
|
|
|
40
19
|
return (
|
|
41
|
-
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
<>
|
|
21
|
+
<GiftExampleContainer $isOpen={isOpen}>
|
|
22
|
+
<h3>Default / no props, isOpen trigger</h3>
|
|
23
|
+
<PopUpExampleWrapper> <PopUpGiftAid onOpenChange={setIsOpen}/> </PopUpExampleWrapper>
|
|
24
|
+
</GiftExampleContainer>
|
|
25
|
+
|
|
26
|
+
<GiftExampleContainer>
|
|
27
|
+
<h3>Props - textColour, backgroundColour, hoverColour, openWindowWidth</h3>
|
|
28
|
+
<PopUpExampleWrapper>
|
|
29
|
+
<PopUpGiftAid textColour="green" backgroundColour="blue_light" hoverColour='coral_light' openWindowWidth='550px'/>
|
|
30
|
+
</PopUpExampleWrapper>
|
|
31
|
+
</GiftExampleContainer>
|
|
32
|
+
|
|
33
|
+
<GiftExampleContainer>
|
|
34
|
+
<h3>Custom heading and paragraphs</h3>
|
|
35
|
+
<PopUpExampleWrapper>
|
|
36
|
+
<PopUpGiftAid
|
|
37
|
+
heading="Why does Gift Aid matter?"
|
|
38
|
+
paragraphs={[
|
|
39
|
+
'Gift Aid lets charities reclaim the tax you have already paid on your donation.',
|
|
40
|
+
'Every £1 you give can be worth £1.25 to the charity at no extra cost to you.'
|
|
41
|
+
]}
|
|
42
|
+
/>
|
|
43
|
+
</PopUpExampleWrapper>
|
|
44
|
+
</GiftExampleContainer>
|
|
45
|
+
</>
|
|
45
46
|
);
|
|
46
47
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`renders coral_light variant 1`] = `
|
|
4
|
-
.
|
|
4
|
+
.c3 {
|
|
5
5
|
font-family: 'Montserrat',Helvetica,Arial,sans-serif;
|
|
6
|
-
background-color:
|
|
6
|
+
background-color: transparent;
|
|
7
7
|
color: #000000;
|
|
8
8
|
display: flex;
|
|
9
9
|
flex-direction: column;
|
|
@@ -12,7 +12,7 @@ exports[`renders coral_light variant 1`] = `
|
|
|
12
12
|
border-radius: 1rem;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
.
|
|
15
|
+
.c3 h3 {
|
|
16
16
|
margin-right: 16px;
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -21,55 +21,63 @@ exports[`renders coral_light variant 1`] = `
|
|
|
21
21
|
width: 100%;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
.
|
|
24
|
+
.c2 {
|
|
25
25
|
visibility: visible;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.
|
|
29
|
-
|
|
28
|
+
.c5 {
|
|
29
|
+
display: block;
|
|
30
|
+
width: 100%;
|
|
31
|
+
height: auto;
|
|
32
|
+
fill: inherit;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
.
|
|
35
|
+
.c1 {
|
|
36
|
+
position: static;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.c4 {
|
|
40
|
+
display: block;
|
|
41
|
+
width: 100%;
|
|
42
|
+
padding: 0;
|
|
33
43
|
border: none;
|
|
34
44
|
background: none;
|
|
35
45
|
cursor: pointer;
|
|
36
46
|
}
|
|
37
47
|
|
|
38
|
-
.
|
|
48
|
+
.c4:hover svg {
|
|
39
49
|
fill: #E52630;
|
|
40
50
|
}
|
|
41
51
|
|
|
42
52
|
@media (min-width: 1024px) {
|
|
43
|
-
.
|
|
53
|
+
.c5 {
|
|
44
54
|
fill: #000000;
|
|
45
55
|
}
|
|
46
56
|
}
|
|
47
57
|
|
|
48
58
|
<div
|
|
49
59
|
backgroundColor="coral_light"
|
|
50
|
-
className="c0"
|
|
60
|
+
className="c0 c1"
|
|
51
61
|
data-open="false"
|
|
52
62
|
data-testid="pop-up-gift-aid"
|
|
53
63
|
>
|
|
54
64
|
<div
|
|
55
|
-
className="
|
|
65
|
+
className="c2"
|
|
56
66
|
>
|
|
57
67
|
<div
|
|
58
|
-
className="
|
|
68
|
+
className="c3"
|
|
59
69
|
>
|
|
60
70
|
<button
|
|
61
71
|
aria-expanded="false"
|
|
62
72
|
aria-label="What is Gift Aid?"
|
|
63
|
-
className="
|
|
73
|
+
className="c4"
|
|
64
74
|
onClick={[Function]}
|
|
65
75
|
type="button"
|
|
66
76
|
>
|
|
67
77
|
<svg
|
|
68
|
-
className="
|
|
78
|
+
className="c5"
|
|
69
79
|
fill="#000000"
|
|
70
|
-
height={49.6}
|
|
71
80
|
viewBox="0 0 350 124"
|
|
72
|
-
width={140}
|
|
73
81
|
xmlns="http://www.w3.org/2000/svg"
|
|
74
82
|
>
|
|
75
83
|
<path
|
|
@@ -83,9 +91,9 @@ exports[`renders coral_light variant 1`] = `
|
|
|
83
91
|
`;
|
|
84
92
|
|
|
85
93
|
exports[`renders default blue_light variant 1`] = `
|
|
86
|
-
.
|
|
94
|
+
.c3 {
|
|
87
95
|
font-family: 'Montserrat',Helvetica,Arial,sans-serif;
|
|
88
|
-
background-color:
|
|
96
|
+
background-color: transparent;
|
|
89
97
|
color: #000000;
|
|
90
98
|
display: flex;
|
|
91
99
|
flex-direction: column;
|
|
@@ -94,7 +102,7 @@ exports[`renders default blue_light variant 1`] = `
|
|
|
94
102
|
border-radius: 1rem;
|
|
95
103
|
}
|
|
96
104
|
|
|
97
|
-
.
|
|
105
|
+
.c3 h3 {
|
|
98
106
|
margin-right: 16px;
|
|
99
107
|
}
|
|
100
108
|
|
|
@@ -103,54 +111,62 @@ exports[`renders default blue_light variant 1`] = `
|
|
|
103
111
|
width: 100%;
|
|
104
112
|
}
|
|
105
113
|
|
|
106
|
-
.
|
|
114
|
+
.c2 {
|
|
107
115
|
visibility: visible;
|
|
108
116
|
}
|
|
109
117
|
|
|
110
|
-
.
|
|
111
|
-
|
|
118
|
+
.c5 {
|
|
119
|
+
display: block;
|
|
120
|
+
width: 100%;
|
|
121
|
+
height: auto;
|
|
122
|
+
fill: inherit;
|
|
112
123
|
}
|
|
113
124
|
|
|
114
|
-
.
|
|
125
|
+
.c1 {
|
|
126
|
+
position: static;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.c4 {
|
|
130
|
+
display: block;
|
|
131
|
+
width: 100%;
|
|
132
|
+
padding: 0;
|
|
115
133
|
border: none;
|
|
116
134
|
background: none;
|
|
117
135
|
cursor: pointer;
|
|
118
136
|
}
|
|
119
137
|
|
|
120
|
-
.
|
|
138
|
+
.c4:hover svg {
|
|
121
139
|
fill: #E52630;
|
|
122
140
|
}
|
|
123
141
|
|
|
124
142
|
@media (min-width: 1024px) {
|
|
125
|
-
.
|
|
143
|
+
.c5 {
|
|
126
144
|
fill: #000000;
|
|
127
145
|
}
|
|
128
146
|
}
|
|
129
147
|
|
|
130
148
|
<div
|
|
131
|
-
className="c0"
|
|
149
|
+
className="c0 c1"
|
|
132
150
|
data-open="false"
|
|
133
151
|
data-testid="pop-up-gift-aid"
|
|
134
152
|
>
|
|
135
153
|
<div
|
|
136
|
-
className="
|
|
154
|
+
className="c2"
|
|
137
155
|
>
|
|
138
156
|
<div
|
|
139
|
-
className="
|
|
157
|
+
className="c3"
|
|
140
158
|
>
|
|
141
159
|
<button
|
|
142
160
|
aria-expanded="false"
|
|
143
161
|
aria-label="What is Gift Aid?"
|
|
144
|
-
className="
|
|
162
|
+
className="c4"
|
|
145
163
|
onClick={[Function]}
|
|
146
164
|
type="button"
|
|
147
165
|
>
|
|
148
166
|
<svg
|
|
149
|
-
className="
|
|
167
|
+
className="c5"
|
|
150
168
|
fill="#000000"
|
|
151
|
-
height={49.6}
|
|
152
169
|
viewBox="0 0 350 124"
|
|
153
|
-
width={140}
|
|
154
170
|
xmlns="http://www.w3.org/2000/svg"
|
|
155
171
|
>
|
|
156
172
|
<path
|
|
@@ -6,10 +6,21 @@ import Text from '../../../Atoms/Text/Text';
|
|
|
6
6
|
import Cross from '../../../Atoms/Icons/CrossRoundedCorners';
|
|
7
7
|
import Padlock from '../../../Atoms/Icons/Padlock';
|
|
8
8
|
import {
|
|
9
|
-
Container, Trigger, CloseButton, PopUpWindow, PopUpHeading, PopUpBodyText
|
|
9
|
+
Container, Trigger, CloseButton, PopUpWindow, PopUpHeading, PopUpBodyText, PageOverlay
|
|
10
10
|
} from '../PopUpShared.style';
|
|
11
11
|
import { usePopUpOpen } from '../PopUpShared.utils';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* The open popup is positioned over the trigger, so its width is set
|
|
15
|
+
* independently of the trigger's width (via openWindowWidth) and centred on it
|
|
16
|
+
*/
|
|
17
|
+
const OpenPopUpWindow = styled(PopUpWindow)`
|
|
18
|
+
width: ${({ $openWindowWidth }) => $openWindowWidth};
|
|
19
|
+
left: 50%;
|
|
20
|
+
right: auto;
|
|
21
|
+
margin-left: ${({ $openWindowWidth }) => `calc(${$openWindowWidth} / -2)`};
|
|
22
|
+
`;
|
|
23
|
+
|
|
13
24
|
const DEFAULT_TRIGGER_TEXT = 'Your donation is secure and encrypted';
|
|
14
25
|
|
|
15
26
|
const DEFAULT_HEADING = 'How we keep your donations secure and encrypted';
|
|
@@ -41,6 +52,7 @@ const PopUpSecurePayment = ({
|
|
|
41
52
|
triggerText = DEFAULT_TRIGGER_TEXT,
|
|
42
53
|
heading = DEFAULT_HEADING,
|
|
43
54
|
paragraphs = DEFAULT_PARAGRAPHS,
|
|
55
|
+
openWindowWidth = '100%',
|
|
44
56
|
onOpenChange,
|
|
45
57
|
...rest
|
|
46
58
|
}) => {
|
|
@@ -55,6 +67,8 @@ const PopUpSecurePayment = ({
|
|
|
55
67
|
data-open={isOpen ? 'true' : 'false'}
|
|
56
68
|
{...rest}
|
|
57
69
|
>
|
|
70
|
+
{isRendered && <PageOverlay aria-hidden="true" />}
|
|
71
|
+
|
|
58
72
|
<Trigger $hidden={isRendered}>
|
|
59
73
|
<SecureButton
|
|
60
74
|
type="button"
|
|
@@ -67,10 +81,11 @@ const PopUpSecurePayment = ({
|
|
|
67
81
|
</Trigger>
|
|
68
82
|
|
|
69
83
|
{isRendered && (
|
|
70
|
-
<
|
|
84
|
+
<OpenPopUpWindow
|
|
71
85
|
$backgroundColour="white"
|
|
72
86
|
$isOpen={isRendered}
|
|
73
87
|
$isClosing={isClosing}
|
|
88
|
+
$openWindowWidth={openWindowWidth}
|
|
74
89
|
>
|
|
75
90
|
<CloseButton
|
|
76
91
|
type="button"
|
|
@@ -86,7 +101,7 @@ const PopUpSecurePayment = ({
|
|
|
86
101
|
// eslint-disable-next-line react/no-array-index-key
|
|
87
102
|
<PopUpBodyText key={index}>{paragraph}</PopUpBodyText>
|
|
88
103
|
))}
|
|
89
|
-
</
|
|
104
|
+
</OpenPopUpWindow>
|
|
90
105
|
)}
|
|
91
106
|
</Container>
|
|
92
107
|
);
|
|
@@ -96,6 +111,7 @@ PopUpSecurePayment.propTypes = {
|
|
|
96
111
|
triggerText: PropTypes.string,
|
|
97
112
|
heading: PropTypes.string,
|
|
98
113
|
paragraphs: PropTypes.arrayOf(PropTypes.string),
|
|
114
|
+
openWindowWidth: PropTypes.string,
|
|
99
115
|
onOpenChange: PropTypes.func
|
|
100
116
|
};
|
|
101
117
|
|
|
@@ -1,46 +1,32 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import PopUpSecurePayment from './PopUpSecurePayment';
|
|
3
|
-
import
|
|
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
|
-
`;
|
|
3
|
+
import { ExampleContainer } from '../PopUpShared.style';
|
|
36
4
|
|
|
37
5
|
export default function PopUpSecurePaymentExample() {
|
|
38
6
|
const [isOpen, setIsOpen] = useState(false);
|
|
39
7
|
|
|
40
8
|
return (
|
|
41
|
-
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
9
|
+
<>
|
|
10
|
+
<ExampleContainer $isOpen={isOpen}>
|
|
11
|
+
<h3>Default / no props, isOpen trigger</h3>
|
|
12
|
+
<PopUpSecurePayment onOpenChange={setIsOpen} />
|
|
13
|
+
</ExampleContainer>
|
|
14
|
+
|
|
15
|
+
<ExampleContainer>
|
|
16
|
+
<h3>Props: triggerText, openWindowWidth</h3>
|
|
17
|
+
<PopUpSecurePayment triggerText="Your payment is protected by 256-bit encryption" openWindowWidth="280px" />
|
|
18
|
+
</ExampleContainer>
|
|
19
|
+
|
|
20
|
+
<ExampleContainer>
|
|
21
|
+
<h3>Custom heading and paragraphs.</h3>
|
|
22
|
+
<PopUpSecurePayment
|
|
23
|
+
heading="Your details are safe with us"
|
|
24
|
+
paragraphs={[
|
|
25
|
+
'We only use your payment details to process your donation.',
|
|
26
|
+
'Card details are encrypted and never stored on our servers.'
|
|
27
|
+
]}
|
|
28
|
+
/>
|
|
29
|
+
</ExampleContainer>
|
|
30
|
+
</>
|
|
45
31
|
);
|
|
46
32
|
}
|
|
@@ -32,6 +32,28 @@ const closeOverlay = keyframes`
|
|
|
32
32
|
}
|
|
33
33
|
`;
|
|
34
34
|
|
|
35
|
+
const ExampleContainer = styled.div`
|
|
36
|
+
position: relative;
|
|
37
|
+
padding: 1rem;
|
|
38
|
+
min-height: 100px;
|
|
39
|
+
margin: 0 0 1rem auto;
|
|
40
|
+
border-radius: 6px;
|
|
41
|
+
background: light_grey;
|
|
42
|
+
min-height: 100px;
|
|
43
|
+
|
|
44
|
+
/* Shade over the wrapper's content while the popup is open */
|
|
45
|
+
&:before {
|
|
46
|
+
content: '';
|
|
47
|
+
position: absolute;
|
|
48
|
+
top: 0;
|
|
49
|
+
right: 0;
|
|
50
|
+
bottom: 0;
|
|
51
|
+
left: 0;
|
|
52
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
53
|
+
pointer-events: none;
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
|
|
35
57
|
const PopUpWindow = styled.div`
|
|
36
58
|
font-family: ${({ theme }) => theme.fontFamilies('Montserrat')};
|
|
37
59
|
background-color: ${({ theme, $backgroundColour }) => theme.color($backgroundColour)};
|
|
@@ -68,6 +90,7 @@ const PopUpWindow = styled.div`
|
|
|
68
90
|
@media (prefers-reduced-motion: reduce) {
|
|
69
91
|
animation: none;
|
|
70
92
|
}
|
|
93
|
+
margin-top: 1rem;
|
|
71
94
|
`}
|
|
72
95
|
|
|
73
96
|
${({ $isClosing }) => $isClosing && css`
|
|
@@ -79,6 +102,22 @@ const PopUpWindow = styled.div`
|
|
|
79
102
|
`}
|
|
80
103
|
`;
|
|
81
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Covers the whole visible window while a popup is open. Fixed positioning
|
|
107
|
+
* is relative to the viewport, so it is not limited to the parent container
|
|
108
|
+
* (it only is if an ancestor uses transform, filter or similar)
|
|
109
|
+
*/
|
|
110
|
+
const PageOverlay = styled.div`
|
|
111
|
+
position: fixed;
|
|
112
|
+
top: 0;
|
|
113
|
+
right: 0;
|
|
114
|
+
bottom: 0;
|
|
115
|
+
left: 0;
|
|
116
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
117
|
+
pointer-events: none;
|
|
118
|
+
${zIndex('medium')}
|
|
119
|
+
`;
|
|
120
|
+
|
|
82
121
|
const Container = styled.div`
|
|
83
122
|
position: relative;
|
|
84
123
|
width: 100%;
|
|
@@ -140,5 +179,12 @@ const PopUpBodyText = styled.p`
|
|
|
140
179
|
`;
|
|
141
180
|
|
|
142
181
|
export {
|
|
143
|
-
Container,
|
|
182
|
+
Container,
|
|
183
|
+
Trigger,
|
|
184
|
+
CloseButton,
|
|
185
|
+
PopUpWindow,
|
|
186
|
+
PopUpHeading,
|
|
187
|
+
PopUpBodyText,
|
|
188
|
+
PageOverlay,
|
|
189
|
+
ExampleContainer
|
|
144
190
|
};
|