@comicrelief/component-library 8.28.1 → 8.30.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.
@@ -119,3 +119,15 @@ const ItalicText = styled(Text).attrs({weight: 'normal'})`
119
119
  maxPxWidthLargeBreakpoint={250}
120
120
  />
121
121
  ```
122
+
123
+ ```js
124
+ <h4>Input with dark label</h4>
125
+ <Input
126
+ name="dark-label"
127
+ placeholder="£0.00"
128
+ type="text"
129
+ label="The label text can be made black rather than the default grey"
130
+ id="input-example-8"
131
+ labelProps={{ darkLabel: true }}
132
+ />
133
+ ```
@@ -11,16 +11,24 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
11
11
  var _Text = _interopRequireDefault(require("../Text/Text"));
12
12
  var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
13
13
  var _hideVisually = _interopRequireDefault(require("../../../theme/shared/hideVisually"));
14
- const LabelElement = _styledComponents.default.label.withConfig({
15
- displayName: "Label__LabelElement",
16
- componentId: "sc-2nrw50-0"
17
- })(["width:100%;position:relative;display:flex;flex-direction:column;color:", ";", ""], _ref => {
14
+ const getLabelColor = _ref => {
18
15
  let {
19
16
  theme,
20
- errorMsg
17
+ errorMsg,
18
+ darkLabel
21
19
  } = _ref;
22
- return errorMsg ? theme.color('red') : theme.color('grey_label');
23
- }, _ref2 => {
20
+ if (errorMsg) {
21
+ return theme.color('red');
22
+ }
23
+ if (darkLabel) {
24
+ return theme.color('black');
25
+ }
26
+ return theme.color('grey_label');
27
+ };
28
+ const LabelElement = _styledComponents.default.label.withConfig({
29
+ displayName: "Label__LabelElement",
30
+ componentId: "sc-2nrw50-0"
31
+ })(["width:100%;position:relative;display:flex;flex-direction:column;color:", ";", ""], getLabelColor, _ref2 => {
24
32
  let {
25
33
  optional,
26
34
  theme
@@ -63,6 +71,7 @@ const LabelText = _ref3 => {
63
71
  * @param children
64
72
  * @param label
65
73
  * @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
66
75
  * @param rest
67
76
  * @returns {JSX.Element}
68
77
  * @constructor
@@ -72,13 +81,15 @@ const Label = _ref4 => {
72
81
  children = null,
73
82
  label,
74
83
  hideLabel = false,
84
+ darkLabel = false,
75
85
  optional = null,
76
86
  errorMsg = '',
77
87
  ...rest
78
88
  } = _ref4;
79
89
  return /*#__PURE__*/_react.default.createElement(LabelElement, Object.assign({
80
90
  optional: optional,
81
- errorMsg: errorMsg
91
+ errorMsg: errorMsg,
92
+ darkLabel: darkLabel
82
93
  }, rest), /*#__PURE__*/_react.default.createElement(LabelText, {
83
94
  label: label,
84
95
  hideLabel: hideLabel
@@ -86,6 +97,7 @@ const Label = _ref4 => {
86
97
  };
87
98
  LabelElement.propTypes = {
88
99
  optional: _propTypes.default.bool,
89
- errorMsg: _propTypes.default.string
100
+ errorMsg: _propTypes.default.string,
101
+ darkLabel: _propTypes.default.bool
90
102
  };
91
103
  var _default = exports.default = Label;
@@ -23,6 +23,7 @@ const Link = _ref => {
23
23
  underline = true,
24
24
  icon = null,
25
25
  iconFirst = false,
26
+ fullWidth = false,
26
27
  ...rest
27
28
  } = _ref;
28
29
  const [documentHost, setDocumentHost] = (0, _react.useState)('');
@@ -61,7 +62,8 @@ const Link = _ref => {
61
62
  type: type,
62
63
  home: home,
63
64
  iconFirst: iconFirst,
64
- underline: underline
65
+ underline: underline,
66
+ fullWidth: fullWidth
65
67
  }), children, window === '_blank' && /*#__PURE__*/_react.default.createElement(_Link.HelperText, null, "(opens in new window)"), hasIcon && /*#__PURE__*/_react.default.createElement(_Link.IconWrapper, {
66
68
  type: type
67
69
  }, icon));
@@ -210,6 +210,11 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
210
210
  White button
211
211
  </Link>
212
212
  </div>
213
+ <div style={{ display: 'block', marginTop: '10px' }}>
214
+ <Link color="red" href="/test" target="blank" type="button" fullWidth>
215
+ Full-width red button
216
+ </Link>
217
+ </div>
213
218
  </div>
214
219
  </div>
215
220
  ```
@@ -9,7 +9,7 @@ exports.default = exports.IconWrapper = exports.HelperText = void 0;
9
9
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
10
10
  var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
11
11
  var _hideVisually = _interopRequireDefault(require("../../../theme/shared/hideVisually"));
12
- const buttonStyle = () => (0, _styledComponents.css)(["display:inline-flex;position:relative;padding:0.5rem 1.25rem;text-decoration:none;font-weight:700;font-size:", ";border-radius:2rem;transition:all 0.3s;height:3.125rem;width:100%;justify-content:center;align-items:center;cursor:pointer;", ";", ";@media ", "{width:auto;}@media ", "{", ";}"], _ref => {
12
+ const buttonStyle = () => (0, _styledComponents.css)(["display:inline-flex;position:relative;padding:0.5rem 1.25rem;text-decoration:none;font-weight:700;font-size:", ";border-radius:2rem;transition:all 0.3s;height:3.125rem;width:100%;justify-content:center;align-items:center;cursor:pointer;", ";", ";@media ", "{width:", ";}@media ", "{", ";}"], _ref => {
13
13
  let {
14
14
  theme
15
15
  } = _ref;
@@ -33,55 +33,60 @@ const buttonStyle = () => (0, _styledComponents.css)(["display:inline-flex;posit
33
33
  return theme.allBreakpoints('M');
34
34
  }, _ref5 => {
35
35
  let {
36
- theme
36
+ fullWidth
37
37
  } = _ref5;
38
- return theme.allBreakpoints('L');
38
+ return fullWidth ? '100%' : 'auto';
39
39
  }, _ref6 => {
40
40
  let {
41
- color,
42
41
  theme
43
42
  } = _ref6;
43
+ return theme.allBreakpoints('L');
44
+ }, _ref7 => {
45
+ let {
46
+ color,
47
+ theme
48
+ } = _ref7;
44
49
  return color ? theme.buttonColors(color) : theme.buttonColors('red');
45
50
  });
46
- const linkStyle = () => (0, _styledComponents.css)(["position:relative;text-decoration:none;display:inline;line-height:", ";", ";"], _ref7 => {
51
+ const linkStyle = () => (0, _styledComponents.css)(["position:relative;text-decoration:none;display:inline;line-height:", ";", ";"], _ref8 => {
47
52
  let {
48
53
  theme
49
- } = _ref7;
54
+ } = _ref8;
50
55
  return theme.fontSize('l');
51
- }, _ref8 => {
56
+ }, _ref9 => {
52
57
  let {
53
58
  type,
54
59
  theme,
55
60
  underline
56
- } = _ref8;
61
+ } = _ref9;
57
62
  return type ? theme.linkStyles(type, underline) : theme.linkStyles('standard', underline);
58
63
  });
59
64
  const IconWrapper = exports.IconWrapper = _styledComponents.default.span.withConfig({
60
65
  displayName: "Linkstyle__IconWrapper",
61
66
  componentId: "sc-t360tr-0"
62
- })(["display:inline-flex;margin-left:", ";align-self:center;right:", ";", ";@media ", "{width:auto;right:auto;position:relative;", ";}"], (0, _spacing.default)('md'), (0, _spacing.default)('m'), _ref9 => {
67
+ })(["display:inline-flex;margin-left:", ";align-self:center;right:", ";", ";@media ", "{width:auto;right:auto;position:relative;", ";}"], (0, _spacing.default)('md'), (0, _spacing.default)('m'), _ref10 => {
63
68
  let {
64
69
  type
65
- } = _ref9;
70
+ } = _ref10;
66
71
  return type === 'standard' && (0, _styledComponents.css)(["position:absolute;right:-2rem;top:0;bottom:0;"]);
67
- }, _ref10 => {
72
+ }, _ref11 => {
68
73
  let {
69
74
  theme
70
- } = _ref10;
75
+ } = _ref11;
71
76
  return theme.allBreakpoints('M');
72
- }, _ref11 => {
77
+ }, _ref12 => {
73
78
  let {
74
79
  type
75
- } = _ref11;
80
+ } = _ref12;
76
81
  return type === 'standard' && (0, _styledComponents.css)(["position:absolute;right:-2rem;top:0;bottom:0;"]);
77
82
  });
78
83
  const StyledLink = _styledComponents.default.a.withConfig({
79
84
  displayName: "Linkstyle__StyledLink",
80
85
  componentId: "sc-t360tr-1"
81
- })(["", " ", ";"], props => props.type === 'button' ? buttonStyle : linkStyle, _ref12 => {
86
+ })(["", " ", ";"], props => props.type === 'button' ? buttonStyle : linkStyle, _ref13 => {
82
87
  let {
83
88
  iconFirst
84
- } = _ref12;
89
+ } = _ref13;
85
90
  return iconFirst && (0, _styledComponents.css)(["flex-direction:row-reverse;span[type=\"button\"]{margin-left:0;margin-right:1rem;}"]);
86
91
  });
87
92
  const HelperText = exports.HelperText = _styledComponents.default.span.withConfig({
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": "8.28.1",
4
+ "version": "8.30.0",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -119,3 +119,15 @@ const ItalicText = styled(Text).attrs({weight: 'normal'})`
119
119
  maxPxWidthLargeBreakpoint={250}
120
120
  />
121
121
  ```
122
+
123
+ ```js
124
+ <h4>Input with dark label</h4>
125
+ <Input
126
+ name="dark-label"
127
+ placeholder="£0.00"
128
+ type="text"
129
+ label="The label text can be made black rather than the default grey"
130
+ id="input-example-8"
131
+ labelProps={{ darkLabel: true }}
132
+ />
133
+ ```
@@ -6,12 +6,22 @@ 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, darkLabel }) => {
10
+ if (errorMsg) {
11
+ return theme.color('red');
12
+ }
13
+ if (darkLabel) {
14
+ return theme.color('black');
15
+ }
16
+ return theme.color('grey_label');
17
+ };
18
+
9
19
  const LabelElement = styled.label`
10
20
  width: 100%;
11
21
  position: relative;
12
22
  display: flex;
13
23
  flex-direction: column;
14
- color: ${({ theme, errorMsg }) => (errorMsg ? theme.color('red') : theme.color('grey_label'))};
24
+ color: ${getLabelColor};
15
25
 
16
26
  ${({ optional, theme }) => optional === true && `
17
27
  :after {
@@ -45,6 +55,7 @@ const LabelText = ({
45
55
  * @param children
46
56
  * @param label
47
57
  * @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
48
59
  * @param rest
49
60
  * @returns {JSX.Element}
50
61
  * @constructor
@@ -53,6 +64,7 @@ const Label = ({
53
64
  children = null,
54
65
  label,
55
66
  hideLabel = false,
67
+ darkLabel = false,
56
68
  optional = null,
57
69
  errorMsg = '',
58
70
  ...rest
@@ -60,6 +72,7 @@ const Label = ({
60
72
  <LabelElement
61
73
  optional={optional}
62
74
  errorMsg={errorMsg}
75
+ darkLabel={darkLabel}
63
76
  {...rest}
64
77
  >
65
78
  <LabelText
@@ -78,12 +91,14 @@ Label.propTypes = {
78
91
  hideLabel: PropTypes.bool,
79
92
  children: PropTypes.node,
80
93
  optional: PropTypes.bool,
81
- errorMsg: PropTypes.string
94
+ errorMsg: PropTypes.string,
95
+ darkLabel: PropTypes.bool
82
96
  };
83
97
 
84
98
  LabelElement.propTypes = {
85
99
  optional: PropTypes.bool,
86
- errorMsg: PropTypes.string
100
+ errorMsg: PropTypes.string,
101
+ darkLabel: PropTypes.bool
87
102
  };
88
103
 
89
104
  LabelText.propTypes = {
@@ -18,6 +18,7 @@ const Link = ({
18
18
  underline = true,
19
19
  icon = null,
20
20
  iconFirst = false,
21
+ fullWidth = false,
21
22
  ...rest
22
23
  }) => {
23
24
  const [documentHost, setDocumentHost] = useState('');
@@ -62,6 +63,7 @@ const Link = ({
62
63
  home={home}
63
64
  iconFirst={iconFirst}
64
65
  underline={underline}
66
+ fullWidth={fullWidth}
65
67
  >
66
68
  {children}
67
69
  {window === '_blank' && <HelperText>(opens in new window)</HelperText>}
@@ -87,7 +89,8 @@ Link.propTypes = {
87
89
  children: PropTypes.node.isRequired,
88
90
  iconFirst: PropTypes.bool,
89
91
  /** Embed icons */
90
- icon: PropTypes.node
92
+ icon: PropTypes.node,
93
+ fullWidth: PropTypes.bool
91
94
  };
92
95
 
93
96
  export default Link;
@@ -210,6 +210,11 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
210
210
  White button
211
211
  </Link>
212
212
  </div>
213
+ <div style={{ display: 'block', marginTop: '10px' }}>
214
+ <Link color="red" href="/test" target="blank" type="button" fullWidth>
215
+ Full-width red button
216
+ </Link>
217
+ </div>
213
218
  </div>
214
219
  </div>
215
220
  ```
@@ -22,7 +22,7 @@ const buttonStyle = () => css`
22
22
  ${({ mobileColour, theme }) => (mobileColour ? theme.buttonColors(mobileColour) : null)};
23
23
 
24
24
  @media ${({ theme }) => theme.allBreakpoints('M')} {
25
- width: auto;
25
+ width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
26
26
  }
27
27
 
28
28
  // Reinstate general styles for 'desktop':