@comicrelief/component-library 6.10.0 → 7.0.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/cypress/integration/components/Organisms/EmailSignUp.spec.js +47 -132
- 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/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,142 +1,57 @@
|
|
|
1
1
|
describe('Email Sign Up component', () => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
before(() => {
|
|
3
|
+
// go to Email Sign Up component
|
|
4
|
+
cy.visit('/#emailsignupform');
|
|
5
|
+
cy.wait(2500);
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
describe('Email Sign Up section', () => {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
cy.get('[data-testid="EmailSignUpForm-example-1"]')
|
|
11
|
+
.as('container')
|
|
12
|
+
.find('[data-preview="EmailSignUpForm"]')
|
|
13
|
+
.as('preview');
|
|
14
|
+
|
|
15
|
+
cy.get('@container')
|
|
16
|
+
.find('button')
|
|
17
|
+
.contains('View Code')
|
|
18
|
+
.as('viewCodeBtn');
|
|
6
19
|
});
|
|
7
20
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
it('shows the table on button click', () => {
|
|
30
|
-
cy.get('@propsBtn').click();
|
|
31
|
-
cy.get('@container')
|
|
32
|
-
.find('table')
|
|
33
|
-
.should('contain', 'Prop name');
|
|
34
|
-
});
|
|
21
|
+
it('renders Email Sign Up preview', () => {
|
|
22
|
+
cy.get('@container')
|
|
23
|
+
.find('h2')
|
|
24
|
+
.should('exist')
|
|
25
|
+
.contains('Stay in the know!');
|
|
26
|
+
cy.get('@container')
|
|
27
|
+
.find('p')
|
|
28
|
+
.contains("Get regular email updates and info on what we're up to!");
|
|
29
|
+
cy.get('[data-test="subscribe-button"]').should('be.disabled');
|
|
30
|
+
cy.get('@container').find('input[id="first-name"]').type('Test');
|
|
31
|
+
cy.get('@container').find('input[id="last-name"]').type('User');
|
|
32
|
+
cy.get('@container')
|
|
33
|
+
.find('input[id="email"]')
|
|
34
|
+
.type('test@comicrelief.com')
|
|
35
|
+
.blur();
|
|
36
|
+
cy.get('[data-test="subscribe-button"]').should('not.be.disabled');
|
|
37
|
+
cy.get('[data-test="subscribe-button"]').click();
|
|
38
|
+
|
|
39
|
+
cy.get('@container').contains(
|
|
40
|
+
'Thanks! Your first email will be with you shortly'
|
|
41
|
+
);
|
|
35
42
|
});
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
cy.get('[data-testid="EmailSignUp-example-1"]')
|
|
40
|
-
.as('container')
|
|
41
|
-
.find('[data-preview="EmailSignUp"]')
|
|
42
|
-
.as('preview');
|
|
43
|
-
|
|
44
|
-
cy.get('@container')
|
|
45
|
-
.find('button')
|
|
46
|
-
.contains('View Code')
|
|
47
|
-
.as('viewCodeBtn');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('renders Email Sign Up preview', () => {
|
|
51
|
-
cy.get('@container')
|
|
52
|
-
.find('h2')
|
|
53
|
-
.should('exist')
|
|
54
|
-
.contains('Stay in the know!');
|
|
55
|
-
cy.get('@container')
|
|
56
|
-
.find('p')
|
|
57
|
-
.contains('Get regular email updates and info on what we\'re up to!');
|
|
58
|
-
cy.get('[data-test="subscribe-button"]')
|
|
59
|
-
.click();
|
|
60
|
-
cy.get('[data-test="error-message"]')
|
|
61
|
-
.should('contain', 'invalid email!');
|
|
62
|
-
cy.get('@container')
|
|
63
|
-
.find('input[id="email"]')
|
|
64
|
-
.type('test@comicrelief.com');
|
|
65
|
-
cy.get('[data-test="subscribe-button"]')
|
|
66
|
-
.click();
|
|
67
|
-
cy.get('@container')
|
|
68
|
-
.contains('Thanks! Your first email will be with you shortly')
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('has view code button', () => {
|
|
72
|
-
cy.get('@viewCodeBtn').should('exist');
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('shows code on click', () => {
|
|
76
|
-
cy.get('@viewCodeBtn').click();
|
|
77
|
-
cy.get('@container')
|
|
78
|
-
.find('textarea')
|
|
79
|
-
.should('exist');
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('closes code on click', () => {
|
|
83
|
-
cy.get('@viewCodeBtn').click();
|
|
84
|
-
});
|
|
44
|
+
it('has view code button', () => {
|
|
45
|
+
cy.get('@viewCodeBtn').should('exist');
|
|
85
46
|
});
|
|
86
47
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
.find('[data-preview="EmailSignUp"]')
|
|
92
|
-
.as('preview');
|
|
93
|
-
|
|
94
|
-
cy.get('@container')
|
|
95
|
-
.find('button')
|
|
96
|
-
.contains('View Code')
|
|
97
|
-
.as('viewCodeBtn');
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('renders Email Sign Up Schools preview', () => {
|
|
101
|
-
cy.get('@container')
|
|
102
|
-
.find('h2')
|
|
103
|
-
.should('exist')
|
|
104
|
-
.contains('Stay in the know!');
|
|
105
|
-
cy.get('@container')
|
|
106
|
-
.find('p')
|
|
107
|
-
.contains('Get regular email updates and info on what we\'re up to!');
|
|
108
|
-
cy.get('[data-test="subscribe-button-school"]')
|
|
109
|
-
.click();
|
|
110
|
-
cy.get('[data-test="error-message"]')
|
|
111
|
-
.should('contain', 'invalid email!');
|
|
112
|
-
cy.get('@container')
|
|
113
|
-
.find('input[id="email"]')
|
|
114
|
-
.type('test@comicrelief.com');
|
|
115
|
-
cy.get('[data-test="subscribe-button-school"]')
|
|
116
|
-
.click();
|
|
117
|
-
cy.get('@container')
|
|
118
|
-
.find('select')
|
|
119
|
-
.select('The first option')
|
|
120
|
-
.first();
|
|
121
|
-
cy.get('[data-test="subscribe-button-school"]')
|
|
122
|
-
.click();
|
|
123
|
-
cy.get('@container')
|
|
124
|
-
.contains('Thanks! Your first email will be with you shortly')
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it('has view code button', () => {
|
|
128
|
-
cy.get('@viewCodeBtn').should('exist');
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('shows code on click', () => {
|
|
132
|
-
cy.get('@viewCodeBtn').click();
|
|
133
|
-
cy.get('@container')
|
|
134
|
-
.find('textarea')
|
|
135
|
-
.should('exist');
|
|
136
|
-
});
|
|
48
|
+
it('shows code on click', () => {
|
|
49
|
+
cy.get('@viewCodeBtn').click();
|
|
50
|
+
cy.get('@container').find('textarea').should('exist');
|
|
51
|
+
});
|
|
137
52
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
});
|
|
53
|
+
it('closes code on click', () => {
|
|
54
|
+
cy.get('@viewCodeBtn').click();
|
|
141
55
|
});
|
|
56
|
+
});
|
|
142
57
|
});
|
|
@@ -1,129 +1,14 @@
|
|
|
1
|
-
# Email
|
|
1
|
+
# Email SignUp Form
|
|
2
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 <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>`}
|
|
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 sendEmail = email => {
|
|
27
|
-
setTimeout(() => setSuccess(!success), 2000);
|
|
28
|
-
console.log(email);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const validate = ({ email }) => {
|
|
32
|
-
let isValid = false;
|
|
33
|
-
if (email.includes('@')) {
|
|
34
|
-
isValid = true;
|
|
35
|
-
setError('');
|
|
36
|
-
} else {
|
|
37
|
-
setError('invalid email!');
|
|
38
|
-
}
|
|
39
|
-
return isValid;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
<EmailSignUp
|
|
43
|
-
title={title}
|
|
44
|
-
topCopy={topCopy}
|
|
45
|
-
successCopy={successCopy}
|
|
46
|
-
isSuccess={success}
|
|
47
|
-
privacyCopy={privacyCopy}
|
|
48
|
-
errorMsg={error}
|
|
49
|
-
subscribe={sendEmail}
|
|
50
|
-
validate={validate}
|
|
51
|
-
/>;
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
# Email Sign Up Schools
|
|
55
3
|
|
|
56
4
|
```js
|
|
57
|
-
import
|
|
58
|
-
|
|
59
|
-
const title = 'Stay in the know!';
|
|
60
|
-
const topCopy = (
|
|
61
|
-
<RichText
|
|
62
|
-
markup={`<p>Get regular email updates and info on what we're up to!</p>`}
|
|
63
|
-
/>
|
|
64
|
-
);
|
|
65
|
-
const privacyCopy = (
|
|
66
|
-
<RichText
|
|
67
|
-
markup={`<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>`}
|
|
68
|
-
/>
|
|
69
|
-
);
|
|
70
|
-
const successCopy = (
|
|
71
|
-
<RichText
|
|
72
|
-
markup={`<p>Thanks! Your first email will be with you shortly</p>`}
|
|
73
|
-
/>
|
|
74
|
-
);
|
|
75
|
-
const selectItems = [
|
|
76
|
-
{ value: '', displayValue: '-- Select age group --' },
|
|
77
|
-
{ value: 'Option one', displayValue: 'The first option' },
|
|
78
|
-
{
|
|
79
|
-
value: 'Option two',
|
|
80
|
-
displayValue: 'The second option'
|
|
81
|
-
},
|
|
82
|
-
{ value: 'Option three', displayValue: 'The third option' },
|
|
83
|
-
{ value: 'Option four', displayValue: 'The fourth option' }
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
const [successSchools, setSuccessSchools] = React.useState(false);
|
|
87
|
-
const [error, setError] = React.useState('');
|
|
88
|
-
|
|
89
|
-
sendEmail = emailAndAge => {
|
|
90
|
-
setTimeout(
|
|
91
|
-
() => setSuccessSchools(!successSchools),
|
|
92
|
-
2000
|
|
93
|
-
);
|
|
94
|
-
console.log(emailAndAge);
|
|
95
|
-
};
|
|
5
|
+
import EmailSignUpForm from './EmailSignUpForm';
|
|
6
|
+
import Text from '../../Atoms/Text/Text';
|
|
96
7
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
} else {
|
|
103
|
-
setError('invalid email!');
|
|
104
|
-
}
|
|
105
|
-
if (isValid === true && typeof age !== 'undefined') {
|
|
106
|
-
if (age) {
|
|
107
|
-
setError('');
|
|
108
|
-
} else {
|
|
109
|
-
isValid = false;
|
|
110
|
-
setError('invalid age!');
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return isValid;
|
|
114
|
-
};
|
|
8
|
+
<>
|
|
9
|
+
<Text tag="p">This EmailSignUpForm component exists purely to show the EmailSignUp component functioning within the Component Library; applications are to provide their own react-hook-form form and validation, based on these.</Text>
|
|
10
|
+
|
|
11
|
+
<EmailSignUpForm />
|
|
12
|
+
</>
|
|
115
13
|
|
|
116
|
-
<EmailSignUp
|
|
117
|
-
title={title}
|
|
118
|
-
topCopy={topCopy}
|
|
119
|
-
successCopy={successCopy}
|
|
120
|
-
schoolsCopy="Now please select your teaching group so you get the right updates."
|
|
121
|
-
isSuccess={successSchools}
|
|
122
|
-
selectItems={selectItems}
|
|
123
|
-
isSchools
|
|
124
|
-
privacyCopy={privacyCopy}
|
|
125
|
-
errorMsg={error}
|
|
126
|
-
subscribe={sendEmail}
|
|
127
|
-
validate={validate}
|
|
128
|
-
/>;
|
|
129
14
|
```
|
|
@@ -5,20 +5,20 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.Title = exports.InputField = exports.
|
|
8
|
+
exports.Title = exports.NameWrapper = exports.InputField = exports.FormInner = exports.ButtonWrapper = exports.PrivacyCopyWrapper = exports.TopCopyWrapper = exports.ESUWrapper = void 0;
|
|
9
9
|
|
|
10
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
11
|
|
|
12
12
|
var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _TextInput = _interopRequireDefault(require("./_TextInput"));
|
|
15
15
|
|
|
16
16
|
var _Text = _interopRequireDefault(require("../../Atoms/Text/Text"));
|
|
17
17
|
|
|
18
18
|
var ESUWrapper = _styledComponents.default.div.withConfig({
|
|
19
19
|
displayName: "EmailSignUpstyle__ESUWrapper",
|
|
20
20
|
componentId: "sc-w2b8yk-0"
|
|
21
|
-
})(["display:flex;flex-direction:column;font-size:", ";color:", ";background-color:", ";"], function (_ref) {
|
|
21
|
+
})(["display:flex;flex-direction:column;font-size:", ";color:", ";background-color:", ";padding:", ";"], function (_ref) {
|
|
22
22
|
var theme = _ref.theme;
|
|
23
23
|
return theme.fontSize('s');
|
|
24
24
|
}, function (_ref2) {
|
|
@@ -26,9 +26,9 @@ var ESUWrapper = _styledComponents.default.div.withConfig({
|
|
|
26
26
|
return theme.color('white');
|
|
27
27
|
}, function (_ref3) {
|
|
28
28
|
var theme = _ref3.theme,
|
|
29
|
-
|
|
30
|
-
return theme.color(
|
|
31
|
-
});
|
|
29
|
+
backgroundColour = _ref3.backgroundColour;
|
|
30
|
+
return theme.color(backgroundColour);
|
|
31
|
+
}, (0, _spacing.default)('m'));
|
|
32
32
|
|
|
33
33
|
exports.ESUWrapper = ESUWrapper;
|
|
34
34
|
|
|
@@ -42,15 +42,10 @@ exports.TopCopyWrapper = TopCopyWrapper;
|
|
|
42
42
|
var ButtonWrapper = _styledComponents.default.div.withConfig({
|
|
43
43
|
displayName: "EmailSignUpstyle__ButtonWrapper",
|
|
44
44
|
componentId: "sc-w2b8yk-2"
|
|
45
|
-
})(["margin-top:", ";
|
|
46
|
-
var theme = _ref4.theme
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var theme = _ref5.theme;
|
|
50
|
-
return theme.breakpoint('small');
|
|
51
|
-
}, function (_ref6) {
|
|
52
|
-
var theme = _ref6.theme;
|
|
53
|
-
return theme.fontSize('m');
|
|
45
|
+
})(["margin-top:", ";button{background-color:", ";}"], (0, _spacing.default)('md'), function (_ref4) {
|
|
46
|
+
var theme = _ref4.theme,
|
|
47
|
+
buttonColour = _ref4.buttonColour;
|
|
48
|
+
return theme.color(buttonColour);
|
|
54
49
|
});
|
|
55
50
|
|
|
56
51
|
exports.ButtonWrapper = ButtonWrapper;
|
|
@@ -58,35 +53,57 @@ exports.ButtonWrapper = ButtonWrapper;
|
|
|
58
53
|
var PrivacyCopyWrapper = _styledComponents.default.div.withConfig({
|
|
59
54
|
displayName: "EmailSignUpstyle__PrivacyCopyWrapper",
|
|
60
55
|
componentId: "sc-w2b8yk-3"
|
|
61
|
-
})(["display:flex;flex-direction:column;margin-top:", ";p{font-size:", ";line-height:", ";a{font-size:", ";color:", ";}}"], (0, _spacing.default)('md'), function (
|
|
56
|
+
})(["display:flex;flex-direction:column;margin-top:", ";p{font-size:", ";line-height:", ";a{font-size:", ";color:", ";}}"], (0, _spacing.default)('md'), function (_ref5) {
|
|
57
|
+
var theme = _ref5.theme;
|
|
58
|
+
return theme.fontSize('s');
|
|
59
|
+
}, function (_ref6) {
|
|
60
|
+
var theme = _ref6.theme;
|
|
61
|
+
return theme.fontSize('xl');
|
|
62
|
+
}, function (_ref7) {
|
|
62
63
|
var theme = _ref7.theme;
|
|
63
64
|
return theme.fontSize('s');
|
|
64
65
|
}, function (_ref8) {
|
|
65
66
|
var theme = _ref8.theme;
|
|
66
|
-
return theme.fontSize('xl');
|
|
67
|
-
}, function (_ref9) {
|
|
68
|
-
var theme = _ref9.theme;
|
|
69
|
-
return theme.fontSize('s');
|
|
70
|
-
}, function (_ref10) {
|
|
71
|
-
var theme = _ref10.theme;
|
|
72
67
|
return theme.color('white');
|
|
73
68
|
});
|
|
74
69
|
|
|
75
70
|
exports.PrivacyCopyWrapper = PrivacyCopyWrapper;
|
|
76
71
|
|
|
77
|
-
var
|
|
78
|
-
displayName: "
|
|
72
|
+
var FormInner = _styledComponents.default.div.withConfig({
|
|
73
|
+
displayName: "EmailSignUpstyle__FormInner",
|
|
79
74
|
componentId: "sc-w2b8yk-4"
|
|
80
75
|
})(["display:flex;flex-direction:column;margin:", " 0;"], (0, _spacing.default)('md'));
|
|
81
76
|
|
|
82
|
-
exports.
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
exports.FormInner = FormInner;
|
|
78
|
+
|
|
79
|
+
var NameWrapper = _styledComponents.default.div.withConfig({
|
|
80
|
+
displayName: "EmailSignUpstyle__NameWrapper",
|
|
85
81
|
componentId: "sc-w2b8yk-5"
|
|
86
|
-
})(["
|
|
82
|
+
})(["display:flex;flex-direction:column;gap:0;@media ", "{justify-content:start;flex-direction:", ";gap:", ";)};}"], function (_ref9) {
|
|
83
|
+
var theme = _ref9.theme;
|
|
84
|
+
return theme.breakpoint('medium');
|
|
85
|
+
}, function (_ref10) {
|
|
86
|
+
var columnLayout = _ref10.columnLayout;
|
|
87
|
+
return columnLayout ? 'column' : 'row';
|
|
88
|
+
}, function (_ref11) {
|
|
89
|
+
var columnLayout = _ref11.columnLayout;
|
|
90
|
+
return columnLayout ? 0 : (0, _spacing.default)('md');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
exports.NameWrapper = NameWrapper;
|
|
94
|
+
var InputField = (0, _styledComponents.default)(_TextInput.default).withConfig({
|
|
95
|
+
displayName: "EmailSignUpstyle__InputField",
|
|
96
|
+
componentId: "sc-w2b8yk-6"
|
|
97
|
+
})(["width:100%;margin-bottom:", ";& > span:first-child{color:", ";}@media ", "{max-width:290px;}"], (0, _spacing.default)('md'), function (_ref12) {
|
|
98
|
+
var theme = _ref12.theme;
|
|
99
|
+
return theme.color('white');
|
|
100
|
+
}, function (_ref13) {
|
|
101
|
+
var theme = _ref13.theme;
|
|
102
|
+
return theme.breakpoint('medium');
|
|
103
|
+
});
|
|
87
104
|
exports.InputField = InputField;
|
|
88
105
|
var Title = (0, _styledComponents.default)(_Text.default).withConfig({
|
|
89
106
|
displayName: "EmailSignUpstyle__Title",
|
|
90
|
-
componentId: "sc-w2b8yk-
|
|
107
|
+
componentId: "sc-w2b8yk-7"
|
|
91
108
|
})(["margin-bottom:", ";"], (0, _spacing.default)('m'));
|
|
92
109
|
exports.Title = Title;
|
|
@@ -6,64 +6,31 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
6
6
|
|
|
7
7
|
require("jest-styled-components");
|
|
8
8
|
|
|
9
|
-
var _reactTestRenderer = _interopRequireDefault(require("react-test-renderer"));
|
|
10
|
-
|
|
11
9
|
var _shallowWithTheme = _interopRequireDefault(require("../../../hoc/shallowWithTheme"));
|
|
12
10
|
|
|
13
|
-
var _EmailSignUp =
|
|
11
|
+
var _EmailSignUp = require("./_EmailSignUp");
|
|
14
12
|
|
|
15
13
|
var _RichText = _interopRequireDefault(require("../../Atoms/RichText/RichText"));
|
|
16
14
|
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
var _reactHookForm = require("react-hook-form");
|
|
16
|
+
|
|
17
|
+
var _yup = require("@hookform/resolvers/yup");
|
|
18
|
+
|
|
19
|
+
var DummyForm = function DummyForm() {
|
|
20
|
+
var formMethods = (0, _reactHookForm.useForm)({
|
|
21
|
+
mode: "onBlur",
|
|
22
|
+
resolver: (0, _yup.yupResolver)(_EmailSignUp.validationSchema)
|
|
23
|
+
});
|
|
24
|
+
var handleSubmit = formMethods.handleSubmit;
|
|
25
|
+
var top = "<h1> Top Copy</h1> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>";
|
|
26
|
+
var success = "<h1> Success Copy</h1> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>";
|
|
21
27
|
var privacy = 'check <a href="https://www.comicrelief.com/privacy-notice">Privacy policy</a>';
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
topCopy: /*#__PURE__*/_react.default.createElement(_RichText.default, {
|
|
25
|
-
markup: top
|
|
26
|
-
}),
|
|
27
|
-
successCopy: /*#__PURE__*/_react.default.createElement(_RichText.default, {
|
|
28
|
-
markup: success
|
|
29
|
-
}),
|
|
30
|
-
isSuccess: false,
|
|
31
|
-
errorMsg: "",
|
|
32
|
-
buttonColor: "teal",
|
|
33
|
-
privacyCopy: /*#__PURE__*/_react.default.createElement(_RichText.default, {
|
|
34
|
-
markup: privacy
|
|
35
|
-
}),
|
|
36
|
-
subscribe: function subscribe() {
|
|
37
|
-
return 'Done';
|
|
38
|
-
},
|
|
39
|
-
validate: function validate() {
|
|
28
|
+
return /*#__PURE__*/_react.default.createElement(_reactHookForm.FormProvider, formMethods, /*#__PURE__*/_react.default.createElement("form", {
|
|
29
|
+
onSubmit: handleSubmit(function () {
|
|
40
30
|
return true;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
it('renders ESU School correctly', function () {
|
|
46
|
-
var top = '<h1> Top Copy</h1> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>';
|
|
47
|
-
var success = '<h1> Success Copy</h1> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>';
|
|
48
|
-
var privacy = 'check <a href="https://www.comicrelief.com/privacy-notice">Privacy policy</a>';
|
|
49
|
-
var selectItems = [{
|
|
50
|
-
value: '',
|
|
51
|
-
displayValue: '-- Select age group --'
|
|
52
|
-
}, {
|
|
53
|
-
value: 'Option one',
|
|
54
|
-
displayValue: 'The first option'
|
|
55
|
-
}, {
|
|
56
|
-
value: 'Option two',
|
|
57
|
-
displayValue: 'The second option'
|
|
58
|
-
}, {
|
|
59
|
-
value: 'Option three',
|
|
60
|
-
displayValue: 'The third option'
|
|
61
|
-
}, {
|
|
62
|
-
value: 'Option four',
|
|
63
|
-
displayValue: 'The fourth option'
|
|
64
|
-
}];
|
|
65
|
-
var mockNext = jest.fn();
|
|
66
|
-
var tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_EmailSignUp.default, {
|
|
31
|
+
}),
|
|
32
|
+
noValidate: true
|
|
33
|
+
}, /*#__PURE__*/_react.default.createElement(_EmailSignUp.EmailSignUp, {
|
|
67
34
|
title: "sign up letter",
|
|
68
35
|
topCopy: /*#__PURE__*/_react.default.createElement(_RichText.default, {
|
|
69
36
|
markup: top
|
|
@@ -71,26 +38,14 @@ it('renders ESU School correctly', function () {
|
|
|
71
38
|
successCopy: /*#__PURE__*/_react.default.createElement(_RichText.default, {
|
|
72
39
|
markup: success
|
|
73
40
|
}),
|
|
74
|
-
schoolsCopy: "Now please select your teaching group so you get the right updates.",
|
|
75
|
-
selectItems: selectItems,
|
|
76
|
-
isSuccess: false,
|
|
77
|
-
isSchools: true,
|
|
78
|
-
errorMsg: "",
|
|
79
|
-
buttonColor: "teal",
|
|
80
41
|
privacyCopy: /*#__PURE__*/_react.default.createElement(_RichText.default, {
|
|
81
42
|
markup: privacy
|
|
82
43
|
}),
|
|
83
|
-
|
|
84
|
-
validate: function validate() {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
44
|
+
formContext: formMethods
|
|
87
45
|
})));
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
var treeJson = tree.toJSON();
|
|
95
|
-
expect(treeJson).toMatchSnapshot();
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
it("renders correctly", function () {
|
|
49
|
+
var tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(DummyForm, null)).toJSON();
|
|
50
|
+
expect(tree).toMatchSnapshot();
|
|
96
51
|
});
|
|
@@ -0,0 +1,92 @@
|
|
|
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 _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
|
|
16
|
+
var _reactHookForm = require("react-hook-form");
|
|
17
|
+
|
|
18
|
+
var _yup = require("@hookform/resolvers/yup");
|
|
19
|
+
|
|
20
|
+
var _RichText = _interopRequireDefault(require("../../Atoms/RichText/RichText"));
|
|
21
|
+
|
|
22
|
+
var _EmailSignUp = require("./_EmailSignUp");
|
|
23
|
+
|
|
24
|
+
var EmailSignUpForm = function EmailSignUpForm() {
|
|
25
|
+
var validationSchema = (0, _EmailSignUp.buildEsuValidationSchema)({});
|
|
26
|
+
var formMethods = (0, _reactHookForm.useForm)({
|
|
27
|
+
mode: 'onBlur',
|
|
28
|
+
resolver: (0, _yup.yupResolver)(validationSchema)
|
|
29
|
+
});
|
|
30
|
+
var handleSubmit = formMethods.handleSubmit,
|
|
31
|
+
trigger = formMethods.trigger;
|
|
32
|
+
|
|
33
|
+
function handleSubscribe(_x) {
|
|
34
|
+
return _handleSubscribe.apply(this, arguments);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function _handleSubscribe() {
|
|
38
|
+
_handleSubscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(data) {
|
|
39
|
+
var valid;
|
|
40
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
41
|
+
while (1) {
|
|
42
|
+
switch (_context.prev = _context.next) {
|
|
43
|
+
case 0:
|
|
44
|
+
_context.next = 2;
|
|
45
|
+
return trigger([_EmailSignUp.ESU_FIELDS.EMAIL, _EmailSignUp.ESU_FIELDS.FIRST_NAME, _EmailSignUp.ESU_FIELDS.LAST_NAME]);
|
|
46
|
+
|
|
47
|
+
case 2:
|
|
48
|
+
valid = _context.sent;
|
|
49
|
+
|
|
50
|
+
if (valid) {
|
|
51
|
+
console.log(data);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
case 4:
|
|
55
|
+
case "end":
|
|
56
|
+
return _context.stop();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, _callee);
|
|
60
|
+
}));
|
|
61
|
+
return _handleSubscribe.apply(this, arguments);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var title = 'Stay in the know!';
|
|
65
|
+
|
|
66
|
+
var topCopy = /*#__PURE__*/_react.default.createElement(_RichText.default, {
|
|
67
|
+
markup: "<p>Get regular email updates and info on what we're up to!</p>"
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
var privacyCopy = /*#__PURE__*/_react.default.createElement(_RichText.default, {
|
|
71
|
+
markup: '<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>'
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
var successCopy = /*#__PURE__*/_react.default.createElement(_RichText.default, {
|
|
75
|
+
markup: "<p>Thanks! Your first email will be with you shortly</p>"
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return /*#__PURE__*/_react.default.createElement(_reactHookForm.FormProvider, formMethods, /*#__PURE__*/_react.default.createElement("form", {
|
|
79
|
+
onSubmit: handleSubmit(handleSubscribe),
|
|
80
|
+
noValidate: true
|
|
81
|
+
}, /*#__PURE__*/_react.default.createElement(_EmailSignUp.EmailSignUp, {
|
|
82
|
+
id: "default",
|
|
83
|
+
title: title,
|
|
84
|
+
topCopy: topCopy,
|
|
85
|
+
successCopy: successCopy,
|
|
86
|
+
privacyCopy: privacyCopy,
|
|
87
|
+
formContext: formMethods
|
|
88
|
+
})));
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
var _default = EmailSignUpForm;
|
|
92
|
+
exports.default = _default;
|