@comicrelief/component-library 7.24.2 → 7.26.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/components/Organisms/Donate/Donate.js +12 -3
- package/dist/components/Organisms/Donate/Donate.md +140 -0
- package/dist/components/Organisms/Donate/Form/Form.js +44 -19
- package/dist/components/Organisms/Donate/GivingSelector/GivingSelector.js +3 -0
- package/dist/components/Organisms/Donate/__snapshots__/Donate.test.js.snap +84 -300
- package/dist/components/Organisms/Donate/dev-data/data-monthly.js +22 -0
- package/package.json +1 -1
- package/src/components/Organisms/Donate/Donate.js +15 -3
- package/src/components/Organisms/Donate/Donate.md +140 -0
- package/src/components/Organisms/Donate/Form/Form.js +60 -25
- package/src/components/Organisms/Donate/GivingSelector/GivingSelector.js +5 -1
- package/src/components/Organisms/Donate/__snapshots__/Donate.test.js.snap +84 -300
- package/src/components/Organisms/Donate/dev-data/data-monthly.js +23 -0
|
@@ -40,7 +40,10 @@ const Donate = _ref => {
|
|
|
40
40
|
PopUpText,
|
|
41
41
|
chooseAmountText,
|
|
42
42
|
isDesktopOverride,
|
|
43
|
-
otherAmountValue
|
|
43
|
+
otherAmountValue,
|
|
44
|
+
additionalSingleCopy,
|
|
45
|
+
additionalMonthlyCopy,
|
|
46
|
+
defaultGivingType
|
|
44
47
|
} = _ref;
|
|
45
48
|
let isDesktop = (0, _reactResponsive.useMediaQuery)({
|
|
46
49
|
query: "(min-width: ".concat(_size.screen.medium, ")")
|
|
@@ -107,7 +110,10 @@ const Donate = _ref => {
|
|
|
107
110
|
PopUpText: PopUpText,
|
|
108
111
|
chooseAmountText: chooseAmountText,
|
|
109
112
|
submitButtonColor: submitButtonColor,
|
|
110
|
-
otherAmountValue: otherAmountValue
|
|
113
|
+
otherAmountValue: otherAmountValue,
|
|
114
|
+
additionalSingleCopy: additionalSingleCopy,
|
|
115
|
+
additionalMonthlyCopy: additionalMonthlyCopy,
|
|
116
|
+
defaultGivingType: defaultGivingType
|
|
111
117
|
})));
|
|
112
118
|
};
|
|
113
119
|
Donate.defaultProps = {
|
|
@@ -133,6 +139,9 @@ Donate.defaultProps = {
|
|
|
133
139
|
chooseAmountText: '',
|
|
134
140
|
isDesktopOverride: null,
|
|
135
141
|
otherAmountValue: null,
|
|
136
|
-
title: null
|
|
142
|
+
title: null,
|
|
143
|
+
additionalSingleCopy: null,
|
|
144
|
+
additionalMonthlyCopy: null,
|
|
145
|
+
defaultGivingType: null
|
|
137
146
|
};
|
|
138
147
|
var _default = exports.default = Donate;
|
|
@@ -354,3 +354,143 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
354
354
|
isDesktopOverride={false}
|
|
355
355
|
/>;
|
|
356
356
|
```
|
|
357
|
+
|
|
358
|
+
## Additional copy for BOTH giving types
|
|
359
|
+
|
|
360
|
+
```js
|
|
361
|
+
import data from './dev-data/data';
|
|
362
|
+
const mobilePictures = require('../../../styleguide/data/data').mobileImages;
|
|
363
|
+
const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
364
|
+
|
|
365
|
+
<Donate
|
|
366
|
+
alt="Background image"
|
|
367
|
+
mobileBackgroundColor="deep_violet_dark"
|
|
368
|
+
desktopOverlayColor="red"
|
|
369
|
+
submitButtonColor="blue_dark"
|
|
370
|
+
formAlignRight={true}
|
|
371
|
+
imageLow={desktopPictures.imageLow}
|
|
372
|
+
images={desktopPictures.images}
|
|
373
|
+
mobileImageLow={mobilePictures.imageLow}
|
|
374
|
+
mobileImages={mobilePictures.images}
|
|
375
|
+
data={data}
|
|
376
|
+
mbshipID="mship-11"
|
|
377
|
+
donateLink="https://donation.comicrelief.com/"
|
|
378
|
+
clientID="donate"
|
|
379
|
+
cartID="default-comicrelief"
|
|
380
|
+
title="Donate Now"
|
|
381
|
+
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
382
|
+
additionalSingleCopy="Some additional single giving copy - Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa."
|
|
383
|
+
additionalMonthlyCopy="Some additional regular giving copy! - Quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos."
|
|
384
|
+
/>;
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## Additional copy for monthly only
|
|
388
|
+
|
|
389
|
+
```js
|
|
390
|
+
import data from './dev-data/data';
|
|
391
|
+
const mobilePictures = require('../../../styleguide/data/data').mobileImages;
|
|
392
|
+
const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
393
|
+
|
|
394
|
+
<Donate
|
|
395
|
+
alt="Background image"
|
|
396
|
+
mobileBackgroundColor="deep_violet_dark"
|
|
397
|
+
desktopOverlayColor="red"
|
|
398
|
+
submitButtonColor="blue_dark"
|
|
399
|
+
formAlignRight={true}
|
|
400
|
+
imageLow={desktopPictures.imageLow}
|
|
401
|
+
images={desktopPictures.images}
|
|
402
|
+
mobileImageLow={mobilePictures.imageLow}
|
|
403
|
+
mobileImages={mobilePictures.images}
|
|
404
|
+
data={data}
|
|
405
|
+
mbshipID="mship-12"
|
|
406
|
+
donateLink="https://donation.comicrelief.com/"
|
|
407
|
+
clientID="donate"
|
|
408
|
+
cartID="default-comicrelief"
|
|
409
|
+
title="Donate Now"
|
|
410
|
+
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
411
|
+
additionalMonthlyCopy="Some additional regular giving copy! - Quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos."
|
|
412
|
+
/>;
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
## Additional copy for single only
|
|
416
|
+
|
|
417
|
+
```js
|
|
418
|
+
import data from './dev-data/data';
|
|
419
|
+
const mobilePictures = require('../../../styleguide/data/data').mobileImages;
|
|
420
|
+
const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
421
|
+
|
|
422
|
+
<Donate
|
|
423
|
+
alt="Background image"
|
|
424
|
+
mobileBackgroundColor="deep_violet_dark"
|
|
425
|
+
desktopOverlayColor="red"
|
|
426
|
+
submitButtonColor="blue_dark"
|
|
427
|
+
formAlignRight={true}
|
|
428
|
+
imageLow={desktopPictures.imageLow}
|
|
429
|
+
images={desktopPictures.images}
|
|
430
|
+
mobileImageLow={mobilePictures.imageLow}
|
|
431
|
+
mobileImages={mobilePictures.images}
|
|
432
|
+
data={data}
|
|
433
|
+
mbshipID="mship-13"
|
|
434
|
+
donateLink="https://donation.comicrelief.com/"
|
|
435
|
+
clientID="donate"
|
|
436
|
+
cartID="default-comicrelief"
|
|
437
|
+
title="Donate Now"
|
|
438
|
+
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
439
|
+
additionalSingleCopy="Some additional single giving copy - Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa."
|
|
440
|
+
/>;
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
## Default monthly giving type
|
|
444
|
+
|
|
445
|
+
```js
|
|
446
|
+
import data from './dev-data/data';
|
|
447
|
+
const mobilePictures = require('../../../styleguide/data/data').mobileImages;
|
|
448
|
+
const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
449
|
+
|
|
450
|
+
<Donate
|
|
451
|
+
alt="Background image"
|
|
452
|
+
mobileBackgroundColor="deep_violet_dark"
|
|
453
|
+
desktopOverlayColor="red"
|
|
454
|
+
submitButtonColor="blue_dark"
|
|
455
|
+
formAlignRight={true}
|
|
456
|
+
imageLow={desktopPictures.imageLow}
|
|
457
|
+
images={desktopPictures.images}
|
|
458
|
+
mobileImageLow={mobilePictures.imageLow}
|
|
459
|
+
mobileImages={mobilePictures.images}
|
|
460
|
+
data={data}
|
|
461
|
+
mbshipID="mship-14"
|
|
462
|
+
donateLink="https://donation.comicrelief.com/"
|
|
463
|
+
clientID="donate"
|
|
464
|
+
cartID="default-comicrelief"
|
|
465
|
+
title="Donate Now"
|
|
466
|
+
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
467
|
+
defaultGivingType="monthly"
|
|
468
|
+
/>;
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
## Monthly ONLY
|
|
472
|
+
|
|
473
|
+
```js
|
|
474
|
+
import data from './dev-data/data-monthly';
|
|
475
|
+
const mobilePictures = require('../../../styleguide/data/data').mobileImages;
|
|
476
|
+
const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
477
|
+
|
|
478
|
+
<Donate
|
|
479
|
+
alt="Background image"
|
|
480
|
+
mobileBackgroundColor="deep_violet_dark"
|
|
481
|
+
desktopOverlayColor="red"
|
|
482
|
+
submitButtonColor="blue_dark"
|
|
483
|
+
formAlignRight={true}
|
|
484
|
+
imageLow={desktopPictures.imageLow}
|
|
485
|
+
images={desktopPictures.images}
|
|
486
|
+
mobileImageLow={mobilePictures.imageLow}
|
|
487
|
+
mobileImages={mobilePictures.images}
|
|
488
|
+
data={data}
|
|
489
|
+
mbshipID="mship-15"
|
|
490
|
+
donateLink="https://donation.comicrelief.com/"
|
|
491
|
+
clientID="donate"
|
|
492
|
+
cartID="default-comicrelief"
|
|
493
|
+
title="Donate Now"
|
|
494
|
+
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
495
|
+
/>;
|
|
496
|
+
```
|
|
@@ -29,9 +29,12 @@ const Signup = _ref => {
|
|
|
29
29
|
chooseAmountText,
|
|
30
30
|
submitButtonColor,
|
|
31
31
|
otherAmountValue,
|
|
32
|
+
additionalSingleCopy,
|
|
33
|
+
additionalMonthlyCopy,
|
|
34
|
+
defaultGivingType,
|
|
32
35
|
...rest
|
|
33
36
|
} = _ref;
|
|
34
|
-
const [givingType, setGivingType] = (0, _react.useState)(
|
|
37
|
+
const [givingType, setGivingType] = (0, _react.useState)();
|
|
35
38
|
const [errorMsg, setErrorMsg] = (0, _react.useState)(false);
|
|
36
39
|
const [amountDonate, setAmountDonate] = (0, _react.useState)(10);
|
|
37
40
|
const [moneyBuyCopy, setMoneyBuyCopy] = (0, _react.useState)(true);
|
|
@@ -43,7 +46,7 @@ const Signup = _ref => {
|
|
|
43
46
|
// otherwise assign based on the associated moneybuys:
|
|
44
47
|
if (otherAmountValue) {
|
|
45
48
|
setAmountDonate(otherAmountValue);
|
|
46
|
-
} else {
|
|
49
|
+
} else if (givingType) {
|
|
47
50
|
const givingData = givingType === 'single' ? singleGiving : regularGiving;
|
|
48
51
|
|
|
49
52
|
// Check the 2nd moneybuy exists before using it;
|
|
@@ -54,20 +57,22 @@ const Signup = _ref => {
|
|
|
54
57
|
}
|
|
55
58
|
}, [givingType, singleGiving, regularGiving, otherAmountValue]);
|
|
56
59
|
(0, _react.useEffect)(() => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
if (givingType) {
|
|
61
|
+
const givingData = givingType === 'single' ? singleGiving : regularGiving;
|
|
62
|
+
let moneyBuyNewDescription = otherAmountText;
|
|
63
|
+
givingData.moneybuys.map((moneyBuy, index) => {
|
|
64
|
+
if (moneyBuy.value === amountDonate) {
|
|
65
|
+
moneyBuyNewDescription = moneyBuy.description;
|
|
66
|
+
}
|
|
67
|
+
return index === 1 && amountDonate === undefined && (setMoneyBuyCopy(moneyBuy.description), setAmountDonate(moneyBuy.value));
|
|
68
|
+
});
|
|
69
|
+
if (!(0, _Membership.isAmountValid)(amountDonate)) {
|
|
70
|
+
if (moneyBuyCopy) setMoneyBuyCopy(false);
|
|
71
|
+
if (!errorMsg) setErrorMsg(true);
|
|
72
|
+
} else {
|
|
73
|
+
if (errorMsg) setErrorMsg(false);
|
|
74
|
+
setMoneyBuyCopy(moneyBuyNewDescription);
|
|
62
75
|
}
|
|
63
|
-
return index === 1 && amountDonate === undefined && (setMoneyBuyCopy(moneyBuy.description), setAmountDonate(moneyBuy.value));
|
|
64
|
-
});
|
|
65
|
-
if (!(0, _Membership.isAmountValid)(amountDonate)) {
|
|
66
|
-
if (moneyBuyCopy) setMoneyBuyCopy(false);
|
|
67
|
-
if (!errorMsg) setErrorMsg(true);
|
|
68
|
-
} else {
|
|
69
|
-
if (errorMsg) setErrorMsg(false);
|
|
70
|
-
setMoneyBuyCopy(moneyBuyNewDescription);
|
|
71
76
|
}
|
|
72
77
|
}, [errorMsg, moneyBuyCopy, singleGiving, regularGiving, givingType, amountDonate, otherAmountText]);
|
|
73
78
|
|
|
@@ -76,6 +81,18 @@ const Signup = _ref => {
|
|
|
76
81
|
(0, _react.useEffect)(() => {
|
|
77
82
|
if (popOpen && !popUpShown) setPopUpShown(true);
|
|
78
83
|
}, [popOpen, popUpShown]);
|
|
84
|
+
|
|
85
|
+
// On load, determine what should actually be the default giving type
|
|
86
|
+
(0, _react.useEffect)(() => {
|
|
87
|
+
// Use any explicit setting
|
|
88
|
+
if (defaultGivingType) {
|
|
89
|
+
setGivingType(defaultGivingType);
|
|
90
|
+
} else {
|
|
91
|
+
// Else, use whatever's available
|
|
92
|
+
setGivingType(singleGiving !== null ? 'single' : 'monthly');
|
|
93
|
+
}
|
|
94
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
95
|
+
}, []);
|
|
79
96
|
const submitDonation = (event, amount, clientId, cartId, mbshipId, donateURL) => {
|
|
80
97
|
event.preventDefault();
|
|
81
98
|
if ((0, _Membership.isAmountValid)(amount) && !errorMsg) {
|
|
@@ -115,7 +132,7 @@ const Signup = _ref => {
|
|
|
115
132
|
const thisAmount = givingData.moneybuys[1] ? givingData.moneybuys[1].value : givingData.moneybuys[0].value;
|
|
116
133
|
setAmountDonate(thisAmount);
|
|
117
134
|
}
|
|
118
|
-
}, [errorMsg, givingData
|
|
135
|
+
}, [errorMsg, givingData]);
|
|
119
136
|
|
|
120
137
|
// Listen for click outside custom amount input if there is no value entered.
|
|
121
138
|
(0, _react.useEffect)(() => {
|
|
@@ -137,6 +154,9 @@ const Signup = _ref => {
|
|
|
137
154
|
}
|
|
138
155
|
return "Donate \xA3".concat(amountDonate, " monthly");
|
|
139
156
|
};
|
|
157
|
+
const showAdditionalSingleCopy = givingType === 'single' && additionalSingleCopy;
|
|
158
|
+
const showAdditionalMonthlyCopy = givingType === 'monthly' && additionalMonthlyCopy;
|
|
159
|
+
const additionalCopy = showAdditionalSingleCopy || showAdditionalMonthlyCopy;
|
|
140
160
|
return /*#__PURE__*/_react.default.createElement(_Donate.FormWrapper, null, showGivingSelector && /*#__PURE__*/_react.default.createElement(_GivingSelector.default, {
|
|
141
161
|
givingType: givingType,
|
|
142
162
|
changeGivingType: data => setGivingType(data),
|
|
@@ -151,7 +171,7 @@ const Signup = _ref => {
|
|
|
151
171
|
tag: "span",
|
|
152
172
|
size: "l",
|
|
153
173
|
weight: "bold"
|
|
154
|
-
}, chooseAmountText || "".concat(noMoneyBuys ? 'Enter' : 'Choose', " an amount to give"))), !noMoneyBuys && /*#__PURE__*/_react.default.createElement(_Donate.MoneyBuys, null, givingData.moneybuys.map((_ref2, index) => {
|
|
174
|
+
}, chooseAmountText || "".concat(noMoneyBuys ? 'Enter' : 'Choose', " an amount to give"))), !noMoneyBuys && givingType && /*#__PURE__*/_react.default.createElement(_Donate.MoneyBuys, null, givingData.moneybuys.map((_ref2, index) => {
|
|
155
175
|
let {
|
|
156
176
|
value
|
|
157
177
|
} = _ref2;
|
|
@@ -191,7 +211,9 @@ const Signup = _ref => {
|
|
|
191
211
|
}, /*#__PURE__*/_react.default.createElement("strong", null, "\xA3".concat(amountDonate, " ")), moneyBuyCopy), errorMsg && /*#__PURE__*/_react.default.createElement(_Donate.Error, {
|
|
192
212
|
className: "error--amount",
|
|
193
213
|
tag: "p"
|
|
194
|
-
}, "Please enter an amount between \xA31 and \xA325000 and up to 2 decimal places"),
|
|
214
|
+
}, "Please enter an amount between \xA31 and \xA325000 and up to 2 decimal places"), additionalCopy && /*#__PURE__*/_react.default.createElement("p", {
|
|
215
|
+
className: "additional-copy"
|
|
216
|
+
}, /*#__PURE__*/_react.default.createElement("strong", null, additionalCopy)), noMoneyBuys ? /*#__PURE__*/_react.default.createElement(_Donate.Button, {
|
|
195
217
|
type: "submit",
|
|
196
218
|
color: submitButtonColor
|
|
197
219
|
}, errorMsg ? 'Donate' : "Donate \xA3".concat(amountDonate)) : /*#__PURE__*/_react.default.createElement(_Donate.Button, {
|
|
@@ -203,6 +225,9 @@ const Signup = _ref => {
|
|
|
203
225
|
Signup.defaultProps = {
|
|
204
226
|
noMoneyBuys: false,
|
|
205
227
|
otherAmountValue: null,
|
|
206
|
-
data: {}
|
|
228
|
+
data: {},
|
|
229
|
+
additionalSingleCopy: null,
|
|
230
|
+
additionalMonthlyCopy: null,
|
|
231
|
+
defaultGivingType: null
|
|
207
232
|
};
|
|
208
233
|
var _default = exports.default = Signup;
|
|
@@ -47,4 +47,7 @@ const GivingSelector = _ref => {
|
|
|
47
47
|
htmlFor: "give-monthly--".concat(mbshipID)
|
|
48
48
|
}, "Monthly"), /*#__PURE__*/_react.default.createElement(_GivingSelector.Switch, null)));
|
|
49
49
|
};
|
|
50
|
+
GivingSelector.defaultProps = {
|
|
51
|
+
givingType: null
|
|
52
|
+
};
|
|
50
53
|
var _default = exports.default = GivingSelector;
|