@comicrelief/component-library 8.6.1 → 8.7.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.
@@ -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);
@@ -65,12 +67,14 @@ const Accordion = _ref6 => {
65
67
  return /*#__PURE__*/_react.default.createElement(Container, rest, /*#__PURE__*/_react.default.createElement(Button, {
66
68
  onClick: handleOpen,
67
69
  "aria-expanded": isOpen ? 'true' : 'false',
68
- ChevronKeyframes: ChevronKeyframes
70
+ ChevronKeyframes: ChevronKeyframes,
71
+ type: "button"
69
72
  }, title, /*#__PURE__*/_react.default.createElement(Icon, null, /*#__PURE__*/_react.default.createElement(_index.Chevron, {
70
73
  colour: "black",
71
74
  direction: isOpen ? 'up' : 'down'
72
75
  }))), /*#__PURE__*/_react.default.createElement(Copy, {
73
- isOpen: isOpen
76
+ isOpen: isOpen,
77
+ contentBottomPadding: contentBottomPadding
74
78
  }, children));
75
79
  };
76
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
+ ```
@@ -114,6 +114,7 @@ exports[`renders correctly 1`] = `
114
114
  aria-expanded="false"
115
115
  className="c1"
116
116
  onClick={[Function]}
117
+ type="button"
117
118
  >
118
119
  <h2
119
120
  className="c2"
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.1",
4
+ "version": "8.7.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
  });
@@ -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
 
@@ -83,13 +83,13 @@ const Accordion = ({
83
83
 
84
84
  return (
85
85
  <Container {...rest}>
86
- <Button onClick={handleOpen} aria-expanded={isOpen ? 'true' : 'false'} ChevronKeyframes={ChevronKeyframes}>
86
+ <Button onClick={handleOpen} aria-expanded={isOpen ? 'true' : 'false'} ChevronKeyframes={ChevronKeyframes} type="button">
87
87
  {title}
88
88
  <Icon>
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
+ ```
@@ -114,6 +114,7 @@ exports[`renders correctly 1`] = `
114
114
  aria-expanded="false"
115
115
  className="c1"
116
116
  onClick={[Function]}
117
+ type="button"
117
118
  >
118
119
  <h2
119
120
  className="c2"