@comicrelief/component-library 8.28.1 → 8.29.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.
@@ -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.29.0",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -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':