@comicrelief/component-library 6.10.0 → 7.0.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/cypress/integration/components/Organisms/Donate.spec.js +13 -13
- package/cypress/integration/components/Organisms/EmailSignUp.spec.js +47 -132
- package/dist/components/Organisms/Donate/Donate.md +9 -9
- package/dist/components/Organisms/Donate/Form/Form.js +2 -1
- package/dist/components/Organisms/Donate/GivingSelector/GivingSelector.js +17 -71
- package/dist/components/Organisms/Donate/GivingSelector/GivingSelector.style.js +71 -0
- package/dist/components/Organisms/Donate/__snapshots__/Donate.test.js.snap +11 -25
- package/dist/components/Organisms/EmailSignUp/EmailSignUp.md +8 -123
- package/dist/components/Organisms/EmailSignUp/EmailSignUp.style.js +46 -29
- package/dist/components/Organisms/EmailSignUp/EmailSignUp.test.js +24 -69
- package/dist/components/Organisms/EmailSignUp/EmailSignUpForm.js +92 -0
- package/dist/components/Organisms/EmailSignUp/_Confetti.js +116 -0
- package/dist/components/Organisms/EmailSignUp/_EmailSignUp.js +107 -0
- package/dist/components/Organisms/EmailSignUp/_EmailSignUpConfig.js +51 -0
- package/dist/components/Organisms/EmailSignUp/_TextInput.js +51 -0
- package/dist/components/Organisms/EmailSignUp/__snapshots__/EmailSignUp.test.js.snap +249 -406
- package/dist/components/Organisms/Header/Header.md +1 -13
- package/dist/components/Organisms/Membership/Membership.test.js +1 -1
- package/dist/index.js +14 -10
- package/package.json +2 -1
- package/src/components/Organisms/Donate/Donate.md +9 -9
- package/src/components/Organisms/Donate/Form/Form.js +1 -0
- package/src/components/Organisms/Donate/GivingSelector/GivingSelector.js +15 -85
- package/src/components/Organisms/Donate/GivingSelector/GivingSelector.style.js +78 -0
- package/src/components/Organisms/Donate/__snapshots__/Donate.test.js.snap +11 -25
- package/src/components/Organisms/EmailSignUp/EmailSignUp.md +8 -123
- package/src/components/Organisms/EmailSignUp/EmailSignUp.style.js +33 -13
- package/src/components/Organisms/EmailSignUp/EmailSignUp.test.js +35 -69
- package/src/components/Organisms/EmailSignUp/EmailSignUpForm.js +60 -0
- package/src/components/Organisms/EmailSignUp/_Confetti.js +106 -0
- package/src/components/Organisms/EmailSignUp/_EmailSignUp.js +138 -0
- package/src/components/Organisms/EmailSignUp/_EmailSignUpConfig.js +54 -0
- package/src/components/Organisms/EmailSignUp/_TextInput.js +45 -0
- package/src/components/Organisms/EmailSignUp/__snapshots__/EmailSignUp.test.js.snap +249 -406
- package/src/components/Organisms/Header/Header.md +1 -13
- package/src/components/Organisms/Membership/Membership.test.js +33 -33
- package/src/index.js +10 -4
- package/cypress/integration/components/Molecules/HeaderEsuWithIcon.spec.js +0 -69
- package/dist/components/Molecules/HeaderEsuWithIcon/HeaderEsuWithIcon.js +0 -136
- package/dist/components/Molecules/HeaderEsuWithIcon/HeaderEsuWithIcon.md +0 -47
- package/dist/components/Molecules/HeaderEsuWithIcon/HeaderEsuWithIcon.style.js +0 -52
- package/dist/components/Molecules/HeaderEsuWithIcon/HeaderEsuWithIcon.test.js +0 -99
- package/dist/components/Molecules/HeaderEsuWithIcon/__snapshots__/HeaderEsuWithIcon.test.js.snap +0 -1211
- package/dist/components/Molecules/HeaderEsuWithIcon/assets/HeaderIcons.js +0 -25
- package/dist/components/Molecules/HeaderEsuWithIcon/assets/icon--close.svg +0 -5
- package/dist/components/Molecules/HeaderEsuWithIcon/assets/icon--email.svg +0 -5
- package/dist/components/Organisms/EmailSignUp/EmailSignUp.js +0 -182
- package/src/components/Molecules/HeaderEsuWithIcon/HeaderEsuWithIcon.js +0 -135
- package/src/components/Molecules/HeaderEsuWithIcon/HeaderEsuWithIcon.md +0 -47
- package/src/components/Molecules/HeaderEsuWithIcon/HeaderEsuWithIcon.style.js +0 -60
- package/src/components/Molecules/HeaderEsuWithIcon/HeaderEsuWithIcon.test.js +0 -103
- package/src/components/Molecules/HeaderEsuWithIcon/__snapshots__/HeaderEsuWithIcon.test.js.snap +0 -1211
- package/src/components/Molecules/HeaderEsuWithIcon/assets/HeaderIcons.js +0 -15
- package/src/components/Molecules/HeaderEsuWithIcon/assets/icon--close.svg +0 -5
- package/src/components/Molecules/HeaderEsuWithIcon/assets/icon--email.svg +0 -5
- package/src/components/Organisms/EmailSignUp/EmailSignUp.js +0 -197
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _iconEmail = _interopRequireDefault(require("./icon--email.svg"));
|
|
11
|
-
|
|
12
|
-
var _iconClose = _interopRequireDefault(require("./icon--close.svg"));
|
|
13
|
-
|
|
14
|
-
var HeaderIcons = {
|
|
15
|
-
email: {
|
|
16
|
-
icon: _iconEmail.default,
|
|
17
|
-
title: 'Sign up for emails'
|
|
18
|
-
},
|
|
19
|
-
close: {
|
|
20
|
-
icon: _iconClose.default,
|
|
21
|
-
title: 'Close email sign-up'
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
var _default = HeaderIcons;
|
|
25
|
-
exports.default = _default;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
<svg id="icon--close" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="3 3 32 32" xml:space="preserve">
|
|
2
|
-
<title>Email Sign-Up</title>
|
|
3
|
-
<desc>Close email Sign-Up form</desc>
|
|
4
|
-
<path fill="white" d="M21.4,20l8.3,8.3l-1.4,1.4L20,21.4l-8.3,8.3l-1.4-1.4l8.3-8.3l-8.3-8.3l1.4-1.4l8.3,8.3l8.3-8.3l1.4,1.4L21.4,20z"></path>
|
|
5
|
-
</svg>
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
<svg id="icon--email" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="10 10 20 20" xml:space="preserve">
|
|
2
|
-
<title>Email Sign-Up</title>
|
|
3
|
-
<desc>Opens Email Sign-Up form</desc>
|
|
4
|
-
<path id="path--email" d="M28,12H12h-2v2v12v2h2h16h2v-2V14v-2H28z M26.6,14L20,20.6L13.4,14H26.6z M12,26V15.4l8,8l8-8V26H12z"></path>
|
|
5
|
-
</svg>
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
11
|
-
|
|
12
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
|
|
13
|
-
|
|
14
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
|
-
var _Select = _interopRequireDefault(require("../../Atoms/Select/Select"));
|
|
17
|
-
|
|
18
|
-
var _Text = _interopRequireDefault(require("../../Atoms/Text/Text"));
|
|
19
|
-
|
|
20
|
-
var _EmailSignUp = require("./EmailSignUp.style");
|
|
21
|
-
|
|
22
|
-
var _Membership = require("../Membership/Membership.style");
|
|
23
|
-
|
|
24
|
-
var _excluded = ["title", "topCopy", "isSuccess", "isSchools", "schoolsCopy", "selectItems", "successCopy", "errorMsg", "privacyCopy", "subscribe", "validate", "buttonColor", "backgroundColor"];
|
|
25
|
-
|
|
26
|
-
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); }
|
|
27
|
-
|
|
28
|
-
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; }
|
|
29
|
-
|
|
30
|
-
var EmailSignUp = function EmailSignUp(_ref) {
|
|
31
|
-
var title = _ref.title,
|
|
32
|
-
topCopy = _ref.topCopy,
|
|
33
|
-
isSuccess = _ref.isSuccess,
|
|
34
|
-
isSchools = _ref.isSchools,
|
|
35
|
-
schoolsCopy = _ref.schoolsCopy,
|
|
36
|
-
selectItems = _ref.selectItems,
|
|
37
|
-
successCopy = _ref.successCopy,
|
|
38
|
-
errorMsg = _ref.errorMsg,
|
|
39
|
-
privacyCopy = _ref.privacyCopy,
|
|
40
|
-
subscribe = _ref.subscribe,
|
|
41
|
-
validate = _ref.validate,
|
|
42
|
-
buttonColor = _ref.buttonColor,
|
|
43
|
-
backgroundColor = _ref.backgroundColor,
|
|
44
|
-
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
45
|
-
|
|
46
|
-
var _useState = (0, _react.useState)(''),
|
|
47
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
48
|
-
value = _useState2[0],
|
|
49
|
-
setValue = _useState2[1];
|
|
50
|
-
|
|
51
|
-
var _useState3 = (0, _react.useState)(''),
|
|
52
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
53
|
-
age = _useState4[0],
|
|
54
|
-
setAge = _useState4[1];
|
|
55
|
-
|
|
56
|
-
var _useState5 = (0, _react.useState)(false),
|
|
57
|
-
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
58
|
-
next = _useState6[0],
|
|
59
|
-
setNext = _useState6[1];
|
|
60
|
-
|
|
61
|
-
var handleSubmit = function handleSubmit(e) {
|
|
62
|
-
// Just stopping weird things happening for now when the user submits with the enter key
|
|
63
|
-
// rather than the Submit button
|
|
64
|
-
e.preventDefault();
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
var schoolsSelect = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Select.default, {
|
|
68
|
-
hideLabel: true,
|
|
69
|
-
label: "Please choose an option",
|
|
70
|
-
placeholder: "Please choose an option",
|
|
71
|
-
description: "Please choose an option",
|
|
72
|
-
errorMsg: errorMsg,
|
|
73
|
-
options: selectItems,
|
|
74
|
-
value: age,
|
|
75
|
-
onChange: function onChange(event) {
|
|
76
|
-
return setAge(event.target.value);
|
|
77
|
-
}
|
|
78
|
-
}), /*#__PURE__*/_react.default.createElement(_Text.default, {
|
|
79
|
-
tag: "p",
|
|
80
|
-
weight: "400",
|
|
81
|
-
size: "m"
|
|
82
|
-
}, schoolsCopy));
|
|
83
|
-
|
|
84
|
-
var subscriptionSchoolsForm = /*#__PURE__*/_react.default.createElement(_EmailSignUp.Form, {
|
|
85
|
-
onSubmit: function onSubmit(e) {
|
|
86
|
-
return handleSubmit(e);
|
|
87
|
-
}
|
|
88
|
-
}, !next && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_EmailSignUp.InputField, {
|
|
89
|
-
"aria-label": "Email address",
|
|
90
|
-
name: "email",
|
|
91
|
-
id: "email",
|
|
92
|
-
hasAria: false,
|
|
93
|
-
showLabel: false,
|
|
94
|
-
type: "email",
|
|
95
|
-
errorMsg: errorMsg,
|
|
96
|
-
label: "email",
|
|
97
|
-
placeholder: "example@youremail.com",
|
|
98
|
-
value: value,
|
|
99
|
-
onChange: function onChange(event) {
|
|
100
|
-
return setValue(event.target.value);
|
|
101
|
-
}
|
|
102
|
-
}), /*#__PURE__*/_react.default.createElement(_EmailSignUp.ButtonWrapper, null, /*#__PURE__*/_react.default.createElement(_Membership.Button, {
|
|
103
|
-
as: "input",
|
|
104
|
-
type: "submit",
|
|
105
|
-
"data-test": "subscribe-button-school",
|
|
106
|
-
color: buttonColor,
|
|
107
|
-
onClick: function onClick() {
|
|
108
|
-
return validate({
|
|
109
|
-
email: value
|
|
110
|
-
}) && setNext(true);
|
|
111
|
-
},
|
|
112
|
-
value: " Subscribe"
|
|
113
|
-
}))), next && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, schoolsSelect, /*#__PURE__*/_react.default.createElement(_EmailSignUp.ButtonWrapper, null, /*#__PURE__*/_react.default.createElement(_Membership.Button, {
|
|
114
|
-
as: "input",
|
|
115
|
-
type: "submit",
|
|
116
|
-
"data-test": "subscribe-button-school",
|
|
117
|
-
color: buttonColor,
|
|
118
|
-
onClick: function onClick() {
|
|
119
|
-
return validate({
|
|
120
|
-
email: value,
|
|
121
|
-
age: age
|
|
122
|
-
}) && subscribe({
|
|
123
|
-
email: "".concat(value),
|
|
124
|
-
age: "".concat(age)
|
|
125
|
-
});
|
|
126
|
-
},
|
|
127
|
-
value: " Subscribe"
|
|
128
|
-
}))));
|
|
129
|
-
|
|
130
|
-
var subscriptionForm = /*#__PURE__*/_react.default.createElement(_EmailSignUp.Form, {
|
|
131
|
-
onSubmit: function onSubmit(e) {
|
|
132
|
-
return handleSubmit(e);
|
|
133
|
-
}
|
|
134
|
-
}, /*#__PURE__*/_react.default.createElement(_EmailSignUp.InputField, {
|
|
135
|
-
"aria-label": "Email address",
|
|
136
|
-
name: "email",
|
|
137
|
-
id: "email",
|
|
138
|
-
hasAria: false,
|
|
139
|
-
showLabel: false,
|
|
140
|
-
type: "email",
|
|
141
|
-
errorMsg: errorMsg,
|
|
142
|
-
label: "email",
|
|
143
|
-
placeholder: "example@youremail.com",
|
|
144
|
-
value: value,
|
|
145
|
-
onChange: function onChange(event) {
|
|
146
|
-
return setValue(event.target.value);
|
|
147
|
-
}
|
|
148
|
-
}), /*#__PURE__*/_react.default.createElement(_EmailSignUp.ButtonWrapper, null, /*#__PURE__*/_react.default.createElement(_Membership.Button, {
|
|
149
|
-
as: "input",
|
|
150
|
-
"data-test": "subscribe-button",
|
|
151
|
-
type: "submit",
|
|
152
|
-
color: buttonColor,
|
|
153
|
-
onClick: function onClick() {
|
|
154
|
-
return validate({
|
|
155
|
-
email: value
|
|
156
|
-
}) && subscribe(value);
|
|
157
|
-
},
|
|
158
|
-
value: " Subscribe"
|
|
159
|
-
})));
|
|
160
|
-
|
|
161
|
-
var privacyContainer = /*#__PURE__*/_react.default.createElement(_EmailSignUp.PrivacyCopyWrapper, null, privacyCopy);
|
|
162
|
-
|
|
163
|
-
return /*#__PURE__*/_react.default.createElement(_EmailSignUp.ESUWrapper, Object.assign({
|
|
164
|
-
backgroundColor: backgroundColor
|
|
165
|
-
}, rest), /*#__PURE__*/_react.default.createElement(_EmailSignUp.Title, {
|
|
166
|
-
tag: "h2",
|
|
167
|
-
size: "xxl",
|
|
168
|
-
weight: "400",
|
|
169
|
-
family: "Anton",
|
|
170
|
-
uppercase: true
|
|
171
|
-
}, title), (!next || isSuccess) && /*#__PURE__*/_react.default.createElement(_EmailSignUp.TopCopyWrapper, null, isSuccess ? successCopy : topCopy), !isSuccess && (isSchools ? subscriptionSchoolsForm : subscriptionForm), privacyContainer);
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
EmailSignUp.defaultProps = {
|
|
175
|
-
backgroundColor: 'deep_violet_dark',
|
|
176
|
-
buttonColor: 'red',
|
|
177
|
-
isSchools: false,
|
|
178
|
-
schoolsCopy: '',
|
|
179
|
-
selectItems: []
|
|
180
|
-
};
|
|
181
|
-
var _default = EmailSignUp;
|
|
182
|
-
exports.default = _default;
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import Icon from '../../Atoms/SocialIcons/Icon/Icon';
|
|
4
|
-
import HeaderIcons from './assets/HeaderIcons';
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
IconWrapper,
|
|
8
|
-
EsuWrapper,
|
|
9
|
-
CloseButton,
|
|
10
|
-
HeaderESU
|
|
11
|
-
} from './HeaderEsuWithIcon.style';
|
|
12
|
-
|
|
13
|
-
/* HeaderEsuWithIcon component */
|
|
14
|
-
const HeaderEsuWithIcon = ({
|
|
15
|
-
title,
|
|
16
|
-
topCopy,
|
|
17
|
-
successCopy,
|
|
18
|
-
privacyCopy,
|
|
19
|
-
buttonColor,
|
|
20
|
-
subscribe,
|
|
21
|
-
validate,
|
|
22
|
-
isSuccess,
|
|
23
|
-
errorMsg,
|
|
24
|
-
isESUOpen: isESUOpenInitial
|
|
25
|
-
}) => {
|
|
26
|
-
// Pre-interaction flag
|
|
27
|
-
const [isClicked, setisClicked] = useState(false);
|
|
28
|
-
const [isESUOpen, setIsESUOpen] = useState(isESUOpenInitial);
|
|
29
|
-
const thisRef = useRef(null);
|
|
30
|
-
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (isClicked) {
|
|
33
|
-
if (isESUOpen && !isSuccess) {
|
|
34
|
-
thisRef.current.querySelector('input').focus();
|
|
35
|
-
} else {
|
|
36
|
-
thisRef.current.querySelector('a').focus();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}, [isClicked, isESUOpen, isSuccess]);
|
|
40
|
-
|
|
41
|
-
/* Allow our ESU modal stuff to happen */
|
|
42
|
-
const handleESUOpen = e => {
|
|
43
|
-
e.preventDefault();
|
|
44
|
-
|
|
45
|
-
// Update flag
|
|
46
|
-
setisClicked(true);
|
|
47
|
-
|
|
48
|
-
// Toggle our 'opened' state
|
|
49
|
-
setIsESUOpen(!isESUOpen);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const handleEscClose = e => {
|
|
53
|
-
// Close the modal if this is the ESC key
|
|
54
|
-
if (e.keyCode === 27) {
|
|
55
|
-
setIsESUOpen(false);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/* Break out ESU render into own function */
|
|
60
|
-
const renderESU = () => (
|
|
61
|
-
<HeaderESU
|
|
62
|
-
title={title}
|
|
63
|
-
topCopy={topCopy}
|
|
64
|
-
successCopy={successCopy}
|
|
65
|
-
privacyCopy={privacyCopy}
|
|
66
|
-
isSuccess={isSuccess}
|
|
67
|
-
subscribe={subscribe}
|
|
68
|
-
validate={validate}
|
|
69
|
-
errorMsg={errorMsg}
|
|
70
|
-
buttonColor={buttonColor}
|
|
71
|
-
aria-modal="true"
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
/* Break out Close button render into own function */
|
|
76
|
-
const renderCloseButton = () => (
|
|
77
|
-
<CloseButton
|
|
78
|
-
onClick={e => handleESUOpen(e)}
|
|
79
|
-
icon={HeaderIcons.close.icon}
|
|
80
|
-
title={HeaderIcons.close.title}
|
|
81
|
-
brand={HeaderIcons.close.title}
|
|
82
|
-
target="self"
|
|
83
|
-
role="button"
|
|
84
|
-
href="#"
|
|
85
|
-
tabIndex="0"
|
|
86
|
-
/>
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
/* Main render */
|
|
90
|
-
return (
|
|
91
|
-
<IconWrapper
|
|
92
|
-
onKeyDown={e => handleEscClose(e)}
|
|
93
|
-
ref={thisRef}
|
|
94
|
-
data-test="header-esu"
|
|
95
|
-
>
|
|
96
|
-
<Icon
|
|
97
|
-
onClick={e => handleESUOpen(e)}
|
|
98
|
-
icon={HeaderIcons.email.icon}
|
|
99
|
-
title={HeaderIcons.email.title}
|
|
100
|
-
brand={HeaderIcons.email.title}
|
|
101
|
-
target="self"
|
|
102
|
-
role="button"
|
|
103
|
-
href="#"
|
|
104
|
-
tabIndex="0"
|
|
105
|
-
/>
|
|
106
|
-
|
|
107
|
-
{isESUOpen ? (
|
|
108
|
-
<EsuWrapper>
|
|
109
|
-
{renderESU()}
|
|
110
|
-
{renderCloseButton()}
|
|
111
|
-
</EsuWrapper>
|
|
112
|
-
) : null}
|
|
113
|
-
</IconWrapper>
|
|
114
|
-
);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
HeaderEsuWithIcon.propTypes = {
|
|
118
|
-
isESUOpen: PropTypes.bool,
|
|
119
|
-
title: PropTypes.node.isRequired,
|
|
120
|
-
topCopy: PropTypes.node.isRequired,
|
|
121
|
-
privacyCopy: PropTypes.node.isRequired,
|
|
122
|
-
successCopy: PropTypes.node.isRequired,
|
|
123
|
-
buttonColor: PropTypes.string,
|
|
124
|
-
subscribe: PropTypes.func.isRequired,
|
|
125
|
-
validate: PropTypes.func.isRequired,
|
|
126
|
-
isSuccess: PropTypes.bool.isRequired,
|
|
127
|
-
errorMsg: PropTypes.string.isRequired
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
HeaderEsuWithIcon.defaultProps = {
|
|
131
|
-
isESUOpen: false,
|
|
132
|
-
buttonColor: 'red'
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export default HeaderEsuWithIcon;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# Header Email Sign Up
|
|
2
|
-
|
|
3
|
-
```js
|
|
4
|
-
import RichText from '../../Atoms/RichText/RichText';
|
|
5
|
-
|
|
6
|
-
const title = 'Stay in the know';
|
|
7
|
-
const topCopy = (
|
|
8
|
-
<RichText
|
|
9
|
-
markup={`<p>Get regular email updates and info on what we're up to!</p>`}
|
|
10
|
-
/>
|
|
11
|
-
);
|
|
12
|
-
const privacyCopy = (
|
|
13
|
-
<RichText
|
|
14
|
-
markup={`<p>Our Privacy Policy describes how we handle and protect your information.<br><br>If you are under 18, please make sure you have your parents’ permission before providing us with any personal details.</p>`}
|
|
15
|
-
/>
|
|
16
|
-
);
|
|
17
|
-
const successCopy = (
|
|
18
|
-
<RichText
|
|
19
|
-
markup={`<p>Thanks! Your first email will be with you shortly</p>`}
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const [success, setSuccess] = React.useState(false);
|
|
24
|
-
const [error, setError] = React.useState('');
|
|
25
|
-
|
|
26
|
-
const validate = ({ email }) => {
|
|
27
|
-
let isValid = false;
|
|
28
|
-
if (email.includes('@')) {
|
|
29
|
-
isValid = true;
|
|
30
|
-
setError('');
|
|
31
|
-
} else {
|
|
32
|
-
setError('invalid email!');
|
|
33
|
-
}
|
|
34
|
-
return isValid;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
<HeaderEsuWithIcon
|
|
38
|
-
title={title}
|
|
39
|
-
topCopy={topCopy}
|
|
40
|
-
successCopy={successCopy}
|
|
41
|
-
isSuccess={success}
|
|
42
|
-
privacyCopy={privacyCopy}
|
|
43
|
-
errorMsg={error}
|
|
44
|
-
subscribe={() => setSuccess(!success)}
|
|
45
|
-
validate={validate}
|
|
46
|
-
/>;
|
|
47
|
-
```
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
import Icon from '../../Atoms/SocialIcons/Icon/Icon';
|
|
3
|
-
import spacing from '../../../theme/shared/spacing';
|
|
4
|
-
import EmailSignUp from '../../Organisms/EmailSignUp/EmailSignUp';
|
|
5
|
-
|
|
6
|
-
const IconWrapper = styled.div`
|
|
7
|
-
width: 35px;
|
|
8
|
-
height: 35px;
|
|
9
|
-
display: inline-block;
|
|
10
|
-
`;
|
|
11
|
-
|
|
12
|
-
const EsuWrapper = styled.div`
|
|
13
|
-
position: fixed;
|
|
14
|
-
width: 100%;
|
|
15
|
-
height: 100%;
|
|
16
|
-
background-color: rgba(255, 255, 255, 0.5);
|
|
17
|
-
z-index: 100;
|
|
18
|
-
top: 0;
|
|
19
|
-
left: 0;
|
|
20
|
-
overflow-y: auto;
|
|
21
|
-
display: flex;
|
|
22
|
-
justify-content: center;
|
|
23
|
-
align-items: flex-start;
|
|
24
|
-
div[aria-modal='true'] {
|
|
25
|
-
padding: ${spacing('l')};
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
const CloseButton = styled(Icon)`
|
|
30
|
-
position: absolute;
|
|
31
|
-
top: 0;
|
|
32
|
-
right: 0;
|
|
33
|
-
width: 40px;
|
|
34
|
-
height: 40px;
|
|
35
|
-
margin-left: 0;
|
|
36
|
-
|
|
37
|
-
@media ${({ theme }) => theme.breakpoint('small')} {
|
|
38
|
-
margin: ${spacing('xl')} 0 0;
|
|
39
|
-
right: 25%;
|
|
40
|
-
}
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
const HeaderESU = styled(EmailSignUp)`
|
|
44
|
-
width: 100%;
|
|
45
|
-
input {
|
|
46
|
-
font-size: ${({ theme }) => theme.fontSize('s')};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@media ${({ theme }) => theme.breakpoint('small')} {
|
|
50
|
-
margin-top: ${spacing('xl')};
|
|
51
|
-
width: 50%;
|
|
52
|
-
input {
|
|
53
|
-
font-size: ${({ theme }) => theme.fontSize('m')};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
`;
|
|
57
|
-
|
|
58
|
-
export {
|
|
59
|
-
IconWrapper, EsuWrapper, CloseButton, HeaderESU
|
|
60
|
-
};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import 'jest-styled-components';
|
|
3
|
-
import renderWithTheme from '../../../hoc/shallowWithTheme';
|
|
4
|
-
import HeaderEsuWithIcon from './HeaderEsuWithIcon';
|
|
5
|
-
import RichText from '../../Atoms/RichText/RichText';
|
|
6
|
-
|
|
7
|
-
const title = 'Stay in the know!';
|
|
8
|
-
const topCopy = (
|
|
9
|
-
<RichText
|
|
10
|
-
markup={"<p>Get regular email updates and info on what we're up to!</p>"}
|
|
11
|
-
/>
|
|
12
|
-
);
|
|
13
|
-
const privacyCopy = (
|
|
14
|
-
<RichText
|
|
15
|
-
markup={
|
|
16
|
-
'<p>Our <a class="link link--white inline" href="/privacy-notice">Privacy Policy</a> describes how we handle and protect your information.<br><br>If you are under 18, please make sure you have your parents’ permission before providing us with any personal details.</p>'
|
|
17
|
-
}
|
|
18
|
-
/>
|
|
19
|
-
);
|
|
20
|
-
const successCopy = (
|
|
21
|
-
<RichText
|
|
22
|
-
markup="<p>Thanks! Your first email will be with you shortly</p>"
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
it('renders correctly with modal closed', () => {
|
|
27
|
-
const tree = renderWithTheme(
|
|
28
|
-
<div>
|
|
29
|
-
<HeaderEsuWithIcon
|
|
30
|
-
title={title}
|
|
31
|
-
topCopy={topCopy}
|
|
32
|
-
privacyCopy={privacyCopy}
|
|
33
|
-
successCopy={successCopy}
|
|
34
|
-
isSuccess={false}
|
|
35
|
-
errorMsg=""
|
|
36
|
-
subscribe={() => 'Done'}
|
|
37
|
-
validate={() => true}
|
|
38
|
-
/>
|
|
39
|
-
</div>
|
|
40
|
-
).toJSON();
|
|
41
|
-
|
|
42
|
-
expect(tree).toMatchSnapshot();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('renders correctly with modal open', () => {
|
|
46
|
-
const tree = renderWithTheme(
|
|
47
|
-
<div>
|
|
48
|
-
<HeaderEsuWithIcon
|
|
49
|
-
title={title}
|
|
50
|
-
topCopy={topCopy}
|
|
51
|
-
privacyCopy={privacyCopy}
|
|
52
|
-
successCopy={successCopy}
|
|
53
|
-
isESUOpen
|
|
54
|
-
isSuccess={false}
|
|
55
|
-
errorMsg=""
|
|
56
|
-
subscribe={() => 'Done'}
|
|
57
|
-
validate={() => true}
|
|
58
|
-
/>
|
|
59
|
-
</div>
|
|
60
|
-
).toJSON();
|
|
61
|
-
|
|
62
|
-
expect(tree).toMatchSnapshot();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('renders correctly with error message', () => {
|
|
66
|
-
const tree = renderWithTheme(
|
|
67
|
-
<div>
|
|
68
|
-
<HeaderEsuWithIcon
|
|
69
|
-
title={title}
|
|
70
|
-
topCopy={topCopy}
|
|
71
|
-
privacyCopy={privacyCopy}
|
|
72
|
-
successCopy={successCopy}
|
|
73
|
-
isESUOpen
|
|
74
|
-
isSuccess={false}
|
|
75
|
-
errorMsg="invalid email"
|
|
76
|
-
subscribe={() => 'Done'}
|
|
77
|
-
validate={() => true}
|
|
78
|
-
/>
|
|
79
|
-
</div>
|
|
80
|
-
).toJSON();
|
|
81
|
-
|
|
82
|
-
expect(tree).toMatchSnapshot();
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('renders correctly with success message', () => {
|
|
86
|
-
const tree = renderWithTheme(
|
|
87
|
-
<div>
|
|
88
|
-
<HeaderEsuWithIcon
|
|
89
|
-
title={title}
|
|
90
|
-
topCopy={topCopy}
|
|
91
|
-
privacyCopy={privacyCopy}
|
|
92
|
-
successCopy={successCopy}
|
|
93
|
-
isESUOpen
|
|
94
|
-
isSuccess
|
|
95
|
-
errorMsg=""
|
|
96
|
-
subscribe={() => 'Done'}
|
|
97
|
-
validate={() => true}
|
|
98
|
-
/>
|
|
99
|
-
</div>
|
|
100
|
-
).toJSON();
|
|
101
|
-
|
|
102
|
-
expect(tree).toMatchSnapshot();
|
|
103
|
-
});
|