@comicrelief/component-library 7.2.0 → 7.4.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 +3 -3
- package/dist/components/Organisms/Donate/Donate.md +3 -12
- package/dist/components/Organisms/Donate/Form/Form.js +23 -12
- package/dist/components/Organisms/Donate/Form/PopUpComponent.js +15 -5
- package/dist/components/Organisms/Donate/GivingSelector/GivingSelector.js +11 -4
- package/dist/utils/Membership.js +2 -1
- package/package.json +1 -1
- package/src/components/Organisms/Donate/Donate.js +4 -4
- package/src/components/Organisms/Donate/Donate.md +3 -12
- package/src/components/Organisms/Donate/Form/Form.js +16 -8
- package/src/components/Organisms/Donate/Form/PopUpComponent.js +19 -8
- package/src/components/Organisms/Donate/GivingSelector/GivingSelector.js +45 -41
- package/src/utils/Membership.js +3 -2
|
@@ -36,7 +36,7 @@ var Donate = function Donate(_ref) {
|
|
|
36
36
|
data = _ref.data,
|
|
37
37
|
title = _ref.title,
|
|
38
38
|
subtitle = _ref.subtitle,
|
|
39
|
-
|
|
39
|
+
otherAmountText = _ref.otherAmountText,
|
|
40
40
|
formAlignRight = _ref.formAlignRight,
|
|
41
41
|
images = _ref.images,
|
|
42
42
|
image = _ref.image,
|
|
@@ -107,7 +107,7 @@ var Donate = function Donate(_ref) {
|
|
|
107
107
|
size: "m"
|
|
108
108
|
}, subtitle)))), /*#__PURE__*/_react.default.createElement(_Form.default, {
|
|
109
109
|
data: data,
|
|
110
|
-
|
|
110
|
+
otherAmountText: otherAmountText,
|
|
111
111
|
cartID: cartID,
|
|
112
112
|
clientID: clientID,
|
|
113
113
|
mbshipID: mbshipID,
|
|
@@ -131,7 +131,7 @@ Donate.defaultProps = {
|
|
|
131
131
|
mobileAlt: '',
|
|
132
132
|
backgroundColor: 'blue_dark',
|
|
133
133
|
mbshipID: null,
|
|
134
|
-
|
|
134
|
+
otherAmountText: 'will help us fund amazing projects in the UK and around the world.',
|
|
135
135
|
subtitle: '',
|
|
136
136
|
noMoneyBuys: false,
|
|
137
137
|
PopUpText: 'Help us deliver long-term impact by converting your single donation into a monthly gift.',
|
|
@@ -22,11 +22,10 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
22
22
|
cartID="default-comicrelief"
|
|
23
23
|
title="Donate Now"
|
|
24
24
|
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
25
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
26
25
|
/>;
|
|
27
26
|
```
|
|
28
27
|
|
|
29
|
-
## Form align left
|
|
28
|
+
## Form align left, with custom message after choosing an "Other amount" to donate.
|
|
30
29
|
|
|
31
30
|
```js
|
|
32
31
|
import data from './dev-data/data';
|
|
@@ -47,7 +46,7 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
47
46
|
cartID="default-comicrelief"
|
|
48
47
|
title="Donate Now"
|
|
49
48
|
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
50
|
-
|
|
49
|
+
otherAmountText="Overridden via the 'Other amount text' prop"
|
|
51
50
|
/>;
|
|
52
51
|
```
|
|
53
52
|
|
|
@@ -72,7 +71,6 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
72
71
|
cartID="default-comicrelief"
|
|
73
72
|
title="Donate Now"
|
|
74
73
|
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
75
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
76
74
|
/>;
|
|
77
75
|
```
|
|
78
76
|
|
|
@@ -98,7 +96,6 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
98
96
|
title="Donate Now"
|
|
99
97
|
noMoneyBuys
|
|
100
98
|
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
101
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
102
99
|
/>;
|
|
103
100
|
```
|
|
104
101
|
|
|
@@ -124,7 +121,6 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
124
121
|
cartID="default-comicrelief"
|
|
125
122
|
title="Donate Now"
|
|
126
123
|
subtitle=""
|
|
127
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
128
124
|
/>;
|
|
129
125
|
```
|
|
130
126
|
|
|
@@ -149,7 +145,6 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
149
145
|
cartID="default-comicrelief"
|
|
150
146
|
title="Donate Now"
|
|
151
147
|
subtitle=""
|
|
152
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
153
148
|
/>;
|
|
154
149
|
```
|
|
155
150
|
|
|
@@ -174,7 +169,6 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
174
169
|
cartID="default-comicrelief"
|
|
175
170
|
title="Donate Now"
|
|
176
171
|
subtitle=""
|
|
177
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
178
172
|
/>;
|
|
179
173
|
```
|
|
180
174
|
|
|
@@ -200,7 +194,6 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
200
194
|
title="Donate Now"
|
|
201
195
|
noMoneyBuys
|
|
202
196
|
subtitle=""
|
|
203
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
204
197
|
/>;
|
|
205
198
|
```
|
|
206
199
|
|
|
@@ -220,8 +213,7 @@ import data from './dev-data/data-single';
|
|
|
220
213
|
title="Donate Now"
|
|
221
214
|
noMoneyBuys
|
|
222
215
|
subtitle=""
|
|
223
|
-
|
|
224
|
-
chooseAmountText="Overridden via the 'choose amount text' props"
|
|
216
|
+
chooseAmountText="Overridden via the 'choose amount text' prop"
|
|
225
217
|
/>;
|
|
226
218
|
```
|
|
227
219
|
|
|
@@ -247,7 +239,6 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
247
239
|
cartID="default-comicrelief"
|
|
248
240
|
title="Donate Now"
|
|
249
241
|
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
250
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
251
242
|
isDesktopOverride={false}
|
|
252
243
|
/>;
|
|
253
244
|
```
|
|
@@ -25,7 +25,7 @@ var _Donate = require("../Donate.style");
|
|
|
25
25
|
|
|
26
26
|
var _GivingSelector = _interopRequireDefault(require("../GivingSelector/GivingSelector"));
|
|
27
27
|
|
|
28
|
-
var _excluded = ["data", "donateLink", "
|
|
28
|
+
var _excluded = ["data", "donateLink", "otherAmountText", "clientID", "cartID", "mbshipID", "noMoneyBuys", "PopUpText", "chooseAmountText"];
|
|
29
29
|
|
|
30
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
31
|
|
|
@@ -36,7 +36,7 @@ var Signup = function Signup(_ref) {
|
|
|
36
36
|
singleGiving = _ref$data.singleGiving,
|
|
37
37
|
regularGiving = _ref$data.regularGiving,
|
|
38
38
|
donateLink = _ref.donateLink,
|
|
39
|
-
|
|
39
|
+
otherAmountText = _ref.otherAmountText,
|
|
40
40
|
clientID = _ref.clientID,
|
|
41
41
|
cartID = _ref.cartID,
|
|
42
42
|
mbshipID = _ref.mbshipID,
|
|
@@ -65,6 +65,17 @@ var Signup = function Signup(_ref) {
|
|
|
65
65
|
moneyBuyCopy = _useState8[0],
|
|
66
66
|
setMoneyBuyCopy = _useState8[1];
|
|
67
67
|
|
|
68
|
+
var _useState9 = (0, _react.useState)(false),
|
|
69
|
+
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
70
|
+
popOpen = _useState10[0],
|
|
71
|
+
setPopOpen = _useState10[1]; // In order to keep track of whether the user has ever been shown the popup
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
var _useState11 = (0, _react.useState)(false),
|
|
75
|
+
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
76
|
+
popUpShown = _useState12[0],
|
|
77
|
+
setPopUpShown = _useState12[1];
|
|
78
|
+
|
|
68
79
|
(0, _react.useEffect)(function () {
|
|
69
80
|
var givingData = givingType === 'single' ? singleGiving : regularGiving; // Check the 2nd moneybuy exists before using it;
|
|
70
81
|
// 'philantrophy' carts have been set up to use a single moneybuy.
|
|
@@ -75,7 +86,7 @@ var Signup = function Signup(_ref) {
|
|
|
75
86
|
}, [givingType, singleGiving, regularGiving]);
|
|
76
87
|
(0, _react.useEffect)(function () {
|
|
77
88
|
var givingData = givingType === 'single' ? singleGiving : regularGiving;
|
|
78
|
-
var moneyBuyNewDescription =
|
|
89
|
+
var moneyBuyNewDescription = otherAmountText;
|
|
79
90
|
givingData.moneybuys.map(function (moneyBuy, index) {
|
|
80
91
|
if (moneyBuy.value === amountDonate) {
|
|
81
92
|
moneyBuyNewDescription = moneyBuy.description;
|
|
@@ -91,13 +102,18 @@ var Signup = function Signup(_ref) {
|
|
|
91
102
|
if (errorMsg) setErrorMsg(false);
|
|
92
103
|
setMoneyBuyCopy(moneyBuyNewDescription);
|
|
93
104
|
}
|
|
94
|
-
}, [errorMsg, moneyBuyCopy, singleGiving, regularGiving, givingType, amountDonate,
|
|
105
|
+
}, [errorMsg, moneyBuyCopy, singleGiving, regularGiving, givingType, amountDonate, otherAmountText]); // Updates our flag that differentiates between the popup
|
|
106
|
+
// being *currently* open and it *ever* having been shown to user
|
|
107
|
+
|
|
108
|
+
(0, _react.useEffect)(function () {
|
|
109
|
+
if (popOpen && !popUpShown) setPopUpShown(true);
|
|
110
|
+
}, [popOpen, popUpShown]);
|
|
95
111
|
|
|
96
112
|
var submitDonation = function submitDonation(event, amount, clientId, cartId, mbshipId, donateURL) {
|
|
97
113
|
event.preventDefault();
|
|
98
114
|
|
|
99
115
|
if ((0, _Membership.isAmountValid)(amount) && !errorMsg) {
|
|
100
|
-
(0, _Membership.handleDonateSubmission)(amount, clientId, cartId, mbshipId, donateURL, givingType);
|
|
116
|
+
(0, _Membership.handleDonateSubmission)(amount, clientId, cartId, mbshipId, donateURL, givingType, popUpShown);
|
|
101
117
|
} else {
|
|
102
118
|
setErrorMsg(true);
|
|
103
119
|
setMoneyBuyCopy(false);
|
|
@@ -107,12 +123,6 @@ var Signup = function Signup(_ref) {
|
|
|
107
123
|
|
|
108
124
|
var givingData = givingType === 'single' ? singleGiving : regularGiving;
|
|
109
125
|
var showGivingSelector = singleGiving !== null && regularGiving !== null;
|
|
110
|
-
|
|
111
|
-
var _useState9 = (0, _react.useState)(false),
|
|
112
|
-
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
113
|
-
popOpen = _useState10[0],
|
|
114
|
-
setPopOpen = _useState10[1];
|
|
115
|
-
|
|
116
126
|
return /*#__PURE__*/_react.default.createElement(_Donate.FormWrapper, null, showGivingSelector && /*#__PURE__*/_react.default.createElement(_GivingSelector.default, {
|
|
117
127
|
givingType: givingType,
|
|
118
128
|
changeGivingType: function changeGivingType(data) {
|
|
@@ -121,7 +131,8 @@ var Signup = function Signup(_ref) {
|
|
|
121
131
|
setPopOpen: setPopOpen,
|
|
122
132
|
mbshipID: mbshipID
|
|
123
133
|
}), popOpen && /*#__PURE__*/_react.default.createElement(_PopUpComponent.default, {
|
|
124
|
-
PopUpText: PopUpText
|
|
134
|
+
PopUpText: PopUpText,
|
|
135
|
+
setPopOpen: setPopOpen
|
|
125
136
|
}), /*#__PURE__*/_react.default.createElement(_Donate.Form, {
|
|
126
137
|
onSubmit: function onSubmit(e) {
|
|
127
138
|
return submitDonation(e, amountDonate, clientID, cartID, mbshipID, donateLink);
|
|
@@ -23,7 +23,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
23
23
|
|
|
24
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
var closeDuration = 0.6;
|
|
27
27
|
var fadeClose = (0, _styledComponents.keyframes)(["0%{opacity:1;max-height:350px;}100%{opacity:0;max-height:0px;display:none;margin-top:-16px;}"]);
|
|
28
28
|
var fadeOpen = (0, _styledComponents.keyframes)(["0%{opacity:0;max-height:0px;display:none;margin-top:-16px;}100%{opacity:1;max-height:350px;}"]);
|
|
29
29
|
|
|
@@ -31,7 +31,7 @@ var StyledPopUp = _styledComponents.default.div.withConfig({
|
|
|
31
31
|
displayName: "PopUpComponent__StyledPopUp",
|
|
32
32
|
componentId: "sc-1d7imlo-0"
|
|
33
33
|
})(["display:grid;overflow:hidden;max-height:350px;opacity:1;animation:0.4s ", " ease;", " background-color:", ";box-shadow:0px 0px 16px rgba(0,0,0,0.15);border-radius:10px;", "{width:450px;margin-right:auto;margin-left:auto;}"], fadeOpen, function (props) {
|
|
34
|
-
return props.isClosed && (0, _styledComponents.css)(["animation:
|
|
34
|
+
return props.isClosed && (0, _styledComponents.css)(["animation:", "s ", " ease forwards;"], closeDuration, fadeClose);
|
|
35
35
|
}, function (_ref) {
|
|
36
36
|
var theme = _ref.theme;
|
|
37
37
|
return theme.color('blue_light');
|
|
@@ -51,18 +51,28 @@ var Button = _styledComponents.default.button.withConfig({
|
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
var PopUpComponent = function PopUpComponent(_ref3) {
|
|
54
|
-
var PopUpText = _ref3.PopUpText
|
|
54
|
+
var PopUpText = _ref3.PopUpText,
|
|
55
|
+
setPopOpen = _ref3.setPopOpen;
|
|
55
56
|
|
|
56
57
|
var _useState = (0, _react.useState)(false),
|
|
57
58
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
58
59
|
isClosed = _useState2[0],
|
|
59
|
-
setIsClosed = _useState2[1];
|
|
60
|
+
setIsClosed = _useState2[1]; // Only update centralised state - which renders
|
|
61
|
+
// this component - once the closing animation is complete
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
var handleCloser = function handleCloser() {
|
|
65
|
+
setIsClosed(true);
|
|
66
|
+
setTimeout(function () {
|
|
67
|
+
setPopOpen(false);
|
|
68
|
+
}, closeDuration * 1000);
|
|
69
|
+
};
|
|
60
70
|
|
|
61
71
|
return /*#__PURE__*/_react.default.createElement(StyledPopUp, {
|
|
62
72
|
isClosed: isClosed
|
|
63
73
|
}, /*#__PURE__*/_react.default.createElement(Button, {
|
|
64
74
|
onClick: function onClick() {
|
|
65
|
-
return
|
|
75
|
+
return handleCloser();
|
|
66
76
|
},
|
|
67
77
|
"aria-label": "Close"
|
|
68
78
|
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
@@ -16,6 +16,15 @@ var GivingSelector = function GivingSelector(_ref) {
|
|
|
16
16
|
changeGivingType = _ref.changeGivingType,
|
|
17
17
|
setPopOpen = _ref.setPopOpen,
|
|
18
18
|
mbshipID = _ref.mbshipID;
|
|
19
|
+
|
|
20
|
+
// Only updates giving type and popup status when appropriate
|
|
21
|
+
var handleGivingTypeChange = function handleGivingTypeChange(thisButtonType, currentGivingType) {
|
|
22
|
+
if (currentGivingType !== thisButtonType) {
|
|
23
|
+
changeGivingType(thisButtonType);
|
|
24
|
+
setPopOpen(thisButtonType === 'single');
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
19
28
|
return /*#__PURE__*/_react.default.createElement(_GivingSelector.Wrapper, null, /*#__PURE__*/_react.default.createElement(_GivingSelector.MoneyBox, null, /*#__PURE__*/_react.default.createElement("input", {
|
|
20
29
|
className: "give-once",
|
|
21
30
|
"aria-label": "Single",
|
|
@@ -26,8 +35,7 @@ var GivingSelector = function GivingSelector(_ref) {
|
|
|
26
35
|
errormsg: "",
|
|
27
36
|
checked: givingType === 'single',
|
|
28
37
|
onClick: function onClick() {
|
|
29
|
-
|
|
30
|
-
setPopOpen(true);
|
|
38
|
+
return handleGivingTypeChange('single', givingType);
|
|
31
39
|
}
|
|
32
40
|
}), /*#__PURE__*/_react.default.createElement(_GivingSelector.Label, {
|
|
33
41
|
active: givingType === 'single',
|
|
@@ -42,8 +50,7 @@ var GivingSelector = function GivingSelector(_ref) {
|
|
|
42
50
|
errormsg: "",
|
|
43
51
|
checked: givingType === 'monthly',
|
|
44
52
|
onClick: function onClick() {
|
|
45
|
-
|
|
46
|
-
setPopOpen(false);
|
|
53
|
+
return handleGivingTypeChange('monthly', givingType);
|
|
47
54
|
}
|
|
48
55
|
}), /*#__PURE__*/_react.default.createElement(_GivingSelector.Label, {
|
|
49
56
|
active: givingType === 'monthly',
|
package/dist/utils/Membership.js
CHANGED
|
@@ -42,6 +42,7 @@ exports.isInputMatchBoxValue = isInputMatchBoxValue;
|
|
|
42
42
|
|
|
43
43
|
var handleDonateSubmission = function handleDonateSubmission(amount, clientID, cartID, mbshipID, donateLink) {
|
|
44
44
|
var givingType = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 'monthly';
|
|
45
|
+
var popUpShown = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
45
46
|
var currentpageUrl = window.location.href;
|
|
46
47
|
var affiliateValue = getUrlParameter(currentpageUrl);
|
|
47
48
|
var reg = /[#?|[\]\\]/g;
|
|
@@ -52,7 +53,7 @@ var handleDonateSubmission = function handleDonateSubmission(amount, clientID, c
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
var givingTypeUrl = givingType === 'single' ? 'single' : 'monthly';
|
|
55
|
-
window.location.href = "".concat(donateLink, "?clientOverride=").concat(clientID, "&amount=").concat(amount, "¤cy=GBP&givingType=").concat(givingTypeUrl, "&cartId=").concat(cartID, "&affiliate=").concat(affiliateValue, "&siteurl=").concat(currentpageUrl, "&rowID=").concat(mbshipID);
|
|
56
|
+
window.location.href = "".concat(donateLink, "?clientOverride=").concat(clientID, "&amount=").concat(amount, "¤cy=GBP&givingType=").concat(givingTypeUrl, "&cartId=").concat(cartID, "&affiliate=").concat(affiliateValue, "&siteurl=").concat(currentpageUrl, "&rowID=").concat(mbshipID, "&popUpShown=").concat(popUpShown);
|
|
56
57
|
};
|
|
57
58
|
|
|
58
59
|
exports.handleDonateSubmission = handleDonateSubmission;
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ const Donate = ({
|
|
|
23
23
|
data,
|
|
24
24
|
title,
|
|
25
25
|
subtitle,
|
|
26
|
-
|
|
26
|
+
otherAmountText,
|
|
27
27
|
formAlignRight,
|
|
28
28
|
images,
|
|
29
29
|
image,
|
|
@@ -105,7 +105,7 @@ const Donate = ({
|
|
|
105
105
|
|
|
106
106
|
<Form
|
|
107
107
|
data={data}
|
|
108
|
-
|
|
108
|
+
otherAmountText={otherAmountText}
|
|
109
109
|
cartID={cartID}
|
|
110
110
|
clientID={clientID}
|
|
111
111
|
mbshipID={mbshipID}
|
|
@@ -126,7 +126,7 @@ Donate.propTypes = {
|
|
|
126
126
|
clientID: PropTypes.string.isRequired,
|
|
127
127
|
donateLink: PropTypes.string.isRequired,
|
|
128
128
|
title: PropTypes.string.isRequired,
|
|
129
|
-
|
|
129
|
+
otherAmountText: PropTypes.string,
|
|
130
130
|
subtitle: PropTypes.string,
|
|
131
131
|
formAlignRight: PropTypes.bool,
|
|
132
132
|
imageLow: PropTypes.string,
|
|
@@ -157,7 +157,7 @@ Donate.defaultProps = {
|
|
|
157
157
|
mobileAlt: '',
|
|
158
158
|
backgroundColor: 'blue_dark',
|
|
159
159
|
mbshipID: null,
|
|
160
|
-
|
|
160
|
+
otherAmountText:
|
|
161
161
|
'will help us fund amazing projects in the UK and around the world.',
|
|
162
162
|
subtitle: '',
|
|
163
163
|
noMoneyBuys: false,
|
|
@@ -22,11 +22,10 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
22
22
|
cartID="default-comicrelief"
|
|
23
23
|
title="Donate Now"
|
|
24
24
|
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
25
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
26
25
|
/>;
|
|
27
26
|
```
|
|
28
27
|
|
|
29
|
-
## Form align left
|
|
28
|
+
## Form align left, with custom message after choosing an "Other amount" to donate.
|
|
30
29
|
|
|
31
30
|
```js
|
|
32
31
|
import data from './dev-data/data';
|
|
@@ -47,7 +46,7 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
47
46
|
cartID="default-comicrelief"
|
|
48
47
|
title="Donate Now"
|
|
49
48
|
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
50
|
-
|
|
49
|
+
otherAmountText="Overridden via the 'Other amount text' prop"
|
|
51
50
|
/>;
|
|
52
51
|
```
|
|
53
52
|
|
|
@@ -72,7 +71,6 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
72
71
|
cartID="default-comicrelief"
|
|
73
72
|
title="Donate Now"
|
|
74
73
|
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
75
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
76
74
|
/>;
|
|
77
75
|
```
|
|
78
76
|
|
|
@@ -98,7 +96,6 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
98
96
|
title="Donate Now"
|
|
99
97
|
noMoneyBuys
|
|
100
98
|
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
101
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
102
99
|
/>;
|
|
103
100
|
```
|
|
104
101
|
|
|
@@ -124,7 +121,6 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
124
121
|
cartID="default-comicrelief"
|
|
125
122
|
title="Donate Now"
|
|
126
123
|
subtitle=""
|
|
127
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
128
124
|
/>;
|
|
129
125
|
```
|
|
130
126
|
|
|
@@ -149,7 +145,6 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
149
145
|
cartID="default-comicrelief"
|
|
150
146
|
title="Donate Now"
|
|
151
147
|
subtitle=""
|
|
152
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
153
148
|
/>;
|
|
154
149
|
```
|
|
155
150
|
|
|
@@ -174,7 +169,6 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
174
169
|
cartID="default-comicrelief"
|
|
175
170
|
title="Donate Now"
|
|
176
171
|
subtitle=""
|
|
177
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
178
172
|
/>;
|
|
179
173
|
```
|
|
180
174
|
|
|
@@ -200,7 +194,6 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
200
194
|
title="Donate Now"
|
|
201
195
|
noMoneyBuys
|
|
202
196
|
subtitle=""
|
|
203
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
204
197
|
/>;
|
|
205
198
|
```
|
|
206
199
|
|
|
@@ -220,8 +213,7 @@ import data from './dev-data/data-single';
|
|
|
220
213
|
title="Donate Now"
|
|
221
214
|
noMoneyBuys
|
|
222
215
|
subtitle=""
|
|
223
|
-
|
|
224
|
-
chooseAmountText="Overridden via the 'choose amount text' props"
|
|
216
|
+
chooseAmountText="Overridden via the 'choose amount text' prop"
|
|
225
217
|
/>;
|
|
226
218
|
```
|
|
227
219
|
|
|
@@ -247,7 +239,6 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
|
|
|
247
239
|
cartID="default-comicrelief"
|
|
248
240
|
title="Donate Now"
|
|
249
241
|
subtitle="Please help us fund life-changing projects in the UK and around the world."
|
|
250
|
-
otherDescription="will help us fund amazing projects in the UK and around the world."
|
|
251
242
|
isDesktopOverride={false}
|
|
252
243
|
/>;
|
|
253
244
|
```
|
|
@@ -26,7 +26,7 @@ import GivingSelector from '../GivingSelector/GivingSelector';
|
|
|
26
26
|
const Signup = ({
|
|
27
27
|
data: { singleGiving, regularGiving },
|
|
28
28
|
donateLink,
|
|
29
|
-
|
|
29
|
+
otherAmountText,
|
|
30
30
|
clientID,
|
|
31
31
|
cartID,
|
|
32
32
|
mbshipID,
|
|
@@ -39,6 +39,9 @@ const Signup = ({
|
|
|
39
39
|
const [errorMsg, setErrorMsg] = useState(false);
|
|
40
40
|
const [amountDonate, setAmountDonate] = useState(' ');
|
|
41
41
|
const [moneyBuyCopy, setMoneyBuyCopy] = useState(true);
|
|
42
|
+
const [popOpen, setPopOpen] = useState(false);
|
|
43
|
+
// In order to keep track of whether the user has ever been shown the popup
|
|
44
|
+
const [popUpShown, setPopUpShown] = useState(false);
|
|
42
45
|
|
|
43
46
|
useEffect(() => {
|
|
44
47
|
const givingData = givingType === 'single' ? singleGiving : regularGiving;
|
|
@@ -56,7 +59,7 @@ const Signup = ({
|
|
|
56
59
|
useEffect(() => {
|
|
57
60
|
const givingData = givingType === 'single' ? singleGiving : regularGiving;
|
|
58
61
|
|
|
59
|
-
let moneyBuyNewDescription =
|
|
62
|
+
let moneyBuyNewDescription = otherAmountText;
|
|
60
63
|
|
|
61
64
|
givingData.moneybuys.map((moneyBuy, index) => {
|
|
62
65
|
if (moneyBuy.value === amountDonate) {
|
|
@@ -85,9 +88,15 @@ const Signup = ({
|
|
|
85
88
|
regularGiving,
|
|
86
89
|
givingType,
|
|
87
90
|
amountDonate,
|
|
88
|
-
|
|
91
|
+
otherAmountText
|
|
89
92
|
]);
|
|
90
93
|
|
|
94
|
+
// Updates our flag that differentiates between the popup
|
|
95
|
+
// being *currently* open and it *ever* having been shown to user
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (popOpen && !popUpShown) setPopUpShown(true);
|
|
98
|
+
}, [popOpen, popUpShown]);
|
|
99
|
+
|
|
91
100
|
const submitDonation = (
|
|
92
101
|
event,
|
|
93
102
|
amount,
|
|
@@ -104,7 +113,8 @@ const Signup = ({
|
|
|
104
113
|
cartId,
|
|
105
114
|
mbshipId,
|
|
106
115
|
donateURL,
|
|
107
|
-
givingType
|
|
116
|
+
givingType,
|
|
117
|
+
popUpShown
|
|
108
118
|
);
|
|
109
119
|
} else {
|
|
110
120
|
setErrorMsg(true);
|
|
@@ -116,8 +126,6 @@ const Signup = ({
|
|
|
116
126
|
const givingData = givingType === 'single' ? singleGiving : regularGiving;
|
|
117
127
|
const showGivingSelector = singleGiving !== null && regularGiving !== null;
|
|
118
128
|
|
|
119
|
-
const [popOpen, setPopOpen] = useState(false);
|
|
120
|
-
|
|
121
129
|
return (
|
|
122
130
|
<FormWrapper>
|
|
123
131
|
{showGivingSelector && (
|
|
@@ -129,7 +137,7 @@ const Signup = ({
|
|
|
129
137
|
/>
|
|
130
138
|
)}
|
|
131
139
|
|
|
132
|
-
{ popOpen && <PopUpComponent PopUpText={PopUpText} /> }
|
|
140
|
+
{ popOpen && <PopUpComponent PopUpText={PopUpText} setPopOpen={setPopOpen} /> }
|
|
133
141
|
|
|
134
142
|
<Form
|
|
135
143
|
onSubmit={e => submitDonation(
|
|
@@ -222,7 +230,7 @@ Signup.propTypes = {
|
|
|
222
230
|
clientID: PropTypes.string.isRequired,
|
|
223
231
|
cartID: PropTypes.string.isRequired,
|
|
224
232
|
donateLink: PropTypes.string.isRequired,
|
|
225
|
-
|
|
233
|
+
otherAmountText: PropTypes.string.isRequired,
|
|
226
234
|
mbshipID: PropTypes.string.isRequired,
|
|
227
235
|
noMoneyBuys: PropTypes.bool,
|
|
228
236
|
data: PropTypes.objectOf(PropTypes.shape),
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
1
|
import React, { useState } from 'react';
|
|
3
2
|
import styled, { css, keyframes } from 'styled-components';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
4
|
import Text from '../../../Atoms/Text/Text';
|
|
5
5
|
import { media } from '../../../../theme/shared/size';
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
6
|
import CloseCross from '../assets/close.svg';
|
|
8
7
|
|
|
8
|
+
const closeDuration = 0.6;
|
|
9
|
+
|
|
9
10
|
const fadeClose = keyframes`
|
|
10
11
|
0% {
|
|
11
12
|
opacity: 1;
|
|
@@ -39,7 +40,7 @@ const StyledPopUp = styled.div`
|
|
|
39
40
|
opacity: 1;
|
|
40
41
|
animation: 0.4s ${fadeOpen} ease;
|
|
41
42
|
${props => props.isClosed && css`
|
|
42
|
-
animation:
|
|
43
|
+
animation: ${closeDuration}s ${fadeClose} ease forwards;
|
|
43
44
|
`}
|
|
44
45
|
background-color: ${({ theme }) => theme.color('blue_light')};
|
|
45
46
|
box-shadow: 0px 0px 16px rgba(0, 0, 0, 0.15);
|
|
@@ -78,23 +79,33 @@ const Button = styled.button`
|
|
|
78
79
|
}
|
|
79
80
|
`;
|
|
80
81
|
|
|
81
|
-
const PopUpComponent = ({ PopUpText }) => {
|
|
82
|
+
const PopUpComponent = ({ PopUpText, setPopOpen }) => {
|
|
82
83
|
const [isClosed, setIsClosed] = useState(false);
|
|
83
84
|
|
|
85
|
+
// Only update centralised state - which renders
|
|
86
|
+
// this component - once the closing animation is complete
|
|
87
|
+
const handleCloser = () => {
|
|
88
|
+
setIsClosed(true);
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
setPopOpen(false);
|
|
91
|
+
}, closeDuration * 1000);
|
|
92
|
+
};
|
|
93
|
+
|
|
84
94
|
return (
|
|
85
95
|
<StyledPopUp isClosed={isClosed}>
|
|
86
|
-
<Button onClick={() =>
|
|
87
|
-
<img src={CloseCross} alt="Close cross icon"/>
|
|
96
|
+
<Button onClick={() => handleCloser()} aria-label="Close">
|
|
97
|
+
<img src={CloseCross} alt="Close cross icon" />
|
|
88
98
|
</Button>
|
|
89
99
|
<TextWrapper>
|
|
90
100
|
<Text>{ PopUpText }</Text>
|
|
91
101
|
</TextWrapper>
|
|
92
102
|
</StyledPopUp>
|
|
93
|
-
)
|
|
103
|
+
);
|
|
94
104
|
};
|
|
95
105
|
|
|
96
106
|
PopUpComponent.propTypes = {
|
|
97
|
-
PopUpText: PropTypes.string.isRequired
|
|
107
|
+
PopUpText: PropTypes.string.isRequired,
|
|
108
|
+
setPopOpen: PropTypes.func.isRequired
|
|
98
109
|
};
|
|
99
110
|
|
|
100
111
|
export default PopUpComponent;
|
|
@@ -7,47 +7,51 @@ import {
|
|
|
7
7
|
|
|
8
8
|
const GivingSelector = ({
|
|
9
9
|
givingType, changeGivingType, setPopOpen, mbshipID
|
|
10
|
-
}) =>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
10
|
+
}) => {
|
|
11
|
+
// Only updates giving type and popup status when appropriate
|
|
12
|
+
const handleGivingTypeChange = (thisButtonType, currentGivingType) => {
|
|
13
|
+
if (currentGivingType !== thisButtonType) {
|
|
14
|
+
changeGivingType(thisButtonType);
|
|
15
|
+
setPopOpen(thisButtonType === 'single');
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Wrapper>
|
|
21
|
+
<MoneyBox>
|
|
22
|
+
<input
|
|
23
|
+
className="give-once"
|
|
24
|
+
aria-label="Single"
|
|
25
|
+
id={`give-once--${mbshipID}`}
|
|
26
|
+
value="Single"
|
|
27
|
+
type="radio"
|
|
28
|
+
label=""
|
|
29
|
+
errormsg=""
|
|
30
|
+
checked={givingType === 'single'}
|
|
31
|
+
onClick={() => handleGivingTypeChange('single', givingType)}
|
|
32
|
+
/>
|
|
33
|
+
<Label active={givingType === 'single'} htmlFor={`give-once--${mbshipID}`}>
|
|
34
|
+
Single
|
|
35
|
+
</Label>
|
|
36
|
+
<input
|
|
37
|
+
className="give-monthly"
|
|
38
|
+
aria-label="Monthly"
|
|
39
|
+
id={`give-monthly--${mbshipID}`}
|
|
40
|
+
value="Monthly"
|
|
41
|
+
type="radio"
|
|
42
|
+
label=""
|
|
43
|
+
errormsg=""
|
|
44
|
+
checked={givingType === 'monthly'}
|
|
45
|
+
onClick={() => handleGivingTypeChange('monthly', givingType)}
|
|
46
|
+
/>
|
|
47
|
+
<Label active={givingType === 'monthly'} htmlFor={`give-monthly--${mbshipID}`}>
|
|
48
|
+
Monthly
|
|
49
|
+
</Label>
|
|
50
|
+
<Switch />
|
|
51
|
+
</MoneyBox>
|
|
52
|
+
</Wrapper>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
51
55
|
|
|
52
56
|
GivingSelector.propTypes = {
|
|
53
57
|
givingType: PropTypes.string.isRequired,
|
package/src/utils/Membership.js
CHANGED
|
@@ -42,7 +42,8 @@ const handleDonateSubmission = (
|
|
|
42
42
|
cartID,
|
|
43
43
|
mbshipID,
|
|
44
44
|
donateLink,
|
|
45
|
-
givingType = 'monthly'
|
|
45
|
+
givingType = 'monthly',
|
|
46
|
+
popUpShown = null
|
|
46
47
|
) => {
|
|
47
48
|
let currentpageUrl = window.location.href;
|
|
48
49
|
const affiliateValue = getUrlParameter(currentpageUrl);
|
|
@@ -56,7 +57,7 @@ const handleDonateSubmission = (
|
|
|
56
57
|
}
|
|
57
58
|
const givingTypeUrl = givingType === 'single' ? 'single' : 'monthly';
|
|
58
59
|
|
|
59
|
-
window.location.href = `${donateLink}?clientOverride=${clientID}&amount=${amount}¤cy=GBP&givingType=${givingTypeUrl}&cartId=${cartID}&affiliate=${affiliateValue}&siteurl=${currentpageUrl}&rowID=${mbshipID}`;
|
|
60
|
+
window.location.href = `${donateLink}?clientOverride=${clientID}&amount=${amount}¤cy=GBP&givingType=${givingTypeUrl}&cartId=${cartID}&affiliate=${affiliateValue}&siteurl=${currentpageUrl}&rowID=${mbshipID}&popUpShown=${popUpShown}`;
|
|
60
61
|
};
|
|
61
62
|
|
|
62
63
|
export {
|