@comicrelief/component-library 6.0.0 → 6.1.2

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.
@@ -26,7 +26,7 @@ var StyledCheckboxInput = _styledComponents.default.input.attrs({
26
26
  }).withConfig({
27
27
  displayName: "Checkbox__StyledCheckboxInput",
28
28
  componentId: "sc-ngak0-0"
29
- })(["font-size:", ";display:block;box-sizing:border-box;opacity:0;position:absolute;left:0px;width:24px;height:24px;margin:0;border:1px solid ", ";+ span{margin-right:12px;width:24px;height:24px;border-radius:4px;background-color:", ";border:1px solid ", ";float:left;}:checked + span{background:url(", ") no-repeat center;background-color:", ";border-color:", ";background-size:contain;}:focus + span{border-color:", ";border-width:1px;}"], function (_ref) {
29
+ })(["font-size:", ";display:block;box-sizing:border-box;opacity:0;position:absolute;left:0px;width:24px;height:24px;margin:0;border:1px solid ", ";+ span{margin-right:12px;width:24px;height:24px;border-radius:4px;background-color:", ";border:1px solid ", ";float:left;flex-shrink:0;}:checked + span{background:url(", ") no-repeat center;background-color:", ";border-color:", ";background-size:contain;}:focus + span{border-color:", ";border-width:1px;}"], function (_ref) {
30
30
  var theme = _ref.theme;
31
31
  return theme.fontSize('sm');
32
32
  }, function (_ref2) {
@@ -20,5 +20,5 @@ it('renders correctly', function () {
20
20
  value: "Handball",
21
21
  label: "Handball"
22
22
  }))).toJSON();
23
- expect(tree).toMatchInlineSnapshot("\n Array [\n .c2 {\n font-size: 1rem;\n line-height: 1rem;\n text-transform: inherit;\n font-weight: bold;\n line-height: normal;\n font-family: 'Montserrat',Helvetica,Arial,sans-serif;\n }\n\n .c1 {\n display: block;\n box-sizing: border-box;\n opacity: 0;\n position: absolute;\n left: 0px;\n width: 24px;\n height: 24px;\n margin: 0;\n border: 1px solid #969598;\n }\n\n .c1 + span {\n margin-right: 12px;\n width: 24px;\n height: 24px;\n border-radius: 4px;\n background-color: #FFFFFF;\n border: 1px solid #969598;\n float: left;\n }\n\n .c1:checked + span {\n background: url(mock.asset) no-repeat center;\n background-color: #E52630;\n border-color: #E52630;\n background-size: contain;\n }\n\n .c1:focus + span {\n border-color: #E52630;\n border-width: 1px;\n }\n\n .c0 {\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-align-items: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n margin-bottom: 8px;\n }\n\n <label\n className=\"c0\"\n >\n <input\n className=\"c1\"\n name=\"sport\"\n type=\"checkbox\"\n value=\"Tenis\"\n />\n <span />\n <span\n className=\"c2\"\n color=\"inherit\"\n size=\"s\"\n >\n Tenis\n </span>\n </label>,\n .c2 {\n font-size: 1rem;\n line-height: 1rem;\n text-transform: inherit;\n font-weight: bold;\n line-height: normal;\n font-family: 'Montserrat',Helvetica,Arial,sans-serif;\n }\n\n .c1 {\n display: block;\n box-sizing: border-box;\n opacity: 0;\n position: absolute;\n left: 0px;\n width: 24px;\n height: 24px;\n margin: 0;\n border: 1px solid #969598;\n }\n\n .c1 + span {\n margin-right: 12px;\n width: 24px;\n height: 24px;\n border-radius: 4px;\n background-color: #FFFFFF;\n border: 1px solid #969598;\n float: left;\n }\n\n .c1:checked + span {\n background: url(mock.asset) no-repeat center;\n background-color: #E52630;\n border-color: #E52630;\n background-size: contain;\n }\n\n .c1:focus + span {\n border-color: #E52630;\n border-width: 1px;\n }\n\n .c0 {\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-align-items: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n margin-bottom: 8px;\n }\n\n <label\n className=\"c0\"\n >\n <input\n className=\"c1\"\n name=\"sport\"\n type=\"checkbox\"\n value=\"Handball\"\n />\n <span />\n <span\n className=\"c2\"\n color=\"inherit\"\n size=\"s\"\n >\n Handball\n </span>\n </label>,\n ]\n ");
23
+ expect(tree).toMatchInlineSnapshot("\n Array [\n .c2 {\n font-size: 1rem;\n line-height: 1rem;\n text-transform: inherit;\n font-weight: bold;\n line-height: normal;\n font-family: 'Montserrat',Helvetica,Arial,sans-serif;\n }\n\n .c1 {\n display: block;\n box-sizing: border-box;\n opacity: 0;\n position: absolute;\n left: 0px;\n width: 24px;\n height: 24px;\n margin: 0;\n border: 1px solid #969598;\n }\n\n .c1 + span {\n margin-right: 12px;\n width: 24px;\n height: 24px;\n border-radius: 4px;\n background-color: #FFFFFF;\n border: 1px solid #969598;\n float: left;\n -webkit-flex-shrink: 0;\n -ms-flex-negative: 0;\n flex-shrink: 0;\n }\n\n .c1:checked + span {\n background: url(mock.asset) no-repeat center;\n background-color: #E52630;\n border-color: #E52630;\n background-size: contain;\n }\n\n .c1:focus + span {\n border-color: #E52630;\n border-width: 1px;\n }\n\n .c0 {\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-align-items: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n margin-bottom: 8px;\n }\n\n <label\n className=\"c0\"\n >\n <input\n className=\"c1\"\n name=\"sport\"\n type=\"checkbox\"\n value=\"Tenis\"\n />\n <span />\n <span\n className=\"c2\"\n color=\"inherit\"\n size=\"s\"\n >\n Tenis\n </span>\n </label>,\n .c2 {\n font-size: 1rem;\n line-height: 1rem;\n text-transform: inherit;\n font-weight: bold;\n line-height: normal;\n font-family: 'Montserrat',Helvetica,Arial,sans-serif;\n }\n\n .c1 {\n display: block;\n box-sizing: border-box;\n opacity: 0;\n position: absolute;\n left: 0px;\n width: 24px;\n height: 24px;\n margin: 0;\n border: 1px solid #969598;\n }\n\n .c1 + span {\n margin-right: 12px;\n width: 24px;\n height: 24px;\n border-radius: 4px;\n background-color: #FFFFFF;\n border: 1px solid #969598;\n float: left;\n -webkit-flex-shrink: 0;\n -ms-flex-negative: 0;\n flex-shrink: 0;\n }\n\n .c1:checked + span {\n background: url(mock.asset) no-repeat center;\n background-color: #E52630;\n border-color: #E52630;\n background-size: contain;\n }\n\n .c1:focus + span {\n border-color: #E52630;\n border-width: 1px;\n }\n\n .c0 {\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-align-items: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n margin-bottom: 8px;\n }\n\n <label\n className=\"c0\"\n >\n <input\n className=\"c1\"\n name=\"sport\"\n type=\"checkbox\"\n value=\"Handball\"\n />\n <span />\n <span\n className=\"c2\"\n color=\"inherit\"\n size=\"s\"\n >\n Handball\n </span>\n </label>,\n ]\n ");
24
24
  });
@@ -21,8 +21,6 @@ var _srLogo = _interopRequireDefault(require("./assets/sr-logo.svg"));
21
21
 
22
22
  var _srGameonLogo = _interopRequireDefault(require("./assets/sr-gameon-logo.svg"));
23
23
 
24
- var _bigNightLogo = _interopRequireDefault(require("./assets/big-night-logo.png"));
25
-
26
24
  var Image = _styledComponents.default.img.withConfig({
27
25
  displayName: "Logo__Image",
28
26
  componentId: "sc-18yiye8-0"
@@ -54,9 +52,6 @@ var themeSwitcher = function themeSwitcher(theme) {
54
52
  case 'Sport Relief Gameon':
55
53
  return _srGameonLogo.default;
56
54
 
57
- case 'Big Night In':
58
- return _bigNightLogo.default;
59
-
60
55
  default:
61
56
  return _crLogo.default;
62
57
  }
@@ -23,7 +23,7 @@ var _dropDownDarkPurple = _interopRequireDefault(require("./assets/drop-down-dar
23
23
 
24
24
  var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
25
25
 
26
- var _excluded = ["errorMsg", "description", "label", "options", "hideLabel", "defaultValue", "onChange", "greyDescription", "className"];
26
+ var _excluded = ["errorMsg", "description", "label", "options", "hideLabel", "defaultValue", "onChange", "greyDescription", "className", "optional"];
27
27
 
28
28
  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); }
29
29
 
@@ -68,6 +68,7 @@ var Select = /*#__PURE__*/_react.default.forwardRef(function (_ref8, ref) {
68
68
  _onChange = _ref8.onChange,
69
69
  greyDescription = _ref8.greyDescription,
70
70
  className = _ref8.className,
71
+ optional = _ref8.optional,
71
72
  rest = (0, _objectWithoutProperties2.default)(_ref8, _excluded);
72
73
 
73
74
  var _useState = (0, _react.useState)(''),
@@ -79,7 +80,8 @@ var Select = /*#__PURE__*/_react.default.forwardRef(function (_ref8, ref) {
79
80
  label: label,
80
81
  hideLabel: hideLabel,
81
82
  errorMsg: errorMsg,
82
- className: className
83
+ className: className,
84
+ optional: optional
83
85
  }, /*#__PURE__*/_react.default.createElement(StyledSelect, Object.assign({
84
86
  onChange: function onChange(e) {
85
87
  setValue(e.currentTarget.value);
@@ -91,6 +93,7 @@ var Select = /*#__PURE__*/_react.default.forwardRef(function (_ref8, ref) {
91
93
  }, rest, {
92
94
  error: errorMsg,
93
95
  defaultValue: defaultValue,
96
+ required: optional === false,
94
97
  hasValue: !!value,
95
98
  greyDescription: greyDescription,
96
99
  ref: ref
@@ -117,7 +120,8 @@ Select.defaultProps = {
117
120
  /** If true, the 'description' option, which is initially selected but disabled, will be grey
118
121
  * - like a text input's placeholder */
119
122
  greyDescription: false,
120
- className: ''
123
+ className: '',
124
+ optional: false
121
125
  };
122
126
  var _default = Select;
123
127
  exports.default = _default;
@@ -78,6 +78,7 @@ exports[`renders correctly 1`] = `
78
78
  className="c3"
79
79
  defaultValue=""
80
80
  onChange={[Function]}
81
+ required={true}
81
82
  >
82
83
  <option
83
84
  disabled={true}
@@ -33,26 +33,6 @@ var Logos = function Logos(_ref) {
33
33
  })));
34
34
  }
35
35
 
36
- if (campaign === 'Big Night In') {
37
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("a", {
38
- href: "/",
39
- title: "Go to Comic Relief homepage"
40
- }, /*#__PURE__*/_react.default.createElement(_Logo.default, {
41
- rotate: true,
42
- sizeSm: "50px",
43
- sizeMd: "60px",
44
- campaign: "Comic Relief"
45
- })), /*#__PURE__*/_react.default.createElement("a", {
46
- href: "/big-night-in",
47
- title: "Big night in homepage"
48
- }, /*#__PURE__*/_react.default.createElement(_Logo.default, {
49
- rotate: false,
50
- sizeSm: "100px",
51
- sizeMd: "200px",
52
- campaign: "Big Night In"
53
- })));
54
- }
55
-
56
36
  if (campaign === 'Sport Relief') {
57
37
  return /*#__PURE__*/_react.default.createElement("a", {
58
38
  href: "/sportrelief",
@@ -67,7 +47,7 @@ var Logos = function Logos(_ref) {
67
47
  href: "/",
68
48
  title: "Go to Comic Relief homepage"
69
49
  }, /*#__PURE__*/_react.default.createElement(_Logo.default, {
70
- rotate: true,
50
+ rotate: false,
71
51
  campaign: "Comic Relief"
72
52
  }));
73
53
  };
@@ -231,6 +231,7 @@ exports[`renders ESU School correctly 1`] = `
231
231
  defaultValue=""
232
232
  onChange={[Function]}
233
233
  placeholder="Please choose an option"
234
+ required={true}
234
235
  value=""
235
236
  >
236
237
  <option
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@comicrelief/component-library",
3
3
  "author": "Comic Relief Engineering Team",
4
- "version": "6.0.0",
4
+ "version": "6.1.2",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -24,6 +24,7 @@ const StyledCheckboxInput = styled.input.attrs({ type: 'checkbox' })`
24
24
  background-color: ${({ theme }) => theme.color('white')};
25
25
  border: 1px solid ${({ theme }) => theme.color('grey')};
26
26
  float: left;
27
+ flex-shrink: 0;
27
28
  }
28
29
  :checked + span {
29
30
  background: url(${checkBoxIcon}) no-repeat center;
@@ -42,6 +42,9 @@ it('renders correctly', () => {
42
42
  background-color: #FFFFFF;
43
43
  border: 1px solid #969598;
44
44
  float: left;
45
+ -webkit-flex-shrink: 0;
46
+ -ms-flex-negative: 0;
47
+ flex-shrink: 0;
45
48
  }
46
49
 
47
50
  .c1:checked + span {
@@ -115,6 +118,9 @@ it('renders correctly', () => {
115
118
  background-color: #FFFFFF;
116
119
  border: 1px solid #969598;
117
120
  float: left;
121
+ -webkit-flex-shrink: 0;
122
+ -ms-flex-negative: 0;
123
+ flex-shrink: 0;
118
124
  }
119
125
 
120
126
  .c1:checked + span {
@@ -7,7 +7,6 @@ import spacing from '../../../theme/shared/spacing';
7
7
  import crLogo from './assets/cr-logo.svg';
8
8
  import srLogo from './assets/sr-logo.svg';
9
9
  import srLogoGameOn from './assets/sr-gameon-logo.svg';
10
- import bigNiht from './assets/big-night-logo.png';
11
10
 
12
11
  const Image = styled.img`
13
12
  object-fit: cover;
@@ -37,8 +36,6 @@ const themeSwitcher = theme => {
37
36
  return srLogo;
38
37
  case 'Sport Relief Gameon':
39
38
  return srLogoGameOn;
40
- case 'Big Night In':
41
- return bigNiht;
42
39
  default:
43
40
  return crLogo;
44
41
  }
@@ -49,6 +49,7 @@ const Select = React.forwardRef(
49
49
  onChange,
50
50
  greyDescription,
51
51
  className,
52
+ optional,
52
53
  ...rest
53
54
  },
54
55
  ref
@@ -56,7 +57,13 @@ const Select = React.forwardRef(
56
57
  const [value, setValue] = useState('');
57
58
 
58
59
  return (
59
- <Label label={label} hideLabel={hideLabel} errorMsg={errorMsg} className={className}>
60
+ <Label
61
+ label={label}
62
+ hideLabel={hideLabel}
63
+ errorMsg={errorMsg}
64
+ className={className}
65
+ optional={optional}
66
+ >
60
67
  <StyledSelect
61
68
  onChange={e => {
62
69
  setValue(e.currentTarget.value);
@@ -67,6 +74,7 @@ const Select = React.forwardRef(
67
74
  {...rest}
68
75
  error={errorMsg}
69
76
  defaultValue={defaultValue}
77
+ required={optional === false}
70
78
  hasValue={!!value}
71
79
  greyDescription={greyDescription}
72
80
  ref={ref}
@@ -102,7 +110,8 @@ Select.propTypes = {
102
110
  greyDescription: PropTypes.bool,
103
111
  // className is needed so that styled(`Select`) will work
104
112
  // (as `rest` is not spread on the outermost component)
105
- className: PropTypes.string
113
+ className: PropTypes.string,
114
+ optional: PropTypes.bool
106
115
  };
107
116
 
108
117
  Select.defaultProps = {
@@ -112,7 +121,8 @@ Select.defaultProps = {
112
121
  /** If true, the 'description' option, which is initially selected but disabled, will be grey
113
122
  * - like a text input's placeholder */
114
123
  greyDescription: false,
115
- className: ''
124
+ className: '',
125
+ optional: false
116
126
  };
117
127
 
118
128
  export default Select;
@@ -78,6 +78,7 @@ exports[`renders correctly 1`] = `
78
78
  className="c3"
79
79
  defaultValue=""
80
80
  onChange={[Function]}
81
+ required={true}
81
82
  >
82
83
  <option
83
84
  disabled={true}
@@ -17,24 +17,6 @@ const Logos = ({ campaign }) => {
17
17
  );
18
18
  }
19
19
 
20
- if (campaign === 'Big Night In') {
21
- return (
22
- <>
23
- <a href="/" title="Go to Comic Relief homepage">
24
- <Logo rotate sizeSm="50px" sizeMd="60px" campaign="Comic Relief" />
25
- </a>
26
- <a href="/big-night-in" title="Big night in homepage">
27
- <Logo
28
- rotate={false}
29
- sizeSm="100px"
30
- sizeMd="200px"
31
- campaign="Big Night In"
32
- />
33
- </a>
34
- </>
35
- );
36
- }
37
-
38
20
  if (campaign === 'Sport Relief') {
39
21
  return (
40
22
  <a href="/sportrelief" title="Sport Relief in homepage">
@@ -45,7 +27,7 @@ const Logos = ({ campaign }) => {
45
27
 
46
28
  return (
47
29
  <a href="/" title="Go to Comic Relief homepage">
48
- <Logo rotate campaign="Comic Relief" />
30
+ <Logo rotate={false} campaign="Comic Relief" />
49
31
  </a>
50
32
  );
51
33
  };
@@ -231,6 +231,7 @@ exports[`renders ESU School correctly 1`] = `
231
231
  defaultValue=""
232
232
  onChange={[Function]}
233
233
  placeholder="Please choose an option"
234
+ required={true}
234
235
  value=""
235
236
  >
236
237
  <option