@comicrelief/component-library 8.52.2 → 8.53.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/.github/workflows/main.yml +1 -1
- package/dist/components/Molecules/CTA/CTAMultiCard/CTAMultiCard.md +1 -0
- package/dist/components/Molecules/CTA/CTAMultiCard/__snapshots__/CTAMultiCard.test.js.snap +280 -232
- package/dist/components/Molecules/CTA/CTASingleCard/__snapshots__/CTASingleCard.test.js.snap +68 -28
- package/dist/components/Molecules/CTA/shared/CTACard.js +1 -1
- package/dist/components/Molecules/CTA/shared/CTACard.style.js +11 -7
- package/dist/components/Organisms/Donate/Donate.js +3 -0
- package/dist/components/Organisms/Donate/Form/Form.js +0 -1
- package/dist/components/Organisms/DonateBanner/DonateBanner.js +132 -0
- package/dist/components/Organisms/DonateBanner/DonateBanner.md +168 -0
- package/dist/components/Organisms/DonateBanner/DonateBanner.style.js +291 -0
- package/dist/components/Organisms/DonateBanner/DonateBanner.test.js +134 -0
- package/dist/components/Organisms/DonateBanner/Form/Form.js +214 -0
- package/dist/components/Organisms/DonateBanner/Form/PopUpComponent.js +70 -0
- package/dist/components/Organisms/DonateBanner/GivingSelector/GivingSelector.js +50 -0
- package/dist/components/Organisms/DonateBanner/GivingSelector/GivingSelector.style.js +73 -0
- package/dist/components/Organisms/DonateBanner/MoneyBuy/MoneyBuy.js +83 -0
- package/dist/components/Organisms/DonateBanner/__snapshots__/DonateBanner.test.js.snap +3170 -0
- package/dist/components/Organisms/DonateBanner/_utils.js +41 -0
- package/dist/components/Organisms/DonateBanner/assets/close.svg +3 -0
- package/dist/components/Organisms/DonateBanner/dev-data/data-high-value.js +33 -0
- package/dist/components/Organisms/DonateBanner/dev-data/data-monthly.js +22 -0
- package/dist/components/Organisms/DonateBanner/dev-data/data-single.js +22 -0
- package/dist/components/Organisms/DonateBanner/dev-data/data.js +33 -0
- package/dist/index.js +7 -0
- package/package.json +1 -1
- package/src/components/Molecules/CTA/CTAMultiCard/CTAMultiCard.md +1 -0
- package/src/components/Molecules/CTA/CTAMultiCard/__snapshots__/CTAMultiCard.test.js.snap +280 -232
- package/src/components/Molecules/CTA/CTASingleCard/__snapshots__/CTASingleCard.test.js.snap +68 -28
- package/src/components/Molecules/CTA/shared/CTACard.js +6 -3
- package/src/components/Molecules/CTA/shared/CTACard.style.js +8 -0
- package/src/components/Organisms/Donate/Donate.js +5 -0
- package/src/components/Organisms/Donate/Form/Form.js +0 -1
- package/src/components/Organisms/DonateBanner/DonateBanner.js +210 -0
- package/src/components/Organisms/DonateBanner/DonateBanner.md +168 -0
- package/src/components/Organisms/DonateBanner/DonateBanner.style.js +320 -0
- package/src/components/Organisms/DonateBanner/DonateBanner.test.js +151 -0
- package/src/components/Organisms/DonateBanner/Form/Form.js +332 -0
- package/src/components/Organisms/DonateBanner/Form/PopUpComponent.js +110 -0
- package/src/components/Organisms/DonateBanner/GivingSelector/GivingSelector.js +61 -0
- package/src/components/Organisms/DonateBanner/GivingSelector/GivingSelector.style.js +71 -0
- package/src/components/Organisms/DonateBanner/MoneyBuy/MoneyBuy.js +58 -0
- package/src/components/Organisms/DonateBanner/__snapshots__/DonateBanner.test.js.snap +3170 -0
- package/src/components/Organisms/DonateBanner/_utils.js +34 -0
- package/src/components/Organisms/DonateBanner/assets/close.svg +3 -0
- package/src/components/Organisms/DonateBanner/dev-data/data-high-value.js +41 -0
- package/src/components/Organisms/DonateBanner/dev-data/data-monthly.js +23 -0
- package/src/components/Organisms/DonateBanner/dev-data/data-single.js +23 -0
- package/src/components/Organisms/DonateBanner/dev-data/data.js +41 -0
- package/src/index.js +1 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.Wrapper = exports.TitleWrapperOuter = exports.TitleWrapperInner = exports.SecondaryTitleText = exports.PrimaryTitleText = exports.OuterFieldset = exports.MoneyBuys = exports.Legend = exports.Label = exports.InnerContainer = exports.FormWrapper = exports.FormFieldset = exports.Form = exports.Error = exports.Copy = exports.Container = exports.Button = exports.BgImage = exports.AmountField = void 0;
|
|
9
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
10
|
+
var _Input = _interopRequireDefault(require("../../Atoms/Input/Input"));
|
|
11
|
+
var _Text = _interopRequireDefault(require("../../Atoms/Text/Text"));
|
|
12
|
+
var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
|
|
13
|
+
var _Picture = _interopRequireDefault(require("../../Atoms/Picture/Picture"));
|
|
14
|
+
var _zIndex = _interopRequireDefault(require("../../../theme/shared/zIndex"));
|
|
15
|
+
const Container = exports.Container = _styledComponents.default.div.withConfig({
|
|
16
|
+
displayName: "DonateBannerstyle__Container",
|
|
17
|
+
componentId: "sc-a4o3ek-0"
|
|
18
|
+
})(["position:relative;display:flex;flex-direction:column;justify-content:center;align-items:center;height:auto;margin:", ";background-color:", ";width:100%;padding:2rem;"], _ref => {
|
|
19
|
+
let {
|
|
20
|
+
paddingAbove,
|
|
21
|
+
paddingBelow
|
|
22
|
+
} = _ref;
|
|
23
|
+
return `${paddingAbove} 0 ${paddingBelow}`;
|
|
24
|
+
}, _ref2 => {
|
|
25
|
+
let {
|
|
26
|
+
theme,
|
|
27
|
+
pageBackgroundColour
|
|
28
|
+
} = _ref2;
|
|
29
|
+
return theme.color(pageBackgroundColour);
|
|
30
|
+
});
|
|
31
|
+
const InnerContainer = exports.InnerContainer = _styledComponents.default.div.withConfig({
|
|
32
|
+
displayName: "DonateBannerstyle__InnerContainer",
|
|
33
|
+
componentId: "sc-a4o3ek-1"
|
|
34
|
+
})(["position:relative;background-color:", ";border-radius:1rem;overflow:hidden;padding:none;width:100%;box-sizing:border-box;@media ", "{padding:", ";", "}@media ", "{padding-left:", ";padding-right:", ";}max-width:1500px;"], _ref3 => {
|
|
35
|
+
let {
|
|
36
|
+
theme,
|
|
37
|
+
componentBackgroundColour
|
|
38
|
+
} = _ref3;
|
|
39
|
+
return theme.color(componentBackgroundColour);
|
|
40
|
+
}, _ref4 => {
|
|
41
|
+
let {
|
|
42
|
+
theme
|
|
43
|
+
} = _ref4;
|
|
44
|
+
return theme.allBreakpoints('L');
|
|
45
|
+
}, (0, _spacing.default)('l'), _ref5 => {
|
|
46
|
+
let {
|
|
47
|
+
$donateWidgetIsTextOnly
|
|
48
|
+
} = _ref5;
|
|
49
|
+
return $donateWidgetIsTextOnly && (0, _styledComponents.css)(["padding-top:7.5rem;padding-bottom:7.5rem;"]);
|
|
50
|
+
}, _ref6 => {
|
|
51
|
+
let {
|
|
52
|
+
theme
|
|
53
|
+
} = _ref6;
|
|
54
|
+
return theme.allBreakpoints('XL');
|
|
55
|
+
}, (0, _spacing.default)('xxl'), (0, _spacing.default)('xxl'));
|
|
56
|
+
const BgImage = exports.BgImage = (0, _styledComponents.default)(_Picture.default).withConfig({
|
|
57
|
+
displayName: "DonateBannerstyle__BgImage",
|
|
58
|
+
componentId: "sc-a4o3ek-2"
|
|
59
|
+
})(["display:block;position:absolute;bottom:0;left:0;right:0;height:100%;"]);
|
|
60
|
+
const Wrapper = exports.Wrapper = _styledComponents.default.div.withConfig({
|
|
61
|
+
displayName: "DonateBannerstyle__Wrapper",
|
|
62
|
+
componentId: "sc-a4o3ek-3"
|
|
63
|
+
})(["position:relative;text-align:center;align-items:center;display:block;width:100%;", " ", ";@media ", "{display:flex;padding:", " ", ";gap:", ";flex-direction:row;}"], _ref7 => {
|
|
64
|
+
let {
|
|
65
|
+
hasTopImage,
|
|
66
|
+
shouldShowTitleSection
|
|
67
|
+
} = _ref7;
|
|
68
|
+
return hasTopImage && !shouldShowTitleSection && (0, _styledComponents.css)(["padding:0;"]);
|
|
69
|
+
}, _ref8 => {
|
|
70
|
+
let {
|
|
71
|
+
noTitlesAtAll
|
|
72
|
+
} = _ref8;
|
|
73
|
+
return noTitlesAtAll === true && (0, _styledComponents.css)(["justify-content:center;"]);
|
|
74
|
+
}, _ref9 => {
|
|
75
|
+
let {
|
|
76
|
+
theme
|
|
77
|
+
} = _ref9;
|
|
78
|
+
return theme.allBreakpoints('L');
|
|
79
|
+
}, (0, _spacing.default)('l'), (0, _spacing.default)('md'), (0, _spacing.default)('l'));
|
|
80
|
+
const TitleWrapperOuter = exports.TitleWrapperOuter = _styledComponents.default.div.withConfig({
|
|
81
|
+
displayName: "DonateBannerstyle__TitleWrapperOuter",
|
|
82
|
+
componentId: "sc-a4o3ek-4"
|
|
83
|
+
})(["width:100%;display:flex;font-family:", ";padding-bottom:", ";@media ", "{flex:1 1 0;width:auto;padding:0;align-items:center;order:", ";}"], _ref10 => {
|
|
84
|
+
let {
|
|
85
|
+
theme
|
|
86
|
+
} = _ref10;
|
|
87
|
+
return theme.fontFamilies(theme.font.regular);
|
|
88
|
+
}, (0, _spacing.default)('l'), _ref11 => {
|
|
89
|
+
let {
|
|
90
|
+
theme
|
|
91
|
+
} = _ref11;
|
|
92
|
+
return theme.allBreakpoints('L');
|
|
93
|
+
}, _ref12 => {
|
|
94
|
+
let {
|
|
95
|
+
donateOrientation
|
|
96
|
+
} = _ref12;
|
|
97
|
+
return donateOrientation === 'left' ? 2 : 1;
|
|
98
|
+
});
|
|
99
|
+
const TitleWrapperInner = exports.TitleWrapperInner = _styledComponents.default.div.withConfig({
|
|
100
|
+
displayName: "DonateBannerstyle__TitleWrapperInner",
|
|
101
|
+
componentId: "sc-a4o3ek-5"
|
|
102
|
+
})(["position:relative;text-align:left;"]);
|
|
103
|
+
const FormWrapper = exports.FormWrapper = _styledComponents.default.div.withConfig({
|
|
104
|
+
displayName: "DonateBannerstyle__FormWrapper",
|
|
105
|
+
componentId: "sc-a4o3ek-6"
|
|
106
|
+
})(["position:relative;font-family:", ";@media ", "{flex:1 1 0;min-width:0;width:auto;display:flex;justify-content:", ";order:", ";}"], _ref13 => {
|
|
107
|
+
let {
|
|
108
|
+
theme
|
|
109
|
+
} = _ref13;
|
|
110
|
+
return theme.fontFamilies(theme.font.regular);
|
|
111
|
+
}, _ref14 => {
|
|
112
|
+
let {
|
|
113
|
+
theme
|
|
114
|
+
} = _ref14;
|
|
115
|
+
return theme.allBreakpoints('L');
|
|
116
|
+
}, _ref15 => {
|
|
117
|
+
let {
|
|
118
|
+
donateOrientation
|
|
119
|
+
} = _ref15;
|
|
120
|
+
return donateOrientation === 'left' ? 'flex-start' : 'flex-end';
|
|
121
|
+
}, _ref16 => {
|
|
122
|
+
let {
|
|
123
|
+
donateOrientation
|
|
124
|
+
} = _ref16;
|
|
125
|
+
return donateOrientation === 'left' ? 1 : 2;
|
|
126
|
+
});
|
|
127
|
+
const Error = exports.Error = (0, _styledComponents.default)(_Text.default).withConfig({
|
|
128
|
+
displayName: "DonateBannerstyle__Error",
|
|
129
|
+
componentId: "sc-a4o3ek-7"
|
|
130
|
+
})(["color:", ";font-size:", ";font-weight:500;margin-top:", ";"], _ref17 => {
|
|
131
|
+
let {
|
|
132
|
+
theme
|
|
133
|
+
} = _ref17;
|
|
134
|
+
return theme.color('red');
|
|
135
|
+
}, _ref18 => {
|
|
136
|
+
let {
|
|
137
|
+
theme
|
|
138
|
+
} = _ref18;
|
|
139
|
+
return theme.fontSize('s');
|
|
140
|
+
}, (0, _spacing.default)('l'));
|
|
141
|
+
const Form = exports.Form = _styledComponents.default.form.withConfig({
|
|
142
|
+
displayName: "DonateBannerstyle__Form",
|
|
143
|
+
componentId: "sc-a4o3ek-8"
|
|
144
|
+
})(["position:relative;width:100%;background-color:", ";box-shadow:0px 0px 16px rgba(0,0,0,0.15);margin-left:auto;margin-right:auto;", " h3{margin-top:", ";}input{max-width:100%;margin:0;}input[type='submit']{margin:", " 0;}@media ", "{width:100%;margin-right:auto;margin-left:auto;}@media ", "{margin-top:", ";border-radius:0.5rem;max-width:461px;min-width:400px;margin-left:0;margin-right:0;}"], _ref19 => {
|
|
145
|
+
let {
|
|
146
|
+
theme
|
|
147
|
+
} = _ref19;
|
|
148
|
+
return theme.color('white');
|
|
149
|
+
}, _ref20 => {
|
|
150
|
+
let {
|
|
151
|
+
hasTopImage,
|
|
152
|
+
shouldShowTitleSection
|
|
153
|
+
} = _ref20;
|
|
154
|
+
return hasTopImage && !shouldShowTitleSection && (0, _styledComponents.css)(["margin-top:0;"]);
|
|
155
|
+
}, (0, _spacing.default)('md'), (0, _spacing.default)('l'), _ref21 => {
|
|
156
|
+
let {
|
|
157
|
+
theme
|
|
158
|
+
} = _ref21;
|
|
159
|
+
return theme.allBreakpoints('M');
|
|
160
|
+
}, _ref22 => {
|
|
161
|
+
let {
|
|
162
|
+
theme
|
|
163
|
+
} = _ref22;
|
|
164
|
+
return theme.allBreakpoints('L');
|
|
165
|
+
}, (0, _spacing.default)('md'));
|
|
166
|
+
const OuterFieldset = exports.OuterFieldset = _styledComponents.default.fieldset.withConfig({
|
|
167
|
+
displayName: "DonateBannerstyle__OuterFieldset",
|
|
168
|
+
componentId: "sc-a4o3ek-9"
|
|
169
|
+
})(["color:", ";padding:0 ", " ", ";margin:0;border:none;@media ", "{padding:0 ", " ", ";}input[type='submit']{margin-bottom:0;}"], _ref23 => {
|
|
170
|
+
let {
|
|
171
|
+
theme
|
|
172
|
+
} = _ref23;
|
|
173
|
+
return theme.color('black');
|
|
174
|
+
}, (0, _spacing.default)('md'), (0, _spacing.default)('md'), _ref24 => {
|
|
175
|
+
let {
|
|
176
|
+
theme
|
|
177
|
+
} = _ref24;
|
|
178
|
+
return theme.allBreakpoints('M');
|
|
179
|
+
}, (0, _spacing.default)('l'), (0, _spacing.default)('l'));
|
|
180
|
+
const Legend = exports.Legend = _styledComponents.default.legend.withConfig({
|
|
181
|
+
displayName: "DonateBannerstyle__Legend",
|
|
182
|
+
componentId: "sc-a4o3ek-10"
|
|
183
|
+
})(["margin:0;padding:", " ", " 0 ", ";display:block;width:100%;"], (0, _spacing.default)('l'), (0, _spacing.default)('sm'), (0, _spacing.default)('sm'));
|
|
184
|
+
const PrimaryTitleText = exports.PrimaryTitleText = (0, _styledComponents.default)(_Text.default).withConfig({
|
|
185
|
+
displayName: "DonateBannerstyle__PrimaryTitleText",
|
|
186
|
+
componentId: "sc-a4o3ek-11"
|
|
187
|
+
})(["display:block;text-align:left;font-size:", ";font-weight:700;"], _ref25 => {
|
|
188
|
+
let {
|
|
189
|
+
theme
|
|
190
|
+
} = _ref25;
|
|
191
|
+
return theme.fontSize('s');
|
|
192
|
+
});
|
|
193
|
+
const SecondaryTitleText = exports.SecondaryTitleText = (0, _styledComponents.default)(_Text.default).withConfig({
|
|
194
|
+
displayName: "DonateBannerstyle__SecondaryTitleText",
|
|
195
|
+
componentId: "sc-a4o3ek-12"
|
|
196
|
+
})(["display:block;text-align:left;font-size:", ";line-height:1.5;margin-top:", ";"], _ref26 => {
|
|
197
|
+
let {
|
|
198
|
+
theme
|
|
199
|
+
} = _ref26;
|
|
200
|
+
return theme.fontSize('s');
|
|
201
|
+
}, (0, _spacing.default)('sm'));
|
|
202
|
+
const MoneyBuys = exports.MoneyBuys = _styledComponents.default.div.withConfig({
|
|
203
|
+
displayName: "DonateBannerstyle__MoneyBuys",
|
|
204
|
+
componentId: "sc-a4o3ek-13"
|
|
205
|
+
})(["display:flex;justify-content:space-between;flex-direction:column;margin-bottom:", ";@media ", "{flex-direction:row;margin-top:", ";}label{flex:0 0 31%;margin-bottom:", ";@media ", "{margin-bottom:0;}input{cursor:pointer;padding:", " ", ";}}"], (0, _spacing.default)('md'), _ref27 => {
|
|
206
|
+
let {
|
|
207
|
+
theme
|
|
208
|
+
} = _ref27;
|
|
209
|
+
return theme.allBreakpoints('M');
|
|
210
|
+
}, (0, _spacing.default)('m'), (0, _spacing.default)('sm'), _ref28 => {
|
|
211
|
+
let {
|
|
212
|
+
theme
|
|
213
|
+
} = _ref28;
|
|
214
|
+
return theme.allBreakpoints('M');
|
|
215
|
+
}, (0, _spacing.default)('sm'), (0, _spacing.default)('m'));
|
|
216
|
+
const FormFieldset = exports.FormFieldset = _styledComponents.default.div.withConfig({
|
|
217
|
+
displayName: "DonateBannerstyle__FormFieldset",
|
|
218
|
+
componentId: "sc-a4o3ek-14"
|
|
219
|
+
})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;"]);
|
|
220
|
+
const Label = exports.Label = (0, _styledComponents.default)(_Text.default).withConfig({
|
|
221
|
+
displayName: "DonateBannerstyle__Label",
|
|
222
|
+
componentId: "sc-a4o3ek-15"
|
|
223
|
+
})(["margin-bottom:", ";"], (0, _spacing.default)('sm'));
|
|
224
|
+
const AmountField = exports.AmountField = (0, _styledComponents.default)(_Input.default).withConfig({
|
|
225
|
+
displayName: "DonateBannerstyle__AmountField",
|
|
226
|
+
componentId: "sc-a4o3ek-16"
|
|
227
|
+
})(["position:relative;flex-basis:50%;flex-shrink:0;flex-grow:0;font-weight:400;display:block;", " @media ", "{flex-basis:60%;}span{position:absolute;font-size:20px;top:50%;transform:translateY(-50%);left:0px;font-weight:500;padding:0px 15px;", ";}input{height:48px;border:1px solid ", ";background:", ";border-radius:0.5rem;padding:", " ", " ", " ", ";&:focus{outline:none;border:1px solid ", ";}}"], _ref29 => {
|
|
228
|
+
let {
|
|
229
|
+
$noMoneyBuys
|
|
230
|
+
} = _ref29;
|
|
231
|
+
return $noMoneyBuys === true && (0, _styledComponents.css)(["margin-top:", ";"], (0, _spacing.default)('sm'));
|
|
232
|
+
}, _ref30 => {
|
|
233
|
+
let {
|
|
234
|
+
theme
|
|
235
|
+
} = _ref30;
|
|
236
|
+
return theme.allBreakpoints('M');
|
|
237
|
+
}, (0, _zIndex.default)('high'), _ref31 => {
|
|
238
|
+
let {
|
|
239
|
+
theme
|
|
240
|
+
} = _ref31;
|
|
241
|
+
return theme.color('grey');
|
|
242
|
+
}, _ref32 => {
|
|
243
|
+
let {
|
|
244
|
+
theme
|
|
245
|
+
} = _ref32;
|
|
246
|
+
return theme.color('grey_light');
|
|
247
|
+
}, (0, _spacing.default)('sm'), (0, _spacing.default)('md'), (0, _spacing.default)('sm'), (0, _spacing.default)('l'), _ref33 => {
|
|
248
|
+
let {
|
|
249
|
+
theme
|
|
250
|
+
} = _ref33;
|
|
251
|
+
return theme.color('grey');
|
|
252
|
+
});
|
|
253
|
+
const Copy = exports.Copy = _styledComponents.default.p.withConfig({
|
|
254
|
+
displayName: "DonateBannerstyle__Copy",
|
|
255
|
+
componentId: "sc-a4o3ek-17"
|
|
256
|
+
})(["line-height:1.5;margin-top:", ";color:", ";"], (0, _spacing.default)('l'), _ref34 => {
|
|
257
|
+
let {
|
|
258
|
+
theme
|
|
259
|
+
} = _ref34;
|
|
260
|
+
return theme.color('black');
|
|
261
|
+
});
|
|
262
|
+
const Button = exports.Button = _styledComponents.default.button.withConfig({
|
|
263
|
+
displayName: "DonateBannerstyle__Button",
|
|
264
|
+
componentId: "sc-a4o3ek-18"
|
|
265
|
+
})(["width:100%;margin:", " 0 ", ";color:", ";font-size:", ";font-weight:bold;cursor:pointer;min-height:48px;background:", ";text-decoration:none;border-radius:0.5rem;border:none;appearance:none;:active,:focus,:hover{outline:none;background-color:", ";}@media ", "{padding:", " ", ";}"], (0, _spacing.default)('sm'), (0, _spacing.default)('sm'), _ref35 => {
|
|
266
|
+
let {
|
|
267
|
+
theme
|
|
268
|
+
} = _ref35;
|
|
269
|
+
return theme.color('white');
|
|
270
|
+
}, _ref36 => {
|
|
271
|
+
let {
|
|
272
|
+
theme
|
|
273
|
+
} = _ref36;
|
|
274
|
+
return theme.fontSize('s');
|
|
275
|
+
}, _ref37 => {
|
|
276
|
+
let {
|
|
277
|
+
theme,
|
|
278
|
+
color
|
|
279
|
+
} = _ref37;
|
|
280
|
+
return theme.color(color);
|
|
281
|
+
}, _ref38 => {
|
|
282
|
+
let {
|
|
283
|
+
theme
|
|
284
|
+
} = _ref38;
|
|
285
|
+
return theme.color('coral_dark');
|
|
286
|
+
}, _ref39 => {
|
|
287
|
+
let {
|
|
288
|
+
theme
|
|
289
|
+
} = _ref39;
|
|
290
|
+
return theme.allBreakpoints('M');
|
|
291
|
+
}, (0, _spacing.default)('md'), (0, _spacing.default)('l'));
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
require("jest-styled-components");
|
|
6
|
+
var _shallowWithTheme = _interopRequireDefault(require("../../../../tests/hoc/shallowWithTheme"));
|
|
7
|
+
var _DonateBanner = _interopRequireDefault(require("./DonateBanner"));
|
|
8
|
+
var _data = _interopRequireDefault(require("./dev-data/data"));
|
|
9
|
+
var _dataSingle = _interopRequireDefault(require("./dev-data/data-single"));
|
|
10
|
+
const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
11
|
+
it('Monthly donation renders correctly', () => {
|
|
12
|
+
const imageL = {
|
|
13
|
+
images: defaultData.pictures.images,
|
|
14
|
+
imageLow: defaultData.pictures.imageLow,
|
|
15
|
+
alt: 'Background image'
|
|
16
|
+
};
|
|
17
|
+
const imageM = {
|
|
18
|
+
images: defaultData.pictures.images,
|
|
19
|
+
imageLow: defaultData.pictures.imageLow,
|
|
20
|
+
alt: 'Background image'
|
|
21
|
+
};
|
|
22
|
+
const imageS = {
|
|
23
|
+
images: defaultData.pictures.images,
|
|
24
|
+
imageLow: defaultData.pictures.imageLow,
|
|
25
|
+
alt: 'Background image'
|
|
26
|
+
};
|
|
27
|
+
const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_DonateBanner.default, {
|
|
28
|
+
pageBackgroundColour: "grey_light",
|
|
29
|
+
paddingAbove: "0rem",
|
|
30
|
+
paddingBelow: "2rem",
|
|
31
|
+
donateOrientation: "right",
|
|
32
|
+
imageL: imageL,
|
|
33
|
+
imageM: imageM,
|
|
34
|
+
imageS: imageS,
|
|
35
|
+
data: _data.default,
|
|
36
|
+
mbshipID: "mbship-1",
|
|
37
|
+
donateLink: "https://donation.comicrelief.com/",
|
|
38
|
+
clientID: "donate",
|
|
39
|
+
cartID: "default-comicrelief",
|
|
40
|
+
title: "Donate Now",
|
|
41
|
+
subtitle: "Please help us fund life-changing projects in the UK and around the world."
|
|
42
|
+
})).toJSON();
|
|
43
|
+
expect(tree).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
it('Single donation renders correctly', () => {
|
|
46
|
+
const imageL = {
|
|
47
|
+
images: defaultData.pictures.images,
|
|
48
|
+
imageLow: defaultData.pictures.imageLow,
|
|
49
|
+
alt: 'Background image'
|
|
50
|
+
};
|
|
51
|
+
const imageM = {
|
|
52
|
+
images: defaultData.pictures.images,
|
|
53
|
+
imageLow: defaultData.pictures.imageLow,
|
|
54
|
+
alt: 'Background image'
|
|
55
|
+
};
|
|
56
|
+
const imageS = {
|
|
57
|
+
images: defaultData.pictures.images,
|
|
58
|
+
imageLow: defaultData.pictures.imageLow,
|
|
59
|
+
alt: 'Background image'
|
|
60
|
+
};
|
|
61
|
+
const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_DonateBanner.default, {
|
|
62
|
+
pageBackgroundColour: "grey_light",
|
|
63
|
+
paddingAbove: "2rem",
|
|
64
|
+
paddingBelow: "2rem",
|
|
65
|
+
donateOrientation: "left",
|
|
66
|
+
imageL: imageL,
|
|
67
|
+
imageM: imageM,
|
|
68
|
+
imageS: imageS,
|
|
69
|
+
data: _dataSingle.default,
|
|
70
|
+
mbshipID: "mbship-1",
|
|
71
|
+
donateLink: "https://donation.comicrelief.com/",
|
|
72
|
+
clientID: "donate",
|
|
73
|
+
cartID: "default-comicrelief",
|
|
74
|
+
title: "Donate Now",
|
|
75
|
+
subtitle: "Please help us fund life-changing projects in the UK and around the world."
|
|
76
|
+
})).toJSON();
|
|
77
|
+
expect(tree).toMatchSnapshot();
|
|
78
|
+
});
|
|
79
|
+
it('Single donation with no Money Buys renders correctly', () => {
|
|
80
|
+
const imageL = {
|
|
81
|
+
images: defaultData.pictures.images,
|
|
82
|
+
imageLow: defaultData.pictures.imageLow,
|
|
83
|
+
alt: 'Background image'
|
|
84
|
+
};
|
|
85
|
+
const imageM = {
|
|
86
|
+
images: defaultData.pictures.images,
|
|
87
|
+
imageLow: defaultData.pictures.imageLow,
|
|
88
|
+
alt: 'Background image'
|
|
89
|
+
};
|
|
90
|
+
const imageS = {
|
|
91
|
+
images: defaultData.pictures.images,
|
|
92
|
+
imageLow: defaultData.pictures.imageLow,
|
|
93
|
+
alt: 'Background image'
|
|
94
|
+
};
|
|
95
|
+
const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_DonateBanner.default, {
|
|
96
|
+
pageBackgroundColour: "grey_light",
|
|
97
|
+
paddingAbove: "0rem",
|
|
98
|
+
paddingBelow: "0rem",
|
|
99
|
+
donateOrientation: "right",
|
|
100
|
+
imageL: imageL,
|
|
101
|
+
imageM: imageM,
|
|
102
|
+
imageS: imageS,
|
|
103
|
+
data: _dataSingle.default,
|
|
104
|
+
mbshipID: "mbship-1",
|
|
105
|
+
donateLink: "https://donation.comicrelief.com/",
|
|
106
|
+
clientID: "donate",
|
|
107
|
+
cartID: "default-comicrelief",
|
|
108
|
+
title: "Donate Now",
|
|
109
|
+
noMoneyBuys: true,
|
|
110
|
+
subtitle: "Please help us fund life-changing projects in the UK and around the world.",
|
|
111
|
+
chooseAmountText: "Overridden choose amount text"
|
|
112
|
+
})).toJSON();
|
|
113
|
+
expect(tree).toMatchSnapshot();
|
|
114
|
+
});
|
|
115
|
+
it('Text-only donate widget renders correctly', () => {
|
|
116
|
+
const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_DonateBanner.default, {
|
|
117
|
+
donateWidgetIsTextOnly: true,
|
|
118
|
+
pageBackgroundColour: "grey_light",
|
|
119
|
+
componentBackgroundColour: "deep_violet_dark",
|
|
120
|
+
paddingAbove: "2rem",
|
|
121
|
+
paddingBelow: "2rem",
|
|
122
|
+
donateOrientation: "right",
|
|
123
|
+
data: _data.default,
|
|
124
|
+
mbshipID: "mbship-4",
|
|
125
|
+
donateLink: "https://donation.comicrelief.com/",
|
|
126
|
+
clientID: "donate",
|
|
127
|
+
cartID: "default-comicrelief",
|
|
128
|
+
title: "Donate Now",
|
|
129
|
+
noMoneyBuys: true,
|
|
130
|
+
subtitle: "Please help us fund life-changing projects in the UK and around the world.",
|
|
131
|
+
chooseAmountText: "Enter an amount to give"
|
|
132
|
+
})).toJSON();
|
|
133
|
+
expect(tree).toMatchSnapshot();
|
|
134
|
+
});
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _PopUpComponent = _interopRequireDefault(require("./PopUpComponent"));
|
|
11
|
+
var _MoneyBuy = _interopRequireDefault(require("../MoneyBuy/MoneyBuy"));
|
|
12
|
+
var _Membership = require("../../../../utils/Membership");
|
|
13
|
+
var _DonateBanner = require("../DonateBanner.style");
|
|
14
|
+
var _GivingSelector = _interopRequireDefault(require("../GivingSelector/GivingSelector"));
|
|
15
|
+
const Signup = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
data: {
|
|
18
|
+
singleGiving,
|
|
19
|
+
regularGiving
|
|
20
|
+
},
|
|
21
|
+
donateLink,
|
|
22
|
+
otherAmountText,
|
|
23
|
+
clientID,
|
|
24
|
+
cartID,
|
|
25
|
+
mbshipID,
|
|
26
|
+
donateOrientation = 'right',
|
|
27
|
+
noMoneyBuys = false,
|
|
28
|
+
popUpText,
|
|
29
|
+
chooseAmountText = null,
|
|
30
|
+
monthlyChooseAmountText = null,
|
|
31
|
+
submitButtonColor = 'red',
|
|
32
|
+
changeGivingType,
|
|
33
|
+
givingType = null,
|
|
34
|
+
hasTopImage = false,
|
|
35
|
+
shouldShowTitleSection = false,
|
|
36
|
+
...rest
|
|
37
|
+
} = _ref;
|
|
38
|
+
const [errorMsg, setErrorMsg] = (0, _react.useState)(false);
|
|
39
|
+
const [amountDonate, setAmountDonate] = (0, _react.useState)(10);
|
|
40
|
+
const [moneyBuyCopy, setMoneyBuyCopy] = (0, _react.useState)(true);
|
|
41
|
+
const [popOpen, setPopOpen] = (0, _react.useState)(false);
|
|
42
|
+
// In order to keep track of whether the user has ever been shown the popup
|
|
43
|
+
const [popUpShown, setPopUpShown] = (0, _react.useState)(false);
|
|
44
|
+
(0, _react.useEffect)(() => {
|
|
45
|
+
if (givingType) {
|
|
46
|
+
const givingData = givingType === 'single' ? singleGiving : regularGiving;
|
|
47
|
+
|
|
48
|
+
// Check the 2nd moneybuy exists before using it;
|
|
49
|
+
// 'philantrophy' carts have been set up to use a single moneybuy.
|
|
50
|
+
// See ENG-1685 for more details
|
|
51
|
+
const thisAmount = givingData.moneybuys[1] ? givingData.moneybuys[1].value : givingData.moneybuys[0].value;
|
|
52
|
+
setAmountDonate(thisAmount);
|
|
53
|
+
}
|
|
54
|
+
// Pass givingType up to parent for copy-switching logic:
|
|
55
|
+
changeGivingType(givingType);
|
|
56
|
+
}, [givingType, singleGiving, regularGiving, changeGivingType]);
|
|
57
|
+
(0, _react.useEffect)(() => {
|
|
58
|
+
if (givingType) {
|
|
59
|
+
const givingData = givingType === 'single' ? singleGiving : regularGiving;
|
|
60
|
+
let moneyBuyUpdatedDescription = otherAmountText;
|
|
61
|
+
givingData.moneybuys.map((moneyBuy, index) => {
|
|
62
|
+
// Only show the MB-associated copy when we're actually showing moneybuys
|
|
63
|
+
if (moneyBuy.value === amountDonate && !noMoneyBuys) {
|
|
64
|
+
moneyBuyUpdatedDescription = moneyBuy.description;
|
|
65
|
+
}
|
|
66
|
+
return index === 1 && amountDonate === undefined && (setMoneyBuyCopy(moneyBuy.description), setAmountDonate(moneyBuy.value));
|
|
67
|
+
});
|
|
68
|
+
if (!(0, _Membership.isAmountValid)(amountDonate)) {
|
|
69
|
+
if (moneyBuyCopy) setMoneyBuyCopy(false);
|
|
70
|
+
if (!errorMsg) setErrorMsg(true);
|
|
71
|
+
} else {
|
|
72
|
+
if (errorMsg) setErrorMsg(false);
|
|
73
|
+
setMoneyBuyCopy(moneyBuyUpdatedDescription);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}, [errorMsg, moneyBuyCopy, singleGiving, regularGiving, givingType, amountDonate, otherAmountText, noMoneyBuys]);
|
|
77
|
+
|
|
78
|
+
// Updates our flag that differentiates between the popup
|
|
79
|
+
// being *currently* open and it *ever* having been shown to user
|
|
80
|
+
(0, _react.useEffect)(() => {
|
|
81
|
+
if (popOpen && !popUpShown) setPopUpShown(true);
|
|
82
|
+
}, [popOpen, popUpShown]);
|
|
83
|
+
|
|
84
|
+
// On load, determine what should actually be the default giving type
|
|
85
|
+
(0, _react.useEffect)(() => {
|
|
86
|
+
const newGivingType = singleGiving !== null ? 'single' : 'monthly';
|
|
87
|
+
changeGivingType(newGivingType);
|
|
88
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
89
|
+
}, []);
|
|
90
|
+
const submitDonation = (event, amount, clientId, cartId, mbshipId, donateURL) => {
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
if ((0, _Membership.isAmountValid)(amount) && !errorMsg) {
|
|
93
|
+
(0, _Membership.handleDonateSubmission)(amount, clientId, cartId, mbshipId, donateURL, givingType, popUpShown);
|
|
94
|
+
} else {
|
|
95
|
+
setErrorMsg(true);
|
|
96
|
+
setMoneyBuyCopy(false);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Create money buy boxes
|
|
101
|
+
const givingData = givingType === 'single' ? singleGiving : regularGiving;
|
|
102
|
+
const showGivingSelector = singleGiving !== null && regularGiving !== null;
|
|
103
|
+
|
|
104
|
+
// Create ref for amount input
|
|
105
|
+
const amountRef = (0, _react.useRef)(null);
|
|
106
|
+
// Create ref for amount button
|
|
107
|
+
const buttonRef = (0, _react.useRef)(null);
|
|
108
|
+
const handleClickOutside = (0, _react.useCallback)(event => {
|
|
109
|
+
if (!errorMsg) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (buttonRef.current && event.target === buttonRef.current) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (amountRef.current && !amountRef.current.contains(event.target)) {
|
|
116
|
+
// Check the 2nd moneybuy exists before using it;
|
|
117
|
+
// 'philantrophy' carts have been set up to use a single moneybuy.
|
|
118
|
+
// See ENG-1685 for more details
|
|
119
|
+
const thisAmount = givingData.moneybuys[1] ? givingData.moneybuys[1].value : givingData.moneybuys[0].value;
|
|
120
|
+
setAmountDonate(thisAmount);
|
|
121
|
+
}
|
|
122
|
+
}, [errorMsg, givingData]);
|
|
123
|
+
|
|
124
|
+
// Listen for click outside custom amount input if there is no value entered.
|
|
125
|
+
(0, _react.useEffect)(() => {
|
|
126
|
+
// Bind the event listener
|
|
127
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
128
|
+
return () => {
|
|
129
|
+
// Unbind the event listener on clean up
|
|
130
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
131
|
+
};
|
|
132
|
+
}, [errorMsg, handleClickOutside]);
|
|
133
|
+
|
|
134
|
+
// Create function to conditionally render button text
|
|
135
|
+
const renderButtonText = () => {
|
|
136
|
+
if (errorMsg) {
|
|
137
|
+
return 'Donate';
|
|
138
|
+
}
|
|
139
|
+
if (givingType === 'single') {
|
|
140
|
+
return `Donate £${amountDonate} now`;
|
|
141
|
+
}
|
|
142
|
+
return `Donate £${amountDonate} monthly`;
|
|
143
|
+
};
|
|
144
|
+
const defaultChooseAmountText = `${noMoneyBuys ? 'Enter' : 'Choose'} an amount to give`;
|
|
145
|
+
const thisChooseAmountText = givingType === 'monthly' && monthlyChooseAmountText ? monthlyChooseAmountText : chooseAmountText || defaultChooseAmountText;
|
|
146
|
+
return /*#__PURE__*/_react.default.createElement(_DonateBanner.FormWrapper, {
|
|
147
|
+
donateOrientation: donateOrientation,
|
|
148
|
+
shouldShowTitleSection: shouldShowTitleSection
|
|
149
|
+
}, popOpen && /*#__PURE__*/_react.default.createElement(_PopUpComponent.default, {
|
|
150
|
+
popUpText: popUpText,
|
|
151
|
+
setPopOpen: setPopOpen
|
|
152
|
+
}), /*#__PURE__*/_react.default.createElement(_DonateBanner.Form, {
|
|
153
|
+
donateOrientation: donateOrientation,
|
|
154
|
+
hasTopImage: hasTopImage,
|
|
155
|
+
shouldShowTitleSection: shouldShowTitleSection,
|
|
156
|
+
onSubmit: e => submitDonation(e, amountDonate, clientID, cartID, mbshipID, donateLink)
|
|
157
|
+
}, /*#__PURE__*/_react.default.createElement(_DonateBanner.OuterFieldset, null, /*#__PURE__*/_react.default.createElement(_DonateBanner.Legend, null, /*#__PURE__*/_react.default.createElement(_DonateBanner.PrimaryTitleText, {
|
|
158
|
+
tag: "span",
|
|
159
|
+
color: "black"
|
|
160
|
+
}, thisChooseAmountText)), showGivingSelector && /*#__PURE__*/_react.default.createElement(_GivingSelector.default, {
|
|
161
|
+
givingType: givingType,
|
|
162
|
+
changeGivingType: data => changeGivingType(data),
|
|
163
|
+
setPopOpen: setPopOpen,
|
|
164
|
+
mbshipID: mbshipID
|
|
165
|
+
}), !noMoneyBuys && givingType && /*#__PURE__*/_react.default.createElement(_DonateBanner.MoneyBuys, null, givingData.moneybuys.map((_ref2, index) => {
|
|
166
|
+
let {
|
|
167
|
+
value
|
|
168
|
+
} = _ref2;
|
|
169
|
+
return /*#__PURE__*/_react.default.createElement(_MoneyBuy.default, {
|
|
170
|
+
isSelected: amountDonate === value,
|
|
171
|
+
amount: value.toString(),
|
|
172
|
+
description: `£${(0, _Membership.amountFormatter)(value)}`,
|
|
173
|
+
setOtherAmount: () => setAmountDonate(value),
|
|
174
|
+
key: value,
|
|
175
|
+
name: `${mbshipID}--moneyBuy${index + 1}`,
|
|
176
|
+
id: `${mbshipID}--moneyBuy-box${index + 1}`
|
|
177
|
+
});
|
|
178
|
+
})), /*#__PURE__*/_react.default.createElement(_DonateBanner.FormFieldset, null, !noMoneyBuys && /*#__PURE__*/_react.default.createElement(_DonateBanner.Label, {
|
|
179
|
+
size: "s",
|
|
180
|
+
weight: "500",
|
|
181
|
+
color: "black"
|
|
182
|
+
}, "Enter another amount"), /*#__PURE__*/_react.default.createElement(_DonateBanner.AmountField, Object.assign({
|
|
183
|
+
$noMoneyBuys: noMoneyBuys,
|
|
184
|
+
step: "0.01",
|
|
185
|
+
name: "membership_amount",
|
|
186
|
+
type: "string",
|
|
187
|
+
inputBorderColor: (0, _Membership.isAmountValid)(amountDonate) === false,
|
|
188
|
+
prefix: "\xA3",
|
|
189
|
+
label: noMoneyBuys ? 'Donation amount' : 'Other donation amount',
|
|
190
|
+
errorMsg: "",
|
|
191
|
+
id: `${mbshipID}--MoneyBuy-userInput`,
|
|
192
|
+
showLabel: false
|
|
193
|
+
}, rest, {
|
|
194
|
+
max: "25000",
|
|
195
|
+
min: "1",
|
|
196
|
+
value: amountDonate,
|
|
197
|
+
pattern: "^[0-9]+([,.][0-9]{0,2})?$" // this only applies on submit
|
|
198
|
+
,
|
|
199
|
+
placeholder: "0.00",
|
|
200
|
+
onChange: e => setAmountDonate(e.target.value.trim()),
|
|
201
|
+
ref: amountRef
|
|
202
|
+
}))), amountDonate >= 1 && moneyBuyCopy && /*#__PURE__*/_react.default.createElement(_DonateBanner.Copy, null, /*#__PURE__*/_react.default.createElement("strong", null, `£${amountDonate} `), moneyBuyCopy), errorMsg && /*#__PURE__*/_react.default.createElement(_DonateBanner.Error, {
|
|
203
|
+
className: "error--amount",
|
|
204
|
+
tag: "p"
|
|
205
|
+
}, "Please enter an amount between \xA31 and \xA325000 and up to 2 decimal places"), /*#__PURE__*/_react.default.createElement(_DonateBanner.Button, {
|
|
206
|
+
type: "submit",
|
|
207
|
+
color: submitButtonColor,
|
|
208
|
+
ref: buttonRef
|
|
209
|
+
// Used by analytics:
|
|
210
|
+
,
|
|
211
|
+
className: "Button_DonateWidget"
|
|
212
|
+
}, renderButtonText()))));
|
|
213
|
+
};
|
|
214
|
+
var _default = exports.default = Signup;
|