@comicrelief/component-library 8.6.2 → 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
+ ```
@@ -43,19 +43,21 @@ const Copy = _styledComponents.default.div.withConfig({
43
43
  return theme.allBreakpoints('M');
44
44
  }, (0, _spacing.default)('lg'), _ref4 => {
45
45
  let {
46
- isOpen
46
+ isOpen,
47
+ contentBottomPadding
47
48
  } = _ref4;
48
- return isOpen && (0, _styledComponents.css)(["height:auto;visibility:visible;transition:all 0.2s cubic-bezier(0.21,1.7,0.83,0.68) 0s;padding:0 ", " ", ";@media ", "{padding:0 ", " ", ";}"], (0, _spacing.default)('l'), (0, _spacing.default)('l'), _ref5 => {
49
+ return isOpen && (0, _styledComponents.css)(["height:auto;visibility:visible;transition:all 0.2s cubic-bezier(0.21,1.7,0.83,0.68) 0s;padding:0 ", " ", ";@media ", "{padding:0 ", " ", ";}"], (0, _spacing.default)('lg'), contentBottomPadding || (0, _spacing.default)('l'), _ref5 => {
49
50
  let {
50
51
  theme
51
52
  } = _ref5;
52
53
  return theme.allBreakpoints('M');
53
- }, (0, _spacing.default)('lg'), (0, _spacing.default)('l'));
54
+ }, (0, _spacing.default)('lg'), contentBottomPadding || (0, _spacing.default)('l'));
54
55
  });
55
56
  const Accordion = _ref6 => {
56
57
  let {
57
58
  children,
58
59
  title,
60
+ contentBottomPadding,
59
61
  ...rest
60
62
  } = _ref6;
61
63
  const [isOpen, setIsOpen] = (0, _react.useState)(false);
@@ -71,7 +73,8 @@ const Accordion = _ref6 => {
71
73
  colour: "black",
72
74
  direction: isOpen ? 'up' : 'down'
73
75
  }))), /*#__PURE__*/_react.default.createElement(Copy, {
74
- isOpen: isOpen
76
+ isOpen: isOpen,
77
+ contentBottomPadding: contentBottomPadding
75
78
  }, children));
76
79
  };
77
80
  var _default = exports.default = Accordion;
@@ -13,3 +13,18 @@ import Text from '../../Atoms/Text/Text';
13
13
  <Text tag="p">Name, surname, email and billing address We need these to process your payment, create a receipt and send it to you. Establishment information We use this information to understand which institutions (e.g. schools, companies) raise money for us. Your details will be kept safe and never shared with other organisations; see our Privacy Policy for more information</Text>
14
14
  </Accordion>
15
15
  ```
16
+
17
+ ```js
18
+ import Text from '../../Atoms/Text/Text';
19
+
20
+ <Accordion
21
+ contentBottomPadding="15px"
22
+ title={
23
+ <Text family="Anton" size="l" uppercase>
24
+ I am the title
25
+ </Text>
26
+ }
27
+ >
28
+ <Text tag="p">Customised bottom padding here!</Text>
29
+ </Accordion>
30
+ ```
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.6.2",
4
+ "version": "8.8.0",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -2,18 +2,17 @@ const { test, expect } = require('@playwright/test');
2
2
 
3
3
  test.describe('accordian component', () => {
4
4
  test('accordian', async ({ page, context }) => {
5
-
6
5
  await page.goto('/#accordion');
7
6
 
8
7
  // accordian elements should be visible
9
8
  await expect(page.locator('[data-testid="Accordion-example-1"]')).toBeVisible();
10
- await expect(page.locator('[data-preview="Accordion"]')).toBeVisible();
9
+ await expect(page.locator('[data-testid="Accordion-example-1"] [data-preview="Accordion"]')).toBeVisible();
11
10
  // dropdown svg icon should be visible
12
- await expect(page.locator('[data-preview="Accordion"] svg')).toBeVisible();
11
+ await expect(page.locator('[data-testid="Accordion-example-1"] [data-preview="Accordion"] svg')).toBeVisible();
13
12
 
14
13
  // clicking the accordian should show the paragraph
15
- await page.locator('[data-preview="Accordion"] svg').click();
16
- await expect(page.locator('[data-preview="Accordion"] p')).toBeVisible();
14
+ await page.locator('[data-testid="Accordion-example-1"] [data-preview="Accordion"] svg').click();
15
+ await expect(page.locator('[data-testid="Accordion-example-1"] [data-preview="Accordion"] p')).toBeVisible();
17
16
 
18
17
  await page.close();
19
18
  });
@@ -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
+ ```
@@ -60,20 +60,20 @@ const Copy = styled.div`
60
60
  padding: 0 ${spacing('lg')};
61
61
  }
62
62
 
63
- ${({ isOpen }) => (isOpen && css`
63
+ ${({ isOpen, contentBottomPadding }) => (isOpen && css`
64
64
  height: auto;
65
65
  visibility: visible;
66
66
  transition: all 0.2s cubic-bezier(0.21, 1.7, 0.83, 0.68) 0s;
67
- padding: 0 ${spacing('l')} ${spacing('l')};
67
+ padding: 0 ${spacing('lg')} ${contentBottomPadding || spacing('l')};
68
68
 
69
69
  @media ${({ theme }) => theme.allBreakpoints('M')} {
70
- padding: 0 ${spacing('lg')} ${spacing('l')};
70
+ padding: 0 ${spacing('lg')} ${contentBottomPadding || spacing('l')};
71
71
  }
72
72
  `)}
73
73
  `;
74
74
 
75
75
  const Accordion = ({
76
- children, title, ...rest
76
+ children, title, contentBottomPadding, ...rest
77
77
  }) => {
78
78
  const [isOpen, setIsOpen] = useState(false);
79
79
 
@@ -89,7 +89,7 @@ const Accordion = ({
89
89
  <Chevron colour="black" direction={isOpen ? 'up' : 'down'} />
90
90
  </Icon>
91
91
  </Button>
92
- <Copy isOpen={isOpen}>
92
+ <Copy isOpen={isOpen} contentBottomPadding={contentBottomPadding}>
93
93
  {children}
94
94
  </Copy>
95
95
  </Container>
@@ -97,6 +97,7 @@ const Accordion = ({
97
97
  };
98
98
 
99
99
  Accordion.propTypes = {
100
+ contentBottomPadding: PropTypes.string,
100
101
  children: PropTypes.node.isRequired,
101
102
  title: PropTypes.oneOfType([
102
103
  PropTypes.string,
@@ -13,3 +13,18 @@ import Text from '../../Atoms/Text/Text';
13
13
  <Text tag="p">Name, surname, email and billing address We need these to process your payment, create a receipt and send it to you. Establishment information We use this information to understand which institutions (e.g. schools, companies) raise money for us. Your details will be kept safe and never shared with other organisations; see our Privacy Policy for more information</Text>
14
14
  </Accordion>
15
15
  ```
16
+
17
+ ```js
18
+ import Text from '../../Atoms/Text/Text';
19
+
20
+ <Accordion
21
+ contentBottomPadding="15px"
22
+ title={
23
+ <Text family="Anton" size="l" uppercase>
24
+ I am the title
25
+ </Text>
26
+ }
27
+ >
28
+ <Text tag="p">Customised bottom padding here!</Text>
29
+ </Accordion>
30
+ ```