@comicrelief/component-library 8.31.2 → 8.33.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/dist/components/Atoms/Input/Input.md +0 -1
- package/dist/components/Atoms/Input/input.test.js +2 -2
- package/dist/components/Atoms/Label/Label.js +4 -12
- package/dist/components/Atoms/Select/Select.js +12 -7
- package/dist/components/Atoms/Select/Select.md +12 -0
- package/dist/components/Atoms/Select/__snapshots__/Select.test.js.snap +1 -1
- package/dist/components/Atoms/TextArea/TextArea.test.js +1 -1
- package/dist/components/Atoms/TextInputWithDropdown/__snapshots__/TextInputWithDropdown.test.js.snap +3 -3
- package/dist/components/Molecules/SchoolLookup/__snapshots__/SchoolLookup.test.js.snap +1 -1
- package/dist/components/Molecules/SearchInput/SearchInput.test.js +1 -1
- package/dist/components/Molecules/Typeahead/__snapshots__/Typeahead.test.js.snap +1 -1
- package/dist/components/Organisms/Donate/__snapshots__/Donate.test.js.snap +4 -4
- package/dist/components/Organisms/EmailSignUp/__snapshots__/EmailSignUp.test.js.snap +1 -1
- package/dist/components/Organisms/Membership/Membership.test.js +1 -1
- package/package.json +1 -1
- package/src/components/Atoms/Input/Input.md +0 -1
- package/src/components/Atoms/Input/input.test.js +2 -2
- package/src/components/Atoms/Label/Label.js +4 -12
- package/src/components/Atoms/Select/Select.js +17 -7
- package/src/components/Atoms/Select/Select.md +12 -0
- package/src/components/Atoms/Select/__snapshots__/Select.test.js.snap +1 -1
- package/src/components/Atoms/TextArea/TextArea.test.js +1 -1
- package/src/components/Atoms/TextInputWithDropdown/__snapshots__/TextInputWithDropdown.test.js.snap +3 -3
- package/src/components/Molecules/SchoolLookup/__snapshots__/SchoolLookup.test.js.snap +1 -1
- package/src/components/Molecules/SearchInput/SearchInput.test.js +1 -1
- package/src/components/Molecules/Typeahead/__snapshots__/Typeahead.test.js.snap +1 -1
- package/src/components/Organisms/Donate/__snapshots__/Donate.test.js.snap +4 -4
- package/src/components/Organisms/EmailSignUp/__snapshots__/EmailSignUp.test.js.snap +1 -1
- package/src/components/Organisms/Membership/Membership.test.js +1 -1
|
@@ -33,7 +33,7 @@ it('renders correctly', () => {
|
|
|
33
33
|
-webkit-flex-direction: column;
|
|
34
34
|
-ms-flex-direction: column;
|
|
35
35
|
flex-direction: column;
|
|
36
|
-
color: #
|
|
36
|
+
color: #000000;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
.c2 {
|
|
@@ -161,7 +161,7 @@ it('renders with responsive max widths correctly', () => {
|
|
|
161
161
|
-webkit-flex-direction: column;
|
|
162
162
|
-ms-flex-direction: column;
|
|
163
163
|
flex-direction: column;
|
|
164
|
-
color: #
|
|
164
|
+
color: #000000;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
.c2 {
|
|
@@ -14,16 +14,12 @@ var _hideVisually = _interopRequireDefault(require("../../../theme/shared/hideVi
|
|
|
14
14
|
const getLabelColor = _ref => {
|
|
15
15
|
let {
|
|
16
16
|
theme,
|
|
17
|
-
errorMsg
|
|
18
|
-
darkLabel
|
|
17
|
+
errorMsg
|
|
19
18
|
} = _ref;
|
|
20
19
|
if (errorMsg) {
|
|
21
20
|
return theme.color('red');
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
return theme.color('black');
|
|
25
|
-
}
|
|
26
|
-
return theme.color('grey_label');
|
|
22
|
+
return theme.color('black');
|
|
27
23
|
};
|
|
28
24
|
const LabelElement = _styledComponents.default.label.withConfig({
|
|
29
25
|
displayName: "Label__LabelElement",
|
|
@@ -71,7 +67,6 @@ const LabelText = _ref3 => {
|
|
|
71
67
|
* @param children
|
|
72
68
|
* @param label
|
|
73
69
|
* @param hideLabel - Visually hide the label text (without removing it from the document)
|
|
74
|
-
* @param darkLabel - Make the label text black rather than the default grey
|
|
75
70
|
* @param rest
|
|
76
71
|
* @returns {JSX.Element}
|
|
77
72
|
* @constructor
|
|
@@ -81,15 +76,13 @@ const Label = _ref4 => {
|
|
|
81
76
|
children = null,
|
|
82
77
|
label,
|
|
83
78
|
hideLabel = false,
|
|
84
|
-
darkLabel = false,
|
|
85
79
|
optional = null,
|
|
86
80
|
errorMsg = '',
|
|
87
81
|
...rest
|
|
88
82
|
} = _ref4;
|
|
89
83
|
return /*#__PURE__*/_react.default.createElement(LabelElement, Object.assign({
|
|
90
84
|
optional: optional,
|
|
91
|
-
errorMsg: errorMsg
|
|
92
|
-
darkLabel: darkLabel
|
|
85
|
+
errorMsg: errorMsg
|
|
93
86
|
}, rest), /*#__PURE__*/_react.default.createElement(LabelText, {
|
|
94
87
|
label: label,
|
|
95
88
|
hideLabel: hideLabel
|
|
@@ -97,7 +90,6 @@ const Label = _ref4 => {
|
|
|
97
90
|
};
|
|
98
91
|
LabelElement.propTypes = {
|
|
99
92
|
optional: _propTypes.default.bool,
|
|
100
|
-
errorMsg: _propTypes.default.string
|
|
101
|
-
darkLabel: _propTypes.default.bool
|
|
93
|
+
errorMsg: _propTypes.default.string
|
|
102
94
|
};
|
|
103
95
|
var _default = exports.default = Label;
|
|
@@ -15,7 +15,7 @@ var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
|
|
|
15
15
|
const StyledSelect = _styledComponents.default.select.withConfig({
|
|
16
16
|
displayName: "Select__StyledSelect",
|
|
17
17
|
componentId: "sc-1atp8e3-0"
|
|
18
|
-
})(["width:100%;font-size:", ";display:block;box-sizing:border-box;padding:0 ", ";padding-right:", ";margin:0;position:relative;height:48px;font-weight:400;font-family:", ";background:", "
|
|
18
|
+
})(["width:100%;font-size:", ";display:block;box-sizing:border-box;padding:0 ", ";padding-right:", ";margin:0;position:relative;height:48px;font-weight:400;font-family:", ";background:", ";border:1px solid;border-color:", ";box-shadow:none;appearance:none;color:", ";border-radius:0.5rem;cursor:pointer;:focus{border:1px solid ", ";}@media ", "{max-width:290px;}"], _ref => {
|
|
19
19
|
let {
|
|
20
20
|
theme
|
|
21
21
|
} = _ref;
|
|
@@ -27,10 +27,11 @@ const StyledSelect = _styledComponents.default.select.withConfig({
|
|
|
27
27
|
return theme.fontFamilies(theme.font.regular);
|
|
28
28
|
}, _ref3 => {
|
|
29
29
|
let {
|
|
30
|
-
theme
|
|
30
|
+
theme,
|
|
31
|
+
hideArrow
|
|
31
32
|
} = _ref3;
|
|
32
|
-
return theme.color('grey_light')
|
|
33
|
-
},
|
|
33
|
+
return hideArrow ? theme.color('grey_light') : `${theme.color('grey_light')} url(${_dropDownDarkPurple.default}) calc(100% - 1.5rem) 14px/20px 1.5rem no-repeat`;
|
|
34
|
+
}, _ref4 => {
|
|
34
35
|
let {
|
|
35
36
|
theme,
|
|
36
37
|
error
|
|
@@ -66,9 +67,11 @@ const Select = /*#__PURE__*/_react.default.forwardRef((_ref8, ref) => {
|
|
|
66
67
|
greyDescription = false,
|
|
67
68
|
className = '',
|
|
68
69
|
optional = false,
|
|
70
|
+
hideArrow = false,
|
|
69
71
|
...rest
|
|
70
72
|
} = _ref8;
|
|
71
|
-
const
|
|
73
|
+
const initialValue = hideArrow ? options[0].value : defaultValue;
|
|
74
|
+
const [value, setValue] = (0, _react.useState)(initialValue);
|
|
72
75
|
return /*#__PURE__*/_react.default.createElement(_Label.default, {
|
|
73
76
|
label: label,
|
|
74
77
|
hideLabel: hideLabel,
|
|
@@ -88,8 +91,10 @@ const Select = /*#__PURE__*/_react.default.forwardRef((_ref8, ref) => {
|
|
|
88
91
|
required: optional === false,
|
|
89
92
|
hasValue: !!value,
|
|
90
93
|
greyDescription: greyDescription,
|
|
91
|
-
ref: ref
|
|
92
|
-
|
|
94
|
+
ref: ref,
|
|
95
|
+
hideArrow: hideArrow
|
|
96
|
+
}), /* empty string "" is falsy so will show */
|
|
97
|
+
!initialValue && /*#__PURE__*/_react.default.createElement("option", {
|
|
93
98
|
disabled: true,
|
|
94
99
|
value: ""
|
|
95
100
|
}, description), options.map(option => /*#__PURE__*/_react.default.createElement("option", {
|
|
@@ -32,4 +32,16 @@
|
|
|
32
32
|
{ value: 'Option four', displayValue: 'The fourth option' }
|
|
33
33
|
]}
|
|
34
34
|
/>
|
|
35
|
+
|
|
36
|
+
<h4>DROPDOWN MENU - hide arrow / just one option</h4>
|
|
37
|
+
<Select
|
|
38
|
+
label="Label"
|
|
39
|
+
errorMsg="This is an error message"
|
|
40
|
+
description="Select an option"
|
|
41
|
+
greyDescription
|
|
42
|
+
hideArrow={true}
|
|
43
|
+
options={[
|
|
44
|
+
{ value: 'Option one', displayValue: 'The first option' }
|
|
45
|
+
]}
|
|
46
|
+
/>
|
|
35
47
|
```
|
package/dist/components/Atoms/TextInputWithDropdown/__snapshots__/TextInputWithDropdown.test.js.snap
CHANGED
|
@@ -19,7 +19,7 @@ exports[`renders correctly with no value and no options 1`] = `
|
|
|
19
19
|
-webkit-flex-direction: column;
|
|
20
20
|
-ms-flex-direction: column;
|
|
21
21
|
flex-direction: column;
|
|
22
|
-
color: #
|
|
22
|
+
color: #000000;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
.c3 {
|
|
@@ -149,7 +149,7 @@ exports[`renders correctly with value and no options 1`] = `
|
|
|
149
149
|
-webkit-flex-direction: column;
|
|
150
150
|
-ms-flex-direction: column;
|
|
151
151
|
flex-direction: column;
|
|
152
|
-
color: #
|
|
152
|
+
color: #000000;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
.c3 {
|
|
@@ -279,7 +279,7 @@ exports[`renders correctly with value and options 1`] = `
|
|
|
279
279
|
-webkit-flex-direction: column;
|
|
280
280
|
-ms-flex-direction: column;
|
|
281
281
|
flex-direction: column;
|
|
282
|
-
color: #
|
|
282
|
+
color: #000000;
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
.c3 {
|
|
@@ -51,7 +51,7 @@ exports[`"Single Giving, No Money Buys, with overridden manual input value" rend
|
|
|
51
51
|
-webkit-flex-direction: column;
|
|
52
52
|
-ms-flex-direction: column;
|
|
53
53
|
flex-direction: column;
|
|
54
|
-
color: #
|
|
54
|
+
color: #000000;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
.c21 {
|
|
@@ -750,7 +750,7 @@ exports[`Monthly donation renders correctly 1`] = `
|
|
|
750
750
|
-webkit-flex-direction: column;
|
|
751
751
|
-ms-flex-direction: column;
|
|
752
752
|
flex-direction: column;
|
|
753
|
-
color: #
|
|
753
|
+
color: #000000;
|
|
754
754
|
}
|
|
755
755
|
|
|
756
756
|
.c22 {
|
|
@@ -1416,7 +1416,7 @@ exports[`Single donation renders correctly 1`] = `
|
|
|
1416
1416
|
-webkit-flex-direction: column;
|
|
1417
1417
|
-ms-flex-direction: column;
|
|
1418
1418
|
flex-direction: column;
|
|
1419
|
-
color: #
|
|
1419
|
+
color: #000000;
|
|
1420
1420
|
}
|
|
1421
1421
|
|
|
1422
1422
|
.c15 {
|
|
@@ -2168,7 +2168,7 @@ exports[`Single donation with no Money Buys renders correctly 1`] = `
|
|
|
2168
2168
|
-webkit-flex-direction: column;
|
|
2169
2169
|
-ms-flex-direction: column;
|
|
2170
2170
|
flex-direction: column;
|
|
2171
|
-
color: #
|
|
2171
|
+
color: #000000;
|
|
2172
2172
|
}
|
|
2173
2173
|
|
|
2174
2174
|
.c15 {
|
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@ it('renders correctly', () => {
|
|
|
34
34
|
-webkit-flex-direction: column;
|
|
35
35
|
-ms-flex-direction: column;
|
|
36
36
|
flex-direction: column;
|
|
37
|
-
color: #
|
|
37
|
+
color: #000000;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
.c2 {
|
|
@@ -166,7 +166,7 @@ it('renders with responsive max widths correctly', () => {
|
|
|
166
166
|
-webkit-flex-direction: column;
|
|
167
167
|
-ms-flex-direction: column;
|
|
168
168
|
flex-direction: column;
|
|
169
|
-
color: #
|
|
169
|
+
color: #000000;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
.c2 {
|
|
@@ -6,14 +6,11 @@ import Text from '../Text/Text';
|
|
|
6
6
|
import spacing from '../../../theme/shared/spacing';
|
|
7
7
|
import hideVisually from '../../../theme/shared/hideVisually';
|
|
8
8
|
|
|
9
|
-
const getLabelColor = ({ theme, errorMsg
|
|
9
|
+
const getLabelColor = ({ theme, errorMsg }) => {
|
|
10
10
|
if (errorMsg) {
|
|
11
11
|
return theme.color('red');
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
return theme.color('black');
|
|
15
|
-
}
|
|
16
|
-
return theme.color('grey_label');
|
|
13
|
+
return theme.color('black');
|
|
17
14
|
};
|
|
18
15
|
|
|
19
16
|
const LabelElement = styled.label`
|
|
@@ -55,7 +52,6 @@ const LabelText = ({
|
|
|
55
52
|
* @param children
|
|
56
53
|
* @param label
|
|
57
54
|
* @param hideLabel - Visually hide the label text (without removing it from the document)
|
|
58
|
-
* @param darkLabel - Make the label text black rather than the default grey
|
|
59
55
|
* @param rest
|
|
60
56
|
* @returns {JSX.Element}
|
|
61
57
|
* @constructor
|
|
@@ -64,7 +60,6 @@ const Label = ({
|
|
|
64
60
|
children = null,
|
|
65
61
|
label,
|
|
66
62
|
hideLabel = false,
|
|
67
|
-
darkLabel = false,
|
|
68
63
|
optional = null,
|
|
69
64
|
errorMsg = '',
|
|
70
65
|
...rest
|
|
@@ -72,7 +67,6 @@ const Label = ({
|
|
|
72
67
|
<LabelElement
|
|
73
68
|
optional={optional}
|
|
74
69
|
errorMsg={errorMsg}
|
|
75
|
-
darkLabel={darkLabel}
|
|
76
70
|
{...rest}
|
|
77
71
|
>
|
|
78
72
|
<LabelText
|
|
@@ -91,14 +85,12 @@ Label.propTypes = {
|
|
|
91
85
|
hideLabel: PropTypes.bool,
|
|
92
86
|
children: PropTypes.node,
|
|
93
87
|
optional: PropTypes.bool,
|
|
94
|
-
errorMsg: PropTypes.string
|
|
95
|
-
darkLabel: PropTypes.bool
|
|
88
|
+
errorMsg: PropTypes.string
|
|
96
89
|
};
|
|
97
90
|
|
|
98
91
|
LabelElement.propTypes = {
|
|
99
92
|
optional: PropTypes.bool,
|
|
100
|
-
errorMsg: PropTypes.string
|
|
101
|
-
darkLabel: PropTypes.bool
|
|
93
|
+
errorMsg: PropTypes.string
|
|
102
94
|
};
|
|
103
95
|
|
|
104
96
|
LabelText.propTypes = {
|
|
@@ -19,8 +19,9 @@ const StyledSelect = styled.select`
|
|
|
19
19
|
height: 48px;
|
|
20
20
|
font-weight: 400;
|
|
21
21
|
font-family: ${({ theme }) => theme.fontFamilies(theme.font.regular)};
|
|
22
|
-
background: ${({ theme }) =>
|
|
23
|
-
|
|
22
|
+
background: ${({ theme, hideArrow }) => (hideArrow
|
|
23
|
+
? theme.color('grey_light')
|
|
24
|
+
: `${theme.color('grey_light')} url(${dropDownIcon}) calc(100% - 1.5rem) 14px/20px 1.5rem no-repeat`)};
|
|
24
25
|
border: 1px solid;
|
|
25
26
|
border-color: ${({ theme, error }) => (error ? theme.color('red') : theme.color('grey_medium'))};
|
|
26
27
|
box-shadow: none;
|
|
@@ -50,11 +51,13 @@ const Select = React.forwardRef(
|
|
|
50
51
|
greyDescription = false,
|
|
51
52
|
className = '',
|
|
52
53
|
optional = false,
|
|
54
|
+
hideArrow = false,
|
|
53
55
|
...rest
|
|
54
56
|
},
|
|
55
57
|
ref
|
|
56
58
|
) => {
|
|
57
|
-
const [value
|
|
59
|
+
const initialValue = hideArrow ? options[0].value : defaultValue;
|
|
60
|
+
const [value, setValue] = useState(initialValue);
|
|
58
61
|
|
|
59
62
|
return (
|
|
60
63
|
<Label
|
|
@@ -78,10 +81,16 @@ const Select = React.forwardRef(
|
|
|
78
81
|
hasValue={!!value}
|
|
79
82
|
greyDescription={greyDescription}
|
|
80
83
|
ref={ref}
|
|
84
|
+
hideArrow={hideArrow}
|
|
81
85
|
>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
|
|
87
|
+
{/* empty string "" is falsy so will show */
|
|
88
|
+
!initialValue && (
|
|
89
|
+
<option disabled value="">
|
|
90
|
+
{description}
|
|
91
|
+
</option>
|
|
92
|
+
)}
|
|
93
|
+
|
|
85
94
|
{options.map(option => (
|
|
86
95
|
<option key={option.value} value={option.value}>
|
|
87
96
|
{option.displayValue}
|
|
@@ -111,7 +120,8 @@ Select.propTypes = {
|
|
|
111
120
|
// className is needed so that styled(`Select`) will work
|
|
112
121
|
// (as `rest` is not spread on the outermost component)
|
|
113
122
|
className: PropTypes.string,
|
|
114
|
-
optional: PropTypes.bool
|
|
123
|
+
optional: PropTypes.bool,
|
|
124
|
+
hideArrow: PropTypes.bool
|
|
115
125
|
};
|
|
116
126
|
|
|
117
127
|
export default Select;
|
|
@@ -32,4 +32,16 @@
|
|
|
32
32
|
{ value: 'Option four', displayValue: 'The fourth option' }
|
|
33
33
|
]}
|
|
34
34
|
/>
|
|
35
|
+
|
|
36
|
+
<h4>DROPDOWN MENU - hide arrow / just one option</h4>
|
|
37
|
+
<Select
|
|
38
|
+
label="Label"
|
|
39
|
+
errorMsg="This is an error message"
|
|
40
|
+
description="Select an option"
|
|
41
|
+
greyDescription
|
|
42
|
+
hideArrow={true}
|
|
43
|
+
options={[
|
|
44
|
+
{ value: 'Option one', displayValue: 'The first option' }
|
|
45
|
+
]}
|
|
46
|
+
/>
|
|
35
47
|
```
|
package/src/components/Atoms/TextInputWithDropdown/__snapshots__/TextInputWithDropdown.test.js.snap
CHANGED
|
@@ -19,7 +19,7 @@ exports[`renders correctly with no value and no options 1`] = `
|
|
|
19
19
|
-webkit-flex-direction: column;
|
|
20
20
|
-ms-flex-direction: column;
|
|
21
21
|
flex-direction: column;
|
|
22
|
-
color: #
|
|
22
|
+
color: #000000;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
.c3 {
|
|
@@ -149,7 +149,7 @@ exports[`renders correctly with value and no options 1`] = `
|
|
|
149
149
|
-webkit-flex-direction: column;
|
|
150
150
|
-ms-flex-direction: column;
|
|
151
151
|
flex-direction: column;
|
|
152
|
-
color: #
|
|
152
|
+
color: #000000;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
.c3 {
|
|
@@ -279,7 +279,7 @@ exports[`renders correctly with value and options 1`] = `
|
|
|
279
279
|
-webkit-flex-direction: column;
|
|
280
280
|
-ms-flex-direction: column;
|
|
281
281
|
flex-direction: column;
|
|
282
|
-
color: #
|
|
282
|
+
color: #000000;
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
.c3 {
|
|
@@ -51,7 +51,7 @@ exports[`"Single Giving, No Money Buys, with overridden manual input value" rend
|
|
|
51
51
|
-webkit-flex-direction: column;
|
|
52
52
|
-ms-flex-direction: column;
|
|
53
53
|
flex-direction: column;
|
|
54
|
-
color: #
|
|
54
|
+
color: #000000;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
.c21 {
|
|
@@ -750,7 +750,7 @@ exports[`Monthly donation renders correctly 1`] = `
|
|
|
750
750
|
-webkit-flex-direction: column;
|
|
751
751
|
-ms-flex-direction: column;
|
|
752
752
|
flex-direction: column;
|
|
753
|
-
color: #
|
|
753
|
+
color: #000000;
|
|
754
754
|
}
|
|
755
755
|
|
|
756
756
|
.c22 {
|
|
@@ -1416,7 +1416,7 @@ exports[`Single donation renders correctly 1`] = `
|
|
|
1416
1416
|
-webkit-flex-direction: column;
|
|
1417
1417
|
-ms-flex-direction: column;
|
|
1418
1418
|
flex-direction: column;
|
|
1419
|
-
color: #
|
|
1419
|
+
color: #000000;
|
|
1420
1420
|
}
|
|
1421
1421
|
|
|
1422
1422
|
.c15 {
|
|
@@ -2168,7 +2168,7 @@ exports[`Single donation with no Money Buys renders correctly 1`] = `
|
|
|
2168
2168
|
-webkit-flex-direction: column;
|
|
2169
2169
|
-ms-flex-direction: column;
|
|
2170
2170
|
flex-direction: column;
|
|
2171
|
-
color: #
|
|
2171
|
+
color: #000000;
|
|
2172
2172
|
}
|
|
2173
2173
|
|
|
2174
2174
|
.c15 {
|