@comicrelief/component-library 7.7.0 → 7.9.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/Atoms/MarketingPreferencesDSForm.spec.js +2 -2
- package/dist/components/Organisms/MarketingPreferencesDS/MarketingPreferencesDS.style.js +60 -42
- package/dist/components/Organisms/MarketingPreferencesDS/_AssociatedFields.js +16 -4
- package/dist/components/Organisms/MarketingPreferencesDS/_CheckAnswer.js +5 -15
- package/dist/components/Organisms/MarketingPreferencesDS/_DefaultCopy.js +6 -6
- package/dist/components/Organisms/MarketingPreferencesDS/_MarketingPreferencesDS.js +67 -114
- package/dist/components/Organisms/MarketingPreferencesDS/_MarketingPrefsConfig.js +8 -11
- package/dist/components/Organisms/MarketingPreferencesDS/assets/CR_Tick_black.svg +1 -0
- package/dist/theme/crTheme/colors.js +4 -0
- package/package.json +1 -1
- package/src/components/Organisms/MarketingPreferencesDS/MarketingPreferencesDS.style.js +78 -71
- package/src/components/Organisms/MarketingPreferencesDS/_AssociatedFields.js +16 -4
- package/src/components/Organisms/MarketingPreferencesDS/_CheckAnswer.js +9 -18
- package/src/components/Organisms/MarketingPreferencesDS/_DefaultCopy.js +8 -8
- package/src/components/Organisms/MarketingPreferencesDS/_MarketingPreferencesDS.js +105 -107
- package/src/components/Organisms/MarketingPreferencesDS/_MarketingPrefsConfig.js +8 -11
- package/src/components/Organisms/MarketingPreferencesDS/assets/CR_Tick_black.svg +1 -0
- package/src/theme/crTheme/colors.js +4 -0
- package/dist/components/Organisms/MarketingPreferencesDS/_NoMessage.js +0 -40
- package/src/components/Organisms/MarketingPreferencesDS/_NoMessage.js +0 -27
|
@@ -24,10 +24,10 @@ var setInitialValues = function setInitialValues(overrideValues) {
|
|
|
24
24
|
mp_town: '',
|
|
25
25
|
mp_country: '',
|
|
26
26
|
mp_postcode: '',
|
|
27
|
-
mp_permissionEmail:
|
|
28
|
-
mp_permissionPost:
|
|
29
|
-
mp_permissionPhone:
|
|
30
|
-
mp_permissionSMS:
|
|
27
|
+
mp_permissionEmail: false,
|
|
28
|
+
mp_permissionPost: false,
|
|
29
|
+
mp_permissionPhone: false,
|
|
30
|
+
mp_permissionSMS: false
|
|
31
31
|
}; // Override with any custom options supplied
|
|
32
32
|
|
|
33
33
|
var updatedValues = (0, _lodash.merge)(defaultValues, overrideValues);
|
|
@@ -41,12 +41,12 @@ var buildValidationSchema = function buildValidationSchema(overrideOptions) {
|
|
|
41
41
|
mp_permissionEmail: {
|
|
42
42
|
/**
|
|
43
43
|
* As per react-hook-form's validation requirements, sets the fields' required attribute
|
|
44
|
-
* for each checkbox option (Yes
|
|
45
|
-
* in the validation. As the backend *currently* needs values to formalise
|
|
46
|
-
* we'll set all fields to 'required' by default
|
|
44
|
+
* for each checkbox option (now only 'Yes' as of 2023), a non-required field isn't rendered
|
|
45
|
+
* or included in the validation. As the backend *currently* needs values to formalise
|
|
46
|
+
* a user's opt-out, we'll set all fields to 'required' by default
|
|
47
|
+
* (once the option is chosen).
|
|
47
48
|
*/
|
|
48
49
|
yes: true,
|
|
49
|
-
no: true,
|
|
50
50
|
// Hide the input from user interaction, but keep it in the DOM so we can pass values to it
|
|
51
51
|
hideInput: false,
|
|
52
52
|
// Allows complete removal of the option (checkboxes & fields) from both render & validation.
|
|
@@ -54,19 +54,16 @@ var buildValidationSchema = function buildValidationSchema(overrideOptions) {
|
|
|
54
54
|
},
|
|
55
55
|
mp_permissionSMS: {
|
|
56
56
|
yes: true,
|
|
57
|
-
no: true,
|
|
58
57
|
hideInput: false,
|
|
59
58
|
disableOption: false
|
|
60
59
|
},
|
|
61
60
|
mp_permissionPhone: {
|
|
62
61
|
yes: true,
|
|
63
|
-
no: true,
|
|
64
62
|
hideInput: false,
|
|
65
63
|
disableOption: false
|
|
66
64
|
},
|
|
67
65
|
mp_permissionPost: {
|
|
68
66
|
yes: true,
|
|
69
|
-
no: true,
|
|
70
67
|
hideInput: false,
|
|
71
68
|
disableOption: false
|
|
72
69
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M36.121 15.879a2.998 2.998 0 0 0-4.242 0L21 26.757l-4.879-4.878a2.998 2.998 0 0 0-4.242 0 2.998 2.998 0 0 0 0 4.242l7 7c.586.586 1.353.879 2.121.879s1.535-.293 2.121-.879l13-13a2.998 2.998 0 0 0 0-4.242z" fill="#000"/></svg>
|
|
@@ -46,6 +46,10 @@ var colors = {
|
|
|
46
46
|
purple_light: '#DFC6F6',
|
|
47
47
|
red: '#E52630',
|
|
48
48
|
red_dark: '#890B11',
|
|
49
|
+
rnd_23_teal: '#3EB1AA',
|
|
50
|
+
rnd_23_yellow: '#FFE300',
|
|
51
|
+
rnd_23_pink: '#EDB4D3',
|
|
52
|
+
rnd_23_black: '#2B3737',
|
|
49
53
|
teal: '#4ECDBE',
|
|
50
54
|
teal_dark: '#13767C',
|
|
51
55
|
teal_light: '#86E4E9',
|
package/package.json
CHANGED
|
@@ -2,15 +2,27 @@ import styled, { css } from 'styled-components';
|
|
|
2
2
|
|
|
3
3
|
import spacing from '../../../theme/shared/spacing';
|
|
4
4
|
import { media } from '../../../theme/shared/size';
|
|
5
|
-
import checkBoxIcon from './assets/
|
|
5
|
+
import checkBoxIcon from './assets/CR_Tick_black.svg';
|
|
6
|
+
import TextInput from './_TextInput';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const OuterWrapper = styled.div`
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
|
|
12
|
+
${media('small')} {
|
|
13
|
+
flex-direction: row;
|
|
14
|
+
flex-wrap: wrap;
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
11
17
|
|
|
12
18
|
const TopCopyWrapper = styled.div`
|
|
13
19
|
margin: ${spacing('l')} 0;
|
|
20
|
+
display: flex;
|
|
21
|
+
width: 100%;
|
|
22
|
+
|
|
23
|
+
@media ${({ theme }) => theme.breakpoint('small')} {
|
|
24
|
+
padding: 10px;
|
|
25
|
+
}
|
|
14
26
|
`;
|
|
15
27
|
|
|
16
28
|
const BottomCopyWrapper = styled.div`
|
|
@@ -26,25 +38,24 @@ const Head = styled.div`
|
|
|
26
38
|
const FormField = styled.div`${({ theme }) => css`
|
|
27
39
|
position: relative;
|
|
28
40
|
margin-bottom: ${spacing('md')};
|
|
41
|
+
width: 100%;
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
|
|
45
|
+
@media ${theme.breakpoint('small')} {
|
|
46
|
+
width: 50%;
|
|
47
|
+
padding: 10px;
|
|
48
|
+
}
|
|
29
49
|
|
|
30
50
|
label {
|
|
31
51
|
position: relative;
|
|
32
52
|
margin-bottom: ${spacing('md')};
|
|
33
|
-
width:
|
|
34
|
-
padding: 10px;
|
|
35
|
-
border: 1px solid ${theme.color('grey')};
|
|
36
|
-
box-sizing: border-box;
|
|
37
|
-
border-radius: 8px;
|
|
53
|
+
width: 100%;
|
|
38
54
|
color: ${theme.color('grey_dark')};
|
|
39
|
-
|
|
40
|
-
@media ${theme.breakpoint('small')} {
|
|
41
|
-
padding: 12px 16px;
|
|
42
|
-
}
|
|
43
55
|
}
|
|
44
56
|
|
|
45
57
|
h3 {
|
|
46
58
|
position: relative;
|
|
47
|
-
padding-left: 35px;
|
|
48
59
|
margin-bottom: ${spacing('md')};
|
|
49
60
|
|
|
50
61
|
&:before {
|
|
@@ -56,23 +67,7 @@ const FormField = styled.div`${({ theme }) => css`
|
|
|
56
67
|
content: '';
|
|
57
68
|
}
|
|
58
69
|
}
|
|
59
|
-
|
|
60
|
-
&.field-email h3:before {
|
|
61
|
-
background: url(${EmailIcon}) top left/contain no-repeat;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
&.field-sms h3:before {
|
|
65
|
-
background: url(${SMSIcon}) top left/contain no-repeat;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
&.field-phone h3:before {
|
|
69
|
-
background: url(${PhoneIcon}) top left/contain no-repeat;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
&.field-post h3:before {
|
|
73
|
-
background: url(${PostIcon}) top left/contain no-repeat;
|
|
74
|
-
}
|
|
75
|
-
`}`;
|
|
70
|
+
`}`;
|
|
76
71
|
|
|
77
72
|
const CheckContainer = styled.div`${({ theme }) => css`
|
|
78
73
|
width: 100%;
|
|
@@ -80,45 +75,17 @@ const CheckContainer = styled.div`${({ theme }) => css`
|
|
|
80
75
|
justify-content: space-between;
|
|
81
76
|
font-size: ${theme.fontSize('md')};
|
|
82
77
|
font-family: ${theme.fontFamilies(theme.font.regular)};
|
|
78
|
+
`}`;
|
|
83
79
|
|
|
84
|
-
|
|
85
|
-
width: 380px;
|
|
86
|
-
}
|
|
87
|
-
`}`;
|
|
88
|
-
|
|
89
|
-
const CheckLabel = styled.label`${({ theme, userSelection }) => css`
|
|
80
|
+
const CheckLabel = styled.label`${({ theme }) => css`
|
|
90
81
|
display: flex;
|
|
91
82
|
align-items: center;
|
|
92
83
|
font-size: ${theme.fontSize('xs')};
|
|
93
|
-
padding: 10px;
|
|
94
84
|
|
|
95
85
|
@media ${theme.breakpoint('small')} {
|
|
96
86
|
font-size: ${theme.fontSize('s')};
|
|
97
|
-
padding: 12px 16px;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
&:hover,
|
|
101
|
-
&:focus {
|
|
102
|
-
border: 2px solid ${theme.color('grey')};
|
|
103
|
-
padding: 9px;
|
|
104
|
-
@media ${theme.breakpoint('small')} {
|
|
105
|
-
padding: 11px 15px;
|
|
106
|
-
}
|
|
107
87
|
}
|
|
108
|
-
|
|
109
|
-
${userSelection && `
|
|
110
|
-
&[for$="${userSelection}"] {
|
|
111
|
-
background: ${theme.color('grey_medium')};
|
|
112
|
-
padding: 9px;
|
|
113
|
-
border: 2px solid ${theme.color('grey')};
|
|
114
|
-
|
|
115
|
-
@media ${theme.breakpoint('small')} {
|
|
116
|
-
padding: 11px 15px;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
`}
|
|
120
|
-
`}
|
|
121
|
-
`;
|
|
88
|
+
`}`;
|
|
122
89
|
|
|
123
90
|
const CheckInput = styled.input`
|
|
124
91
|
font-size: ${({ theme }) => theme.fontSize('sm')};
|
|
@@ -137,7 +104,7 @@ const CheckInput = styled.input`
|
|
|
137
104
|
width: 30px;
|
|
138
105
|
height: 30px;
|
|
139
106
|
background-color: ${({ theme }) => theme.color('grey_light')};
|
|
140
|
-
border: 1px solid ${({ theme }) => theme.color('
|
|
107
|
+
border: 1px solid ${({ theme }) => theme.color('black')};
|
|
141
108
|
float: left;
|
|
142
109
|
border-radius: 8px;
|
|
143
110
|
|
|
@@ -147,20 +114,15 @@ const CheckInput = styled.input`
|
|
|
147
114
|
}
|
|
148
115
|
:checked + span {
|
|
149
116
|
background: url(${checkBoxIcon}) no-repeat center;
|
|
150
|
-
background-color: ${({ theme }) => theme.color('
|
|
117
|
+
background-color: ${({ theme }) => theme.color('grey_light')};
|
|
151
118
|
background-size: contain;
|
|
152
119
|
}
|
|
153
120
|
`;
|
|
154
121
|
|
|
155
122
|
const ShowHideInputWrapper = styled.div`
|
|
156
123
|
display: ${({ show }) => (show ? 'block' : 'none')};
|
|
157
|
-
margin-bottom: ${spacing('lg')};
|
|
158
124
|
width: 100%;
|
|
159
125
|
|
|
160
|
-
${media('small')} {
|
|
161
|
-
max-width: 290px;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
126
|
label {
|
|
165
127
|
width: 100%;
|
|
166
128
|
border: none;
|
|
@@ -168,6 +130,48 @@ const ShowHideInputWrapper = styled.div`
|
|
|
168
130
|
}
|
|
169
131
|
`;
|
|
170
132
|
|
|
133
|
+
const ExtraInfo = styled.span`
|
|
134
|
+
display: block;
|
|
135
|
+
width: 100%;
|
|
136
|
+
font-size: 1rem;
|
|
137
|
+
text-transform: inherit;
|
|
138
|
+
font-weight: normal;
|
|
139
|
+
line-height: normal;
|
|
140
|
+
font-family: 'Montserrat',Helvetica,Arial,sans-serif;
|
|
141
|
+
margin-bottom: 0.5rem;
|
|
142
|
+
|
|
143
|
+
+ label {
|
|
144
|
+
margin-top: 20px;
|
|
145
|
+
|
|
146
|
+
// Visually hide the actual field label for the
|
|
147
|
+
// non-multifield options, as we have the
|
|
148
|
+
// more chatty 'extra info' language
|
|
149
|
+
&[for="mp_email"],
|
|
150
|
+
&[for="mp_mobile"],
|
|
151
|
+
&[for="mp_phone"] {
|
|
152
|
+
> span:first-child {
|
|
153
|
+
position: absolute;
|
|
154
|
+
margin: -1px;
|
|
155
|
+
padding: 0;
|
|
156
|
+
width: 1px;
|
|
157
|
+
height: 1px;
|
|
158
|
+
border: 0;
|
|
159
|
+
overflow: hidden;
|
|
160
|
+
clip: rect(1px 1px 1px 1px);
|
|
161
|
+
word-wrap: normal;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
`;
|
|
165
|
+
|
|
166
|
+
const MPTextInput = styled(TextInput)`
|
|
167
|
+
input {
|
|
168
|
+
border: 1px solid ${({ theme }) => theme.color('black')};;
|
|
169
|
+
${media('small')} {
|
|
170
|
+
max-width: none;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
`;
|
|
174
|
+
|
|
171
175
|
export {
|
|
172
176
|
TopCopyWrapper,
|
|
173
177
|
BottomCopyWrapper,
|
|
@@ -176,5 +180,8 @@ export {
|
|
|
176
180
|
CheckLabel,
|
|
177
181
|
CheckInput,
|
|
178
182
|
CheckContainer,
|
|
179
|
-
ShowHideInputWrapper
|
|
183
|
+
ShowHideInputWrapper,
|
|
184
|
+
ExtraInfo,
|
|
185
|
+
OuterWrapper,
|
|
186
|
+
MPTextInput
|
|
180
187
|
};
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
const AssociatedFields = {
|
|
2
|
-
mp_permissionSMS:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
mp_permissionSMS: {
|
|
3
|
+
fieldNames: ['mp_mobile'],
|
|
4
|
+
label: 'Text'
|
|
5
|
+
},
|
|
6
|
+
mp_permissionPhone: {
|
|
7
|
+
fieldNames: ['mp_phone'],
|
|
8
|
+
label: 'Phone'
|
|
9
|
+
},
|
|
10
|
+
mp_permissionEmail: {
|
|
11
|
+
fieldNames: ['mp_email'],
|
|
12
|
+
label: 'Email'
|
|
13
|
+
},
|
|
14
|
+
mp_permissionPost: {
|
|
15
|
+
fieldNames: ['mp_address1', 'mp_address2', 'mp_address3', 'mp_town', 'mp_postcode', 'mp_country'],
|
|
16
|
+
label: 'Post'
|
|
17
|
+
}
|
|
6
18
|
};
|
|
7
19
|
|
|
8
20
|
export default AssociatedFields;
|
|
@@ -16,26 +16,26 @@ const CheckAnswer = ({
|
|
|
16
16
|
const onChange = e => {
|
|
17
17
|
let newVal;
|
|
18
18
|
if (e.target.checked) {
|
|
19
|
-
newVal = e.target.value
|
|
19
|
+
newVal = e.target.value;
|
|
20
20
|
} else {
|
|
21
21
|
newVal = '';
|
|
22
22
|
|
|
23
23
|
// To ensure we're not letting invalid values get passed, reset any associated fields:
|
|
24
|
-
const theseFields = AssociatedFields[name];
|
|
24
|
+
const theseFields = AssociatedFields[name].fieldNames;
|
|
25
25
|
theseFields.forEach(fieldName => {
|
|
26
26
|
setValue(fieldName, '');
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// Update the checkbox field itself
|
|
31
|
-
setValue(name,
|
|
31
|
+
setValue(name, newVal);
|
|
32
32
|
|
|
33
33
|
/* If the click represents either a 'none selected' or a 'not required' option
|
|
34
34
|
(set in config), reset errors for all fields associated with this checkbox */
|
|
35
35
|
const reValidate = !mpValidationOptions[name][newVal];
|
|
36
36
|
|
|
37
37
|
if (reValidate) {
|
|
38
|
-
const theseFields = AssociatedFields[name];
|
|
38
|
+
const theseFields = AssociatedFields[name].fieldNames;
|
|
39
39
|
theseFields.forEach(fieldName => {
|
|
40
40
|
clearErrors(fieldName);
|
|
41
41
|
});
|
|
@@ -54,19 +54,7 @@ const CheckAnswer = ({
|
|
|
54
54
|
onChange={onChange}
|
|
55
55
|
/>
|
|
56
56
|
<span />
|
|
57
|
-
|
|
58
|
-
</CheckLabel>
|
|
59
|
-
<CheckLabel htmlFor={`${name}-no`} userSelection={userSelection}>
|
|
60
|
-
<CheckInput
|
|
61
|
-
type="checkbox"
|
|
62
|
-
id={`${name}-no`}
|
|
63
|
-
name={name}
|
|
64
|
-
value="no"
|
|
65
|
-
ref={register}
|
|
66
|
-
onChange={onChange}
|
|
67
|
-
/>
|
|
68
|
-
<span />
|
|
69
|
-
No, thanks
|
|
57
|
+
{ AssociatedFields[name].label }
|
|
70
58
|
</CheckLabel>
|
|
71
59
|
</CheckContainer>
|
|
72
60
|
);
|
|
@@ -82,7 +70,10 @@ CheckAnswer.propTypes = {
|
|
|
82
70
|
/* These options are created in _MarketingPrefsConfig.js, passed to react-hook-form
|
|
83
71
|
in the parent to set-up the validation, but also required here for additional functionality */
|
|
84
72
|
mpValidationOptions: PropTypes.objectOf(PropTypes.shape).isRequired,
|
|
85
|
-
userSelection: PropTypes.
|
|
73
|
+
userSelection: PropTypes.oneOfType([
|
|
74
|
+
PropTypes.string,
|
|
75
|
+
PropTypes.bool
|
|
76
|
+
]),
|
|
86
77
|
formContext: PropTypes.shape()
|
|
87
78
|
};
|
|
88
79
|
|
|
@@ -5,35 +5,35 @@ import Link from '../../Atoms/Link/Link';
|
|
|
5
5
|
const defaultCopyTop = (
|
|
6
6
|
<div>
|
|
7
7
|
<Text tag="h3" size="xl" family="Anton" uppercase weight="400" color="grey_dark">
|
|
8
|
-
|
|
8
|
+
Stay up to date with Comic Relief?
|
|
9
9
|
</Text>
|
|
10
10
|
<Text tag="p" size="md" color="grey_dark">
|
|
11
|
-
We’d
|
|
12
|
-
|
|
11
|
+
We’d like to send you updates on the work we’re funding and how
|
|
12
|
+
your support makes a difference in the UK and around the world.
|
|
13
13
|
</Text>
|
|
14
14
|
<Text tag="p" size="md" color="grey_dark">
|
|
15
|
-
Please
|
|
15
|
+
Please tick the relevant boxes below if you would like to hear from us.
|
|
16
16
|
</Text>
|
|
17
17
|
</div>
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
const defaultCopyBottom = (
|
|
21
21
|
<Text tag="p" color="grey_dark">
|
|
22
|
-
|
|
22
|
+
Update your preferences at any time by visiting our
|
|
23
23
|
{' '}
|
|
24
24
|
<Link
|
|
25
25
|
type="standard"
|
|
26
26
|
href="https://www.comicrelief.com/update-your-preferences"
|
|
27
27
|
>
|
|
28
|
-
|
|
28
|
+
preferences centre
|
|
29
29
|
</Link>
|
|
30
|
-
. Your details will be kept safe,
|
|
30
|
+
. Your details will be kept safe, see our
|
|
31
31
|
{' '}
|
|
32
32
|
<Link type="standard" href="https://www.comicrelief.com/privacy-policy">
|
|
33
33
|
privacy policy
|
|
34
34
|
</Link>
|
|
35
35
|
{' '}
|
|
36
|
-
for more
|
|
36
|
+
for more information.
|
|
37
37
|
</Text>
|
|
38
38
|
);
|
|
39
39
|
|