@comicrelief/component-library 7.25.0 → 7.26.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.
- package/dist/components/Organisms/Donate/Donate.js +6 -3
- package/dist/components/Organisms/Donate/Donate.md +83 -0
- package/dist/components/Organisms/Donate/Form/Form.js +35 -22
- package/dist/components/Organisms/Donate/GivingSelector/GivingSelector.js +3 -0
- package/dist/components/Organisms/Donate/__snapshots__/Donate.test.js.snap +86 -302
- package/dist/components/Organisms/Donate/dev-data/data-monthly.js +22 -0
- package/package.json +1 -1
- package/src/components/Organisms/Donate/Donate.js +7 -3
- package/src/components/Organisms/Donate/Donate.md +83 -0
- package/src/components/Organisms/Donate/Form/Form.js +50 -45
- package/src/components/Organisms/Donate/GivingSelector/GivingSelector.js +5 -1
- package/src/components/Organisms/Donate/__snapshots__/Donate.test.js.snap +86 -302
- package/src/components/Organisms/Donate/dev-data/data-monthly.js +23 -0
|
@@ -42,7 +42,8 @@ const Donate = _ref => {
|
|
|
42
42
|
isDesktopOverride,
|
|
43
43
|
otherAmountValue,
|
|
44
44
|
additionalSingleCopy,
|
|
45
|
-
additionalMonthlyCopy
|
|
45
|
+
additionalMonthlyCopy,
|
|
46
|
+
defaultGivingType
|
|
46
47
|
} = _ref;
|
|
47
48
|
let isDesktop = (0, _reactResponsive.useMediaQuery)({
|
|
48
49
|
query: "(min-width: ".concat(_size.screen.medium, ")")
|
|
@@ -111,7 +112,8 @@ const Donate = _ref => {
|
|
|
111
112
|
submitButtonColor: submitButtonColor,
|
|
112
113
|
otherAmountValue: otherAmountValue,
|
|
113
114
|
additionalSingleCopy: additionalSingleCopy,
|
|
114
|
-
additionalMonthlyCopy: additionalMonthlyCopy
|
|
115
|
+
additionalMonthlyCopy: additionalMonthlyCopy,
|
|
116
|
+
defaultGivingType: defaultGivingType
|
|
115
117
|
})));
|
|
116
118
|
};
|
|
117
119
|
Donate.defaultProps = {
|
|
@@ -139,6 +141,7 @@ Donate.defaultProps = {
|
|
|
139
141
|
otherAmountValue: null,
|
|
140
142
|
title: null,
|
|
141
143
|
additionalSingleCopy: null,
|
|
142
|
-
additionalMonthlyCopy: null
|
|
144
|
+
additionalMonthlyCopy: null,
|
|
145
|
+
defaultGivingType: null
|
|
143
146
|
};
|
|
144
147
|
var _default = exports.default = Donate;
|
|
@@ -438,4 +438,87 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
438
438
|
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
439
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
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
|
+
```
|
|
497
|
+
|
|
498
|
+
## Monthly ONLY, no moneybuys
|
|
499
|
+
|
|
500
|
+
```js
|
|
501
|
+
import data from './dev-data/data-monthly';
|
|
502
|
+
const mobilePictures = require('../../../styleguide/data/data').mobileImages;
|
|
503
|
+
const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
504
|
+
|
|
505
|
+
<Donate
|
|
506
|
+
alt="Background image"
|
|
507
|
+
mobileBackgroundColor="deep_violet_dark"
|
|
508
|
+
desktopOverlayColor="red"
|
|
509
|
+
submitButtonColor="blue_dark"
|
|
510
|
+
formAlignRight={true}
|
|
511
|
+
imageLow={desktopPictures.imageLow}
|
|
512
|
+
images={desktopPictures.images}
|
|
513
|
+
mobileImageLow={mobilePictures.imageLow}
|
|
514
|
+
mobileImages={mobilePictures.images}
|
|
515
|
+
data={data}
|
|
516
|
+
mbshipID="mship-15"
|
|
517
|
+
donateLink="https://donation.comicrelief.com/"
|
|
518
|
+
clientID="donate"
|
|
519
|
+
cartID="default-comicrelief"
|
|
520
|
+
title="Donate Now"
|
|
521
|
+
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
522
|
+
noMoneyBuys
|
|
523
|
+
/>;
|
|
441
524
|
```
|
|
@@ -31,9 +31,10 @@ const Signup = _ref => {
|
|
|
31
31
|
otherAmountValue,
|
|
32
32
|
additionalSingleCopy,
|
|
33
33
|
additionalMonthlyCopy,
|
|
34
|
+
defaultGivingType,
|
|
34
35
|
...rest
|
|
35
36
|
} = _ref;
|
|
36
|
-
const [givingType, setGivingType] = (0, _react.useState)(
|
|
37
|
+
const [givingType, setGivingType] = (0, _react.useState)();
|
|
37
38
|
const [errorMsg, setErrorMsg] = (0, _react.useState)(false);
|
|
38
39
|
const [amountDonate, setAmountDonate] = (0, _react.useState)(10);
|
|
39
40
|
const [moneyBuyCopy, setMoneyBuyCopy] = (0, _react.useState)(true);
|
|
@@ -45,7 +46,7 @@ const Signup = _ref => {
|
|
|
45
46
|
// otherwise assign based on the associated moneybuys:
|
|
46
47
|
if (otherAmountValue) {
|
|
47
48
|
setAmountDonate(otherAmountValue);
|
|
48
|
-
} else {
|
|
49
|
+
} else if (givingType) {
|
|
49
50
|
const givingData = givingType === 'single' ? singleGiving : regularGiving;
|
|
50
51
|
|
|
51
52
|
// Check the 2nd moneybuy exists before using it;
|
|
@@ -56,20 +57,22 @@ const Signup = _ref => {
|
|
|
56
57
|
}
|
|
57
58
|
}, [givingType, singleGiving, regularGiving, otherAmountValue]);
|
|
58
59
|
(0, _react.useEffect)(() => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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);
|
|
64
75
|
}
|
|
65
|
-
return index === 1 && amountDonate === undefined && (setMoneyBuyCopy(moneyBuy.description), setAmountDonate(moneyBuy.value));
|
|
66
|
-
});
|
|
67
|
-
if (!(0, _Membership.isAmountValid)(amountDonate)) {
|
|
68
|
-
if (moneyBuyCopy) setMoneyBuyCopy(false);
|
|
69
|
-
if (!errorMsg) setErrorMsg(true);
|
|
70
|
-
} else {
|
|
71
|
-
if (errorMsg) setErrorMsg(false);
|
|
72
|
-
setMoneyBuyCopy(moneyBuyNewDescription);
|
|
73
76
|
}
|
|
74
77
|
}, [errorMsg, moneyBuyCopy, singleGiving, regularGiving, givingType, amountDonate, otherAmountText]);
|
|
75
78
|
|
|
@@ -78,6 +81,18 @@ const Signup = _ref => {
|
|
|
78
81
|
(0, _react.useEffect)(() => {
|
|
79
82
|
if (popOpen && !popUpShown) setPopUpShown(true);
|
|
80
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
|
+
}, []);
|
|
81
96
|
const submitDonation = (event, amount, clientId, cartId, mbshipId, donateURL) => {
|
|
82
97
|
event.preventDefault();
|
|
83
98
|
if ((0, _Membership.isAmountValid)(amount) && !errorMsg) {
|
|
@@ -117,7 +132,7 @@ const Signup = _ref => {
|
|
|
117
132
|
const thisAmount = givingData.moneybuys[1] ? givingData.moneybuys[1].value : givingData.moneybuys[0].value;
|
|
118
133
|
setAmountDonate(thisAmount);
|
|
119
134
|
}
|
|
120
|
-
}, [errorMsg, givingData
|
|
135
|
+
}, [errorMsg, givingData]);
|
|
121
136
|
|
|
122
137
|
// Listen for click outside custom amount input if there is no value entered.
|
|
123
138
|
(0, _react.useEffect)(() => {
|
|
@@ -156,7 +171,7 @@ const Signup = _ref => {
|
|
|
156
171
|
tag: "span",
|
|
157
172
|
size: "l",
|
|
158
173
|
weight: "bold"
|
|
159
|
-
}, 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) => {
|
|
160
175
|
let {
|
|
161
176
|
value
|
|
162
177
|
} = _ref2;
|
|
@@ -198,10 +213,7 @@ const Signup = _ref => {
|
|
|
198
213
|
tag: "p"
|
|
199
214
|
}, "Please enter an amount between \xA31 and \xA325000 and up to 2 decimal places"), additionalCopy && /*#__PURE__*/_react.default.createElement("p", {
|
|
200
215
|
className: "additional-copy"
|
|
201
|
-
}, /*#__PURE__*/_react.default.createElement("strong", null, additionalCopy)),
|
|
202
|
-
type: "submit",
|
|
203
|
-
color: submitButtonColor
|
|
204
|
-
}, errorMsg ? 'Donate' : "Donate \xA3".concat(amountDonate)) : /*#__PURE__*/_react.default.createElement(_Donate.Button, {
|
|
216
|
+
}, /*#__PURE__*/_react.default.createElement("strong", null, additionalCopy)), /*#__PURE__*/_react.default.createElement(_Donate.Button, {
|
|
205
217
|
type: "submit",
|
|
206
218
|
color: submitButtonColor,
|
|
207
219
|
ref: buttonRef
|
|
@@ -212,6 +224,7 @@ Signup.defaultProps = {
|
|
|
212
224
|
otherAmountValue: null,
|
|
213
225
|
data: {},
|
|
214
226
|
additionalSingleCopy: null,
|
|
215
|
-
additionalMonthlyCopy: null
|
|
227
|
+
additionalMonthlyCopy: null,
|
|
228
|
+
defaultGivingType: null
|
|
216
229
|
};
|
|
217
230
|
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;
|