@comicrelief/component-library 8.7.0 → 8.8.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.
@@ -12,7 +12,7 @@ var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
12
12
  const StyledButton = _styledComponents.default.button.withConfig({
13
13
  displayName: "Button__StyledButton",
14
14
  componentId: "sc-1gm5vj0-0"
15
- })(["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;border:none;cursor:pointer;> a{text-decoration:none;}", ";@media ", "{width:auto;}@media ", "{width:auto;padding:", " ", ";margin:0 auto ", ";}"], _ref => {
15
+ })(["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;border:none;cursor:pointer;> a{text-decoration:none;}", ";@media ", "{width:", ";}@media ", "{width:", ";padding:", " ", ";margin:0 auto ", ";}"], _ref => {
16
16
  let {
17
17
  theme
18
18
  } = _ref;
@@ -30,23 +30,37 @@ const StyledButton = _styledComponents.default.button.withConfig({
30
30
  return theme.allBreakpoints('M');
31
31
  }, _ref4 => {
32
32
  let {
33
- theme
33
+ fullWidth
34
34
  } = _ref4;
35
+ return fullWidth ? '100%' : 'auto';
36
+ }, _ref5 => {
37
+ let {
38
+ theme
39
+ } = _ref5;
35
40
  return theme.allBreakpoints('L');
41
+ }, _ref6 => {
42
+ let {
43
+ fullWidth
44
+ } = _ref6;
45
+ return fullWidth ? '100%' : 'auto';
36
46
  }, (0, _spacing.default)('md'), (0, _spacing.default)('l'), (0, _spacing.default)('l'));
37
- const Button = /*#__PURE__*/_react.default.forwardRef((_ref5, ref) => {
47
+ const Button = /*#__PURE__*/_react.default.forwardRef((_ref7, ref) => {
38
48
  let {
39
49
  children,
40
50
  wrapper = false,
51
+ fullWidth = false,
41
52
  ...rest
42
- } = _ref5;
53
+ } = _ref7;
43
54
  return /*#__PURE__*/_react.default.createElement(StyledButton, Object.assign({}, rest, {
44
55
  as: wrapper ? 'span' : 'button',
45
- ref: ref
56
+ ref: ref,
57
+ fullWidth: fullWidth
46
58
  }), children);
47
59
  });
48
60
  Button.propTypes = {
49
61
  children: _propTypes.default.node.isRequired,
50
- wrapper: _propTypes.default.bool // Buttons as span
62
+ wrapper: _propTypes.default.bool,
63
+ // Buttons as span
64
+ fullWidth: _propTypes.default.bool
51
65
  };
52
66
  var _default = exports.default = Button;
@@ -5,3 +5,7 @@
5
5
  ```js
6
6
  <Button wrapper>My button as a span</Button>
7
7
  ```
8
+
9
+ ```js
10
+ <Button type="button" fullWidth>Full-width button</Button>
11
+ ```
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.7.0",
4
+ "version": "8.8.0",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -22,26 +22,30 @@ const StyledButton = styled.button`
22
22
  text-decoration: none;
23
23
  }
24
24
  ${({ color, theme }) => (color ? theme.buttonColors(color) : theme.buttonColors('red'))};
25
+
25
26
  @media ${({ theme }) => theme.allBreakpoints('M')} {
26
- width: auto;
27
+ width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
27
28
  }
28
29
 
29
30
  @media ${({ theme }) => theme.allBreakpoints('L')} {
30
- width: auto;
31
+ width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
31
32
  padding: ${spacing('md')} ${spacing('l')};
32
33
  margin: 0 auto ${spacing('l')};
33
34
  }
34
35
  `;
35
36
 
36
- const Button = React.forwardRef(({ children, wrapper = false, ...rest }, ref) => (
37
- <StyledButton {...rest} as={wrapper ? 'span' : 'button'} ref={ref}>
37
+ const Button = React.forwardRef(({
38
+ children, wrapper = false, fullWidth = false, ...rest
39
+ }, ref) => (
40
+ <StyledButton {...rest} as={wrapper ? 'span' : 'button'} ref={ref} fullWidth={fullWidth}>
38
41
  {children}
39
42
  </StyledButton>
40
43
  ));
41
44
 
42
45
  Button.propTypes = {
43
46
  children: PropTypes.node.isRequired,
44
- wrapper: PropTypes.bool // Buttons as span
47
+ wrapper: PropTypes.bool, // Buttons as span
48
+ fullWidth: PropTypes.bool
45
49
  };
46
50
 
47
51
  export default Button;
@@ -5,3 +5,7 @@
5
5
  ```js
6
6
  <Button wrapper>My button as a span</Button>
7
7
  ```
8
+
9
+ ```js
10
+ <Button type="button" fullWidth>Full-width button</Button>
11
+ ```