@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
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { merge } from 'lodash';
|
|
2
|
+
import * as yup from 'yup';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ESU_FIELDS
|
|
6
|
+
*
|
|
7
|
+
* Exposes an enum to consumer of the component, to accurately access the underlying field names.
|
|
8
|
+
* can be used in conjunction with RHF or buildEsuValidationSchema
|
|
9
|
+
* to customise form validation or behaviour, as the fields are handled within the CL
|
|
10
|
+
* we just make this read-only to prevent any external changes of this object.
|
|
11
|
+
*/
|
|
12
|
+
const ESU_FIELDS = Object.freeze({
|
|
13
|
+
FIRST_NAME: 'firstName',
|
|
14
|
+
LAST_NAME: 'lastName',
|
|
15
|
+
EMAIL: 'email'
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* buildEsuValidationSchema
|
|
20
|
+
*
|
|
21
|
+
* Exposes a function that can be passed a partial or complete yup schema
|
|
22
|
+
* to extend or override the default buildEsuValidationSchema
|
|
23
|
+
*
|
|
24
|
+
* @param overrides {Object} - A yup schema object (or an empty object)
|
|
25
|
+
*/
|
|
26
|
+
const buildEsuValidationSchema = overrides => {
|
|
27
|
+
const defaultSchema = yup.object({
|
|
28
|
+
[ESU_FIELDS.FIRST_NAME]: yup
|
|
29
|
+
.string()
|
|
30
|
+
.required('Please enter your first name')
|
|
31
|
+
.matches(
|
|
32
|
+
/^[A-Za-z][A-Za-z' -]*$/,
|
|
33
|
+
"This field only accepts letters and ' - and must start with a letter"
|
|
34
|
+
)
|
|
35
|
+
.max(25, 'Your first name must be between 1 and 25 characters'),
|
|
36
|
+
[ESU_FIELDS.LAST_NAME]: yup
|
|
37
|
+
.string()
|
|
38
|
+
.required('Please enter your last name')
|
|
39
|
+
.matches(
|
|
40
|
+
/^[A-Za-z][A-Za-z' -]*$/,
|
|
41
|
+
"This field only accepts letters and ' - and must start with a letter"
|
|
42
|
+
)
|
|
43
|
+
.max(50, 'Your first name must be between 1 and 50 characters'),
|
|
44
|
+
[ESU_FIELDS.EMAIL]: yup
|
|
45
|
+
.string()
|
|
46
|
+
.required('Please enter your email address')
|
|
47
|
+
.email('Please enter a valid email address')
|
|
48
|
+
.max(100, 'Your email address must be between 1 and 100 characters long')
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return merge(defaultSchema, overrides);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { ESU_FIELDS, buildEsuValidationSchema };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Input from '../../Atoms/Input/Input';
|
|
4
|
+
|
|
5
|
+
// TODO: This is a copy paste of the RHF friendly `TextInput` from Marketing Prefs.
|
|
6
|
+
// Perhaps it would be worthwhile refactoring this into a new `Atom` as a seperate PR.
|
|
7
|
+
const TextInput = ({
|
|
8
|
+
fieldName,
|
|
9
|
+
label,
|
|
10
|
+
optional,
|
|
11
|
+
fieldType,
|
|
12
|
+
formContext,
|
|
13
|
+
...rest
|
|
14
|
+
}) => {
|
|
15
|
+
const { errors, register } = formContext;
|
|
16
|
+
|
|
17
|
+
const props = {
|
|
18
|
+
name: fieldName,
|
|
19
|
+
type: fieldType,
|
|
20
|
+
label,
|
|
21
|
+
placeholder: label,
|
|
22
|
+
errorMsg: errors && errors[fieldName] && errors[fieldName].message,
|
|
23
|
+
optional,
|
|
24
|
+
'aria-required': !optional,
|
|
25
|
+
...rest
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return <Input {...props} ref={register} />;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
TextInput.defaultProps = {
|
|
32
|
+
optional: null,
|
|
33
|
+
fieldType: 'text',
|
|
34
|
+
formContext: null
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
TextInput.propTypes = {
|
|
38
|
+
fieldName: PropTypes.string.isRequired,
|
|
39
|
+
label: PropTypes.string.isRequired,
|
|
40
|
+
optional: PropTypes.bool,
|
|
41
|
+
fieldType: PropTypes.string,
|
|
42
|
+
formContext: PropTypes.shape()
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default TextInput;
|