@comicrelief/component-library 8.6.2 → 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.
- package/dist/components/Molecules/Accordion/Accordion.js +7 -4
- package/dist/components/Molecules/Accordion/Accordion.md +15 -0
- package/package.json +1 -1
- package/playwright/components/molecules/accordian.spec.js +4 -5
- package/src/components/Molecules/Accordion/Accordion.js +6 -5
- package/src/components/Molecules/Accordion/Accordion.md +15 -0
|
@@ -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)('
|
|
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
|
@@ -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('
|
|
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
|
+
```
|