@comicrelief/component-library 8.55.0 → 8.55.2
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/Molecules/HeroBanner/HeroBanner.style.js +68 -62
- package/dist/components/Molecules/HeroBanner/__snapshots__/HeroBanner.test.js.snap +7 -4
- package/dist/components/Organisms/DonateBanner/DonateBanner.js +12 -10
- package/dist/components/Organisms/DonateBanner/DonateBanner.md +24 -2
- package/dist/components/Organisms/DonateBanner/DonateBanner.style.js +34 -39
- package/dist/components/Organisms/DonateBanner/Form/Form.js +21 -26
- package/dist/components/Organisms/DonateBanner/GivingSelector/GivingSelector.js +1 -3
- package/dist/components/Organisms/DonateBanner/GivingSelector/GivingSelector.style.js +43 -7
- package/dist/components/Organisms/DonateBanner/MoneyBuy/MoneyBuy.js +20 -10
- package/dist/components/Organisms/DonateBanner/__snapshots__/DonateBanner.test.js.snap +355 -316
- package/dist/theme/shared/animations.js +9 -0
- package/package.json +1 -1
- package/src/components/Molecules/HeroBanner/HeroBanner.style.js +4 -3
- package/src/components/Molecules/HeroBanner/__snapshots__/HeroBanner.test.js.snap +7 -4
- package/src/components/Organisms/DonateBanner/DonateBanner.js +15 -11
- package/src/components/Organisms/DonateBanner/DonateBanner.md +24 -2
- package/src/components/Organisms/DonateBanner/DonateBanner.style.js +12 -12
- package/src/components/Organisms/DonateBanner/Form/Form.js +41 -32
- package/src/components/Organisms/DonateBanner/GivingSelector/GivingSelector.js +2 -4
- package/src/components/Organisms/DonateBanner/GivingSelector/GivingSelector.style.js +20 -3
- package/src/components/Organisms/DonateBanner/MoneyBuy/MoneyBuy.js +9 -1
- package/src/components/Organisms/DonateBanner/__snapshots__/DonateBanner.test.js.snap +355 -316
- package/src/theme/shared/animations.js +24 -1
|
@@ -67,18 +67,27 @@ const formFieldInputAnimation = function () {
|
|
|
67
67
|
* @param {boolean} animateScale - Whether to enable the scale animation
|
|
68
68
|
* @param {number} pixelMovement - Amount of movement to apply on hover
|
|
69
69
|
* @param {number} bounceIntensity - Intensity of the springy bounce effect (0-3, default: 1)
|
|
70
|
+
* @param {boolean} targetChild - Where to apply the transform
|
|
71
|
+
|
|
70
72
|
* @returns {css} template literal for the animation
|
|
71
73
|
*/
|
|
72
74
|
exports.formFieldInputAnimation = formFieldInputAnimation;
|
|
73
75
|
const bounceUpAnimation = function (animateScale) {
|
|
74
76
|
let pixelMovement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
75
77
|
let bounceIntensity = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
78
|
+
let targetChild = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
76
79
|
if (!animateScale) {
|
|
77
80
|
return (0, _styledComponents.css)([""]);
|
|
78
81
|
}
|
|
79
82
|
const pullBack = -0.55 - bounceIntensity * 0.3;
|
|
80
83
|
const overshoot = 1.55 + bounceIntensity * 0.4;
|
|
81
84
|
const duration = 0.2 + bounceIntensity * 0.1;
|
|
85
|
+
|
|
86
|
+
// The Hero Banner requires us to apply the transform inside
|
|
87
|
+
// the anchor, in order to address the 'infinity bounce' bug
|
|
88
|
+
if (targetChild) {
|
|
89
|
+
return (0, _styledComponents.css)(["> div{transition:transform ", "s cubic-bezier(0.68,", ",0.265,", ");transform-origin:center;}&:hover,&:focus{> div{transform:translateY(-", "px);}}"], duration, pullBack, overshoot, pixelMovement);
|
|
90
|
+
}
|
|
82
91
|
return (0, _styledComponents.css)(["transition:transform ", "s cubic-bezier(0.68,", ",0.265,", ");transform-origin:center;&:hover,&:focus{transform:translateY(-", "px);}"], duration, pullBack, overshoot, pixelMovement);
|
|
83
92
|
};
|
|
84
93
|
exports.bounceUpAnimation = bounceUpAnimation;
|
package/package.json
CHANGED
|
@@ -30,6 +30,7 @@ const Container = styled.div`
|
|
|
30
30
|
flex-direction: column;
|
|
31
31
|
background: ${({ theme, pageBackgroundColour }) => theme.color(pageBackgroundColour)};
|
|
32
32
|
justify-content: center;
|
|
33
|
+
${({ paddingTop, paddingBottom }) => css`padding: ${paddingTop} 0 ${paddingBottom};`}
|
|
33
34
|
|
|
34
35
|
${({ variant, paddingTop, paddingBottom }) => (variant === variants.TEXT_BANNER && css`
|
|
35
36
|
padding: ${paddingTop} 1rem ${paddingBottom};
|
|
@@ -100,11 +101,11 @@ const CopyOuterWrapper = styled.div`
|
|
|
100
101
|
display: flex;
|
|
101
102
|
width: calc(100% - (2 * 1rem));
|
|
102
103
|
|
|
103
|
-
${({ variant }) => (variant !== variants.TEXT_BANNER ? 'margin: -2rem 1rem
|
|
104
|
+
${({ variant }) => (variant !== variants.TEXT_BANNER ? 'margin: -2rem 1rem 0;' : 'margin: 0; width: 100%;')}
|
|
104
105
|
|
|
105
106
|
@media ${({ theme }) => theme.breakpoints2026('M')} {
|
|
106
107
|
${({ variant }) => (variant !== variants.TEXT_BANNER
|
|
107
|
-
? 'margin: -2rem 2rem
|
|
108
|
+
? 'margin: -2rem 2rem 0rem; width: calc(100% - (2 * 2rem));'
|
|
108
109
|
: 'margin: 0; width: 100%;')}
|
|
109
110
|
}
|
|
110
111
|
|
|
@@ -237,7 +238,7 @@ const HeroBannerLink = styled.a`
|
|
|
237
238
|
|
|
238
239
|
@media ${({ theme }) => theme.breakpoints2026('L')} {
|
|
239
240
|
|
|
240
|
-
${bounceUpAnimation(true, 10, 2)}
|
|
241
|
+
${bounceUpAnimation(true, 10, 2, true)}
|
|
241
242
|
|
|
242
243
|
// As the link is now wrapping the content, it'll take over width duties from 'Copy':
|
|
243
244
|
width: ${({ variant }) => (variant !== variants.TEXT_BANNER ? '92%' : '100%')};
|
|
@@ -73,6 +73,7 @@ exports[`renders "Full Height Media" Hero Banner correctly 1`] = `
|
|
|
73
73
|
-webkit-justify-content: center;
|
|
74
74
|
-ms-flex-pack: center;
|
|
75
75
|
justify-content: center;
|
|
76
|
+
padding: 0rem 0 2rem;
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
.c1 {
|
|
@@ -107,7 +108,7 @@ exports[`renders "Full Height Media" Hero Banner correctly 1`] = `
|
|
|
107
108
|
display: -ms-flexbox;
|
|
108
109
|
display: flex;
|
|
109
110
|
width: calc(100% - (2 * 1rem));
|
|
110
|
-
margin: -2rem 1rem
|
|
111
|
+
margin: -2rem 1rem 0;
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
.c7 {
|
|
@@ -211,7 +212,7 @@ exports[`renders "Full Height Media" Hero Banner correctly 1`] = `
|
|
|
211
212
|
|
|
212
213
|
@media (min-width:740px) {
|
|
213
214
|
.c5 {
|
|
214
|
-
margin: -2rem 2rem
|
|
215
|
+
margin: -2rem 2rem 0rem;
|
|
215
216
|
width: calc(100% - (2 * 2rem));
|
|
216
217
|
}
|
|
217
218
|
}
|
|
@@ -394,6 +395,7 @@ exports[`renders "Half Height Media" Hero Banner correctly 1`] = `
|
|
|
394
395
|
-webkit-justify-content: center;
|
|
395
396
|
-ms-flex-pack: center;
|
|
396
397
|
justify-content: center;
|
|
398
|
+
padding: 0rem 0 2rem;
|
|
397
399
|
}
|
|
398
400
|
|
|
399
401
|
.c1 {
|
|
@@ -428,7 +430,7 @@ exports[`renders "Half Height Media" Hero Banner correctly 1`] = `
|
|
|
428
430
|
display: -ms-flexbox;
|
|
429
431
|
display: flex;
|
|
430
432
|
width: calc(100% - (2 * 1rem));
|
|
431
|
-
margin: -2rem 1rem
|
|
433
|
+
margin: -2rem 1rem 0;
|
|
432
434
|
}
|
|
433
435
|
|
|
434
436
|
.c7 {
|
|
@@ -532,7 +534,7 @@ exports[`renders "Half Height Media" Hero Banner correctly 1`] = `
|
|
|
532
534
|
|
|
533
535
|
@media (min-width:740px) {
|
|
534
536
|
.c5 {
|
|
535
|
-
margin: -2rem 2rem
|
|
537
|
+
margin: -2rem 2rem 0rem;
|
|
536
538
|
width: calc(100% - (2 * 2rem));
|
|
537
539
|
}
|
|
538
540
|
}
|
|
@@ -700,6 +702,7 @@ exports[`renders "Text Banner" Hero Banner correctly 1`] = `
|
|
|
700
702
|
-webkit-justify-content: center;
|
|
701
703
|
-ms-flex-pack: center;
|
|
702
704
|
justify-content: center;
|
|
705
|
+
padding: 0rem 0 2rem;
|
|
703
706
|
padding: 0rem 1rem 2rem;
|
|
704
707
|
}
|
|
705
708
|
|
|
@@ -28,7 +28,6 @@ const DonateBanner = ({
|
|
|
28
28
|
subtitle = '',
|
|
29
29
|
monthlyTitle = '',
|
|
30
30
|
monthlySubtitle = '',
|
|
31
|
-
popUpText = 'Help us deliver long-term impact by converting your single donation into a monthly gift.',
|
|
32
31
|
chooseAmountText = null,
|
|
33
32
|
monthlyChooseAmountText = null,
|
|
34
33
|
otherAmountText = 'will help us fund amazing projects in the UK and around the world.',
|
|
@@ -43,7 +42,7 @@ const DonateBanner = ({
|
|
|
43
42
|
donateLink,
|
|
44
43
|
mbshipID
|
|
45
44
|
}) => {
|
|
46
|
-
const
|
|
45
|
+
const isLargeBreakpoint = useMediaQuery({ query: `(min-width: ${breakpointValues.L}px)` });
|
|
47
46
|
const isMedium = useMediaQuery({ query: `(min-width: ${breakpointValues.M}px)` });
|
|
48
47
|
const [givingType, setGivingType] = useState();
|
|
49
48
|
|
|
@@ -61,18 +60,21 @@ const DonateBanner = ({
|
|
|
61
60
|
const shouldShowImage = donateWidgetIsTextOnly === false;
|
|
62
61
|
|
|
63
62
|
const shouldShowDesktopImage = shouldShowImage
|
|
64
|
-
&&
|
|
63
|
+
&& isLargeBreakpoint && imageL
|
|
65
64
|
&& (imageL.images || imageL.image);
|
|
66
65
|
|
|
67
|
-
const shouldShowTopImage = shouldShowImage && !
|
|
66
|
+
const shouldShowTopImage = shouldShowImage && !isLargeBreakpoint;
|
|
68
67
|
const topImage = isMedium ? imageM : imageS;
|
|
69
68
|
|
|
70
|
-
const shouldRenderTopImage =
|
|
71
|
-
|
|
69
|
+
const shouldRenderTopImage = !!(
|
|
70
|
+
shouldShowTopImage
|
|
71
|
+
&& topImage && (topImage.images || topImage.image)
|
|
72
|
+
);
|
|
72
73
|
|
|
73
74
|
// For text-only variants, we hide the title area on non-desktop widths
|
|
74
75
|
// (M and below), so only the form is shown.
|
|
75
|
-
const shouldShowTitleSection = noTitlesAtAll === false
|
|
76
|
+
const shouldShowTitleSection = noTitlesAtAll === false
|
|
77
|
+
&& isLargeBreakpoint && donateWidgetIsTextOnly;
|
|
76
78
|
|
|
77
79
|
return (
|
|
78
80
|
<Container
|
|
@@ -125,8 +127,7 @@ const DonateBanner = ({
|
|
|
125
127
|
{showCopy && (
|
|
126
128
|
<>
|
|
127
129
|
<Text
|
|
128
|
-
tag="
|
|
129
|
-
size="big"
|
|
130
|
+
tag="h1"
|
|
130
131
|
family="Anton"
|
|
131
132
|
weight="normal"
|
|
132
133
|
>
|
|
@@ -149,7 +150,6 @@ const DonateBanner = ({
|
|
|
149
150
|
mbshipID={mbshipID}
|
|
150
151
|
donateLink={donateLink}
|
|
151
152
|
hideMoneyBuys={hideMoneyBuys}
|
|
152
|
-
popUpText={popUpText}
|
|
153
153
|
chooseAmountText={chooseAmountText}
|
|
154
154
|
monthlyChooseAmountText={monthlyChooseAmountText}
|
|
155
155
|
donateWidgetIsTextOnly={donateWidgetIsTextOnly}
|
|
@@ -158,6 +158,11 @@ const DonateBanner = ({
|
|
|
158
158
|
donateOrientation={donateOrientation}
|
|
159
159
|
givingType={givingType}
|
|
160
160
|
changeGivingType={setGivingType}
|
|
161
|
+
thisTitle={thisTitle}
|
|
162
|
+
thisSubtitle={thisSubtitle}
|
|
163
|
+
showCopy={showCopy}
|
|
164
|
+
isLargeBreakpoint={isLargeBreakpoint}
|
|
165
|
+
isMediumBreakpoint={isMedium}
|
|
161
166
|
/>
|
|
162
167
|
</Wrapper>
|
|
163
168
|
</InnerContainer>
|
|
@@ -176,7 +181,6 @@ DonateBanner.propTypes = {
|
|
|
176
181
|
subtitle: PropTypes.string,
|
|
177
182
|
monthlyTitle: PropTypes.string,
|
|
178
183
|
monthlySubtitle: PropTypes.string,
|
|
179
|
-
popUpText: PropTypes.string,
|
|
180
184
|
chooseAmountText: PropTypes.string,
|
|
181
185
|
monthlyChooseAmountText: PropTypes.string,
|
|
182
186
|
otherAmountText: PropTypes.string,
|
|
@@ -87,7 +87,6 @@ const imageS = {
|
|
|
87
87
|
monthlySubtitle="A regular gift helps fund long-term impact."
|
|
88
88
|
chooseAmountText="Choose a one-off amount"
|
|
89
89
|
monthlyChooseAmountText="Choose a monthly amount"
|
|
90
|
-
popUpText="Switching to a single gift means less predictable funding."
|
|
91
90
|
/>;
|
|
92
91
|
```
|
|
93
92
|
|
|
@@ -137,7 +136,30 @@ import data from './dev-data/data';
|
|
|
137
136
|
/>;
|
|
138
137
|
```
|
|
139
138
|
|
|
140
|
-
##
|
|
139
|
+
## Text-only widget (no image), with giving selector (single vs monthly)
|
|
140
|
+
|
|
141
|
+
```js
|
|
142
|
+
import data from './dev-data/data';
|
|
143
|
+
|
|
144
|
+
<DonateBanner
|
|
145
|
+
donateWidgetIsTextOnly
|
|
146
|
+
pageBackgroundColour="grey_light"
|
|
147
|
+
paddingAbove="2rem"
|
|
148
|
+
paddingBelow="2rem"
|
|
149
|
+
donateOrientation="right"
|
|
150
|
+
data={data}
|
|
151
|
+
mbshipID="mbship-3c"
|
|
152
|
+
donateLink="https://donation.comicrelief.com/"
|
|
153
|
+
clientID="donate"
|
|
154
|
+
cartID="default-comicrelief"
|
|
155
|
+
title="Donate now"
|
|
156
|
+
subtitle="Choose between a one-off or monthly gift."
|
|
157
|
+
monthlyTitle="Give monthly"
|
|
158
|
+
monthlySubtitle="A regular gift helps fund long-term impact."
|
|
159
|
+
/>;
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Different "Other amount" copy for single vs monthly
|
|
141
163
|
|
|
142
164
|
```js
|
|
143
165
|
import data from './dev-data/data';
|
|
@@ -27,6 +27,7 @@ const InnerContainer = styled.div`
|
|
|
27
27
|
padding: none;
|
|
28
28
|
width: 100%;
|
|
29
29
|
box-sizing: border-box;
|
|
30
|
+
box-shadow: 0px 0px 16px rgba(0, 0, 0, 0.15);
|
|
30
31
|
@media ${({ theme }) => theme.allBreakpoints('L')} {
|
|
31
32
|
padding: ${spacing('l')};
|
|
32
33
|
${({ $donateWidgetIsTextOnly }) => $donateWidgetIsTextOnly && css`
|
|
@@ -148,7 +149,7 @@ const Form = styled.form`
|
|
|
148
149
|
|
|
149
150
|
@media ${({ theme }) => theme.allBreakpoints('L')} {
|
|
150
151
|
margin-top: ${spacing('md')};
|
|
151
|
-
border-radius:
|
|
152
|
+
border-radius: 1rem;
|
|
152
153
|
max-width: 461px;
|
|
153
154
|
min-width: 400px;
|
|
154
155
|
/* Alignment is handled by the outer wrapper on desktop. */
|
|
@@ -159,7 +160,7 @@ const Form = styled.form`
|
|
|
159
160
|
|
|
160
161
|
const OuterFieldset = styled.fieldset`
|
|
161
162
|
color: ${({ theme }) => theme.color('black')};
|
|
162
|
-
padding:
|
|
163
|
+
padding: ${spacing('m')};
|
|
163
164
|
margin: 0;
|
|
164
165
|
border: none;
|
|
165
166
|
@media ${({ theme }) => theme.allBreakpoints('M')} {
|
|
@@ -181,7 +182,6 @@ const Legend = styled.legend`
|
|
|
181
182
|
const PrimaryTitleText = styled(Text)`
|
|
182
183
|
display: block;
|
|
183
184
|
text-align: left;
|
|
184
|
-
font-size: ${({ theme }) => theme.fontSize('s')};
|
|
185
185
|
font-weight: 700;
|
|
186
186
|
`;
|
|
187
187
|
|
|
@@ -190,7 +190,7 @@ const SecondaryTitleText = styled(Text)`
|
|
|
190
190
|
text-align: left;
|
|
191
191
|
font-size: ${({ theme }) => theme.fontSize('s')};
|
|
192
192
|
line-height: 1.5;
|
|
193
|
-
margin
|
|
193
|
+
margin: ${spacing('sm')} 0 !important;
|
|
194
194
|
`;
|
|
195
195
|
|
|
196
196
|
const MoneyBuys = styled.div`
|
|
@@ -266,20 +266,24 @@ const AmountField = styled(Input)`
|
|
|
266
266
|
}
|
|
267
267
|
`;
|
|
268
268
|
|
|
269
|
-
const
|
|
269
|
+
const MoneybuyCopy = styled.p`
|
|
270
270
|
line-height: 1.5;
|
|
271
271
|
margin-top: ${spacing('l')};
|
|
272
272
|
color: ${({ theme }) => theme.color('black')};
|
|
273
|
+
margin: ${spacing('md')} 0 ${spacing('sm')};
|
|
274
|
+
@media ${({ theme }) => theme.allBreakpoints('M')} {
|
|
275
|
+
margin: ${spacing('m')} 0 ${spacing('md')};
|
|
276
|
+
}
|
|
273
277
|
`;
|
|
274
278
|
|
|
275
279
|
const Button = styled.button`
|
|
276
280
|
width: 100%;
|
|
277
|
-
margin: ${spacing('
|
|
281
|
+
margin-top: ${spacing('md')};
|
|
278
282
|
color: ${({ theme }) => theme.color('white')};
|
|
279
283
|
font-size: ${({ theme }) => theme.fontSize('s')};
|
|
280
284
|
font-weight: bold;
|
|
285
|
+
min-height: 44px;
|
|
281
286
|
cursor: pointer;
|
|
282
|
-
min-height: 48px;
|
|
283
287
|
background: ${({ theme, color }) => theme.color(color)};
|
|
284
288
|
text-decoration: none;
|
|
285
289
|
border-radius: 0.5rem;
|
|
@@ -291,16 +295,12 @@ const Button = styled.button`
|
|
|
291
295
|
outline: none;
|
|
292
296
|
background-color: ${({ theme }) => theme.color('coral_dark')};
|
|
293
297
|
}
|
|
294
|
-
|
|
295
|
-
@media ${({ theme }) => theme.allBreakpoints('M')} {
|
|
296
|
-
padding: ${spacing('md')} ${spacing('l')};
|
|
297
|
-
}
|
|
298
298
|
`;
|
|
299
299
|
|
|
300
300
|
export {
|
|
301
301
|
BgImage,
|
|
302
302
|
Button,
|
|
303
|
-
|
|
303
|
+
MoneybuyCopy,
|
|
304
304
|
Container,
|
|
305
305
|
InnerContainer,
|
|
306
306
|
Error,
|
|
@@ -3,7 +3,6 @@ import React, {
|
|
|
3
3
|
} from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
|
|
6
|
-
import PopUpComponent from './PopUpComponent';
|
|
7
6
|
import MoneyBuy from '../MoneyBuy/MoneyBuy';
|
|
8
7
|
import {
|
|
9
8
|
handleDonateSubmission,
|
|
@@ -12,7 +11,7 @@ import {
|
|
|
12
11
|
} from '../../../../utils/Membership';
|
|
13
12
|
import {
|
|
14
13
|
Button,
|
|
15
|
-
|
|
14
|
+
MoneybuyCopy,
|
|
16
15
|
Error,
|
|
17
16
|
FormFieldset,
|
|
18
17
|
FormWrapper,
|
|
@@ -22,7 +21,8 @@ import {
|
|
|
22
21
|
AmountField,
|
|
23
22
|
OuterFieldset,
|
|
24
23
|
Legend,
|
|
25
|
-
PrimaryTitleText
|
|
24
|
+
PrimaryTitleText,
|
|
25
|
+
SecondaryTitleText
|
|
26
26
|
} from '../DonateBanner.style';
|
|
27
27
|
import GivingSelector from '../GivingSelector/GivingSelector';
|
|
28
28
|
|
|
@@ -35,22 +35,22 @@ const Signup = ({
|
|
|
35
35
|
mbshipID,
|
|
36
36
|
donateOrientation = 'right',
|
|
37
37
|
noMoneyBuys = false,
|
|
38
|
-
popUpText,
|
|
39
|
-
chooseAmountText = null,
|
|
40
|
-
monthlyChooseAmountText = null,
|
|
41
38
|
submitButtonColor = 'red',
|
|
42
39
|
changeGivingType,
|
|
43
40
|
givingType = null,
|
|
44
41
|
hasTopImage = false,
|
|
45
42
|
shouldShowTitleSection = false,
|
|
43
|
+
donateWidgetIsTextOnly = false,
|
|
44
|
+
thisTitle = null,
|
|
45
|
+
thisSubtitle = null,
|
|
46
|
+
showCopy = false,
|
|
47
|
+
isLargeBreakpoint = false,
|
|
48
|
+
isMediumBreakpoint = false,
|
|
46
49
|
...rest
|
|
47
50
|
}) => {
|
|
48
51
|
const [errorMsg, setErrorMsg] = useState(false);
|
|
49
52
|
const [amountDonate, setAmountDonate] = useState(10);
|
|
50
53
|
const [moneyBuyCopy, setMoneyBuyCopy] = useState(true);
|
|
51
|
-
const [popOpen, setPopOpen] = useState(false);
|
|
52
|
-
// In order to keep track of whether the user has ever been shown the popup
|
|
53
|
-
const [popUpShown, setPopUpShown] = useState(false);
|
|
54
54
|
|
|
55
55
|
useEffect(() => {
|
|
56
56
|
if (givingType) {
|
|
@@ -108,12 +108,6 @@ const Signup = ({
|
|
|
108
108
|
noMoneyBuys
|
|
109
109
|
]);
|
|
110
110
|
|
|
111
|
-
// Updates our flag that differentiates between the popup
|
|
112
|
-
// being *currently* open and it *ever* having been shown to user
|
|
113
|
-
useEffect(() => {
|
|
114
|
-
if (popOpen && !popUpShown) setPopUpShown(true);
|
|
115
|
-
}, [popOpen, popUpShown]);
|
|
116
|
-
|
|
117
111
|
// On load, determine what should actually be the default giving type
|
|
118
112
|
useEffect(() => {
|
|
119
113
|
const newGivingType = singleGiving !== null ? 'single' : 'monthly';
|
|
@@ -139,7 +133,7 @@ const Signup = ({
|
|
|
139
133
|
mbshipId,
|
|
140
134
|
donateURL,
|
|
141
135
|
givingType,
|
|
142
|
-
|
|
136
|
+
null
|
|
143
137
|
);
|
|
144
138
|
} else {
|
|
145
139
|
setErrorMsg(true);
|
|
@@ -198,18 +192,18 @@ const Signup = ({
|
|
|
198
192
|
return `Donate £${amountDonate} monthly`;
|
|
199
193
|
};
|
|
200
194
|
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
195
|
+
const shouldShowTitleInForm = showCopy && (
|
|
196
|
+
!donateWidgetIsTextOnly || (donateWidgetIsTextOnly && !isLargeBreakpoint)
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
// Use h1 tag for text-only version, p tag for image version
|
|
200
|
+
const titleTag = donateWidgetIsTextOnly ? 'h1' : 'p';
|
|
205
201
|
|
|
206
202
|
return (
|
|
207
203
|
<FormWrapper
|
|
208
204
|
donateOrientation={donateOrientation}
|
|
209
205
|
shouldShowTitleSection={shouldShowTitleSection}
|
|
210
206
|
>
|
|
211
|
-
{ popOpen && <PopUpComponent popUpText={popUpText} setPopOpen={setPopOpen} /> }
|
|
212
|
-
|
|
213
207
|
<Form
|
|
214
208
|
donateOrientation={donateOrientation}
|
|
215
209
|
hasTopImage={hasTopImage}
|
|
@@ -225,16 +219,26 @@ const Signup = ({
|
|
|
225
219
|
}
|
|
226
220
|
>
|
|
227
221
|
<OuterFieldset>
|
|
228
|
-
|
|
229
|
-
<
|
|
230
|
-
{
|
|
231
|
-
|
|
232
|
-
|
|
222
|
+
{shouldShowTitleInForm ? (
|
|
223
|
+
<Legend>
|
|
224
|
+
<PrimaryTitleText tag={titleTag} $donateWidgetIsTextOnly={donateWidgetIsTextOnly}>
|
|
225
|
+
{thisTitle}
|
|
226
|
+
</PrimaryTitleText>
|
|
227
|
+
{thisSubtitle && (
|
|
228
|
+
<SecondaryTitleText
|
|
229
|
+
tag="p"
|
|
230
|
+
$showGivingSelector={showGivingSelector}
|
|
231
|
+
$isMediumBreakpoint={isMediumBreakpoint}
|
|
232
|
+
>
|
|
233
|
+
{thisSubtitle}
|
|
234
|
+
</SecondaryTitleText>
|
|
235
|
+
)}
|
|
236
|
+
</Legend>
|
|
237
|
+
) : null}
|
|
233
238
|
{showGivingSelector && (
|
|
234
239
|
<GivingSelector
|
|
235
240
|
givingType={givingType}
|
|
236
241
|
changeGivingType={data => changeGivingType(data)}
|
|
237
|
-
setPopOpen={setPopOpen}
|
|
238
242
|
mbshipID={mbshipID}
|
|
239
243
|
/>
|
|
240
244
|
)}
|
|
@@ -281,10 +285,10 @@ const Signup = ({
|
|
|
281
285
|
/>
|
|
282
286
|
</FormFieldset>
|
|
283
287
|
{amountDonate >= 1 && moneyBuyCopy && (
|
|
284
|
-
<
|
|
288
|
+
<MoneybuyCopy>
|
|
285
289
|
<strong>{`£${amountDonate} `}</strong>
|
|
286
290
|
{moneyBuyCopy}
|
|
287
|
-
</
|
|
291
|
+
</MoneybuyCopy>
|
|
288
292
|
)}
|
|
289
293
|
|
|
290
294
|
{errorMsg && (
|
|
@@ -319,14 +323,19 @@ Signup.propTypes = {
|
|
|
319
323
|
donateOrientation: PropTypes.oneOf(['left', 'right']),
|
|
320
324
|
noMoneyBuys: PropTypes.bool,
|
|
321
325
|
data: PropTypes.objectOf(PropTypes.shape),
|
|
322
|
-
popUpText: PropTypes.string.isRequired,
|
|
323
326
|
chooseAmountText: PropTypes.string,
|
|
324
327
|
monthlyChooseAmountText: PropTypes.string,
|
|
325
328
|
submitButtonColor: PropTypes.string,
|
|
326
329
|
changeGivingType: PropTypes.func.isRequired,
|
|
327
330
|
givingType: PropTypes.string,
|
|
328
331
|
hasTopImage: PropTypes.bool,
|
|
329
|
-
shouldShowTitleSection: PropTypes.bool
|
|
332
|
+
shouldShowTitleSection: PropTypes.bool,
|
|
333
|
+
donateWidgetIsTextOnly: PropTypes.bool,
|
|
334
|
+
thisTitle: PropTypes.string,
|
|
335
|
+
thisSubtitle: PropTypes.string,
|
|
336
|
+
showCopy: PropTypes.bool,
|
|
337
|
+
isLargeBreakpoint: PropTypes.bool,
|
|
338
|
+
isMediumBreakpoint: PropTypes.bool
|
|
330
339
|
};
|
|
331
340
|
|
|
332
341
|
export default Signup;
|
|
@@ -6,13 +6,12 @@ import {
|
|
|
6
6
|
} from './GivingSelector.style';
|
|
7
7
|
|
|
8
8
|
const GivingSelector = ({
|
|
9
|
-
givingType = null, changeGivingType,
|
|
9
|
+
givingType = null, changeGivingType, mbshipID
|
|
10
10
|
}) => {
|
|
11
|
-
// Only updates giving type
|
|
11
|
+
// Only updates giving type when appropriate
|
|
12
12
|
const handleGivingTypeChange = (thisButtonType, currentGivingType) => {
|
|
13
13
|
if (currentGivingType !== thisButtonType) {
|
|
14
14
|
changeGivingType(thisButtonType);
|
|
15
|
-
setPopOpen(thisButtonType === 'single');
|
|
16
15
|
}
|
|
17
16
|
};
|
|
18
17
|
|
|
@@ -54,7 +53,6 @@ const GivingSelector = ({
|
|
|
54
53
|
GivingSelector.propTypes = {
|
|
55
54
|
givingType: PropTypes.string,
|
|
56
55
|
changeGivingType: PropTypes.func.isRequired,
|
|
57
|
-
setPopOpen: PropTypes.func.isRequired,
|
|
58
56
|
mbshipID: PropTypes.string.isRequired
|
|
59
57
|
};
|
|
60
58
|
|
|
@@ -27,7 +27,6 @@ const MoneyBox = styled.div`
|
|
|
27
27
|
margin: ${spacing('sm')} 0;
|
|
28
28
|
overflow: hidden;
|
|
29
29
|
border-radius: 0.5rem;
|
|
30
|
-
border: 1px solid ${({ theme }) => theme.color('grey')};
|
|
31
30
|
background: ${({ theme }) => theme.color('white')};
|
|
32
31
|
@media ${({ theme }) => theme.allBreakpoints('M')} {
|
|
33
32
|
margin: 0 auto;
|
|
@@ -38,6 +37,10 @@ const MoneyBox = styled.div`
|
|
|
38
37
|
input {
|
|
39
38
|
${hideVisually}
|
|
40
39
|
}
|
|
40
|
+
input:focus-visible + label {
|
|
41
|
+
${zIndex('high')};
|
|
42
|
+
box-shadow: inset 0 0 0 2px ${({ theme }) => theme.color('blue_donate')}};
|
|
43
|
+
}
|
|
41
44
|
`;
|
|
42
45
|
|
|
43
46
|
const Label = styled.label`
|
|
@@ -53,15 +56,29 @@ const Label = styled.label`
|
|
|
53
56
|
transition: color 0.15s ease-out;
|
|
54
57
|
${zIndex('medium')};
|
|
55
58
|
cursor: ${({ active }) => (active === true ? 'default' : 'pointer')};
|
|
56
|
-
border-radius: 2rem;
|
|
57
59
|
color: ${({ active, theme }) => (active === true ? theme.color('white') : theme.color('black'))};
|
|
58
60
|
|
|
61
|
+
/* All this long winded border CSS below is to ensure that the border
|
|
62
|
+
of the 'selected' giving type is red, rather than a grey line around
|
|
63
|
+
the whole outside */
|
|
64
|
+
&:first-of-type {
|
|
65
|
+
border-left: 1px solid ${({ active, theme }) => (active ? theme.color('red') : theme.color('grey'))};
|
|
66
|
+
border-top: 1px solid ${({ active, theme }) => (active ? theme.color('red') : theme.color('grey'))};
|
|
67
|
+
border-bottom: 1px solid ${({ active, theme }) => (active ? theme.color('red') : theme.color('grey'))};
|
|
68
|
+
border-radius: 0.5rem 0 0 0.5rem;
|
|
69
|
+
}
|
|
70
|
+
&:last-of-type {
|
|
71
|
+
border-right: 1px solid ${({ active, theme }) => (active ? theme.color('red') : theme.color('grey'))};
|
|
72
|
+
border-top: 1px solid ${({ active, theme }) => (active ? theme.color('red') : theme.color('grey'))};
|
|
73
|
+
border-bottom: 1px solid ${({ active, theme }) => (active ? theme.color('red') : theme.color('grey'))};
|
|
74
|
+
border-radius: 0 0.5rem 0.5rem 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
59
77
|
&:active:focus {
|
|
60
78
|
box-shadow: none;
|
|
61
79
|
}
|
|
62
80
|
&:focus {
|
|
63
81
|
border: none;
|
|
64
|
-
outline: none;
|
|
65
82
|
box-shadow: inset 0 0 0 4px ${({ theme }) => theme.color('red')};
|
|
66
83
|
}
|
|
67
84
|
`;
|
|
@@ -14,12 +14,20 @@ const MoneyBuyButton = styled(Input)`
|
|
|
14
14
|
font-family: ${({ theme }) => theme.fontFamilies('Anton')};
|
|
15
15
|
font-weight: normal;
|
|
16
16
|
border-radius: 0.5rem;
|
|
17
|
-
height:
|
|
17
|
+
height: 3.75rem;
|
|
18
18
|
border: 1px solid ${({ theme }) => theme.color('grey')};
|
|
19
19
|
&:focus {
|
|
20
20
|
border: 1px solid ${({ theme }) => theme.color('red')};
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
@media ${({ theme }) => theme.allBreakpoints('M')} {
|
|
24
|
+
height: 4.5rem;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@media ${({ theme }) => theme.allBreakpoints('L')} {
|
|
28
|
+
height: 3.4375rem;
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
${({ isSelected }) => isSelected
|
|
24
32
|
&& css`
|
|
25
33
|
background-color: ${({ theme }) => theme.color('red')};
|