@comicrelief/component-library 8.18.1 → 8.18.2
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/README.md +1 -1
- package/dist/components/Atoms/Checkbox/Checkbox.js +4 -1
- package/dist/components/Atoms/Checkbox/Checkbox.md +8 -7
- package/dist/components/Atoms/Checkbox/Checkbox.test.js +1 -1
- package/package.json +1 -1
- package/playwright/components/atoms/checkbox.spec.js +2 -3
- package/src/components/Atoms/Checkbox/Checkbox.js +3 -0
- package/src/components/Atoms/Checkbox/Checkbox.md +8 -7
- package/src/components/Atoms/Checkbox/Checkbox.test.js +2 -0
package/README.md
CHANGED
|
@@ -73,12 +73,15 @@ const Checkbox = /*#__PURE__*/_react.default.forwardRef((_ref8, ref) => {
|
|
|
73
73
|
checkboxBgChecked,
|
|
74
74
|
checkboxBorderChecked,
|
|
75
75
|
checkboxBorderFocus,
|
|
76
|
+
name,
|
|
76
77
|
...rest
|
|
77
78
|
} = _ref8;
|
|
78
79
|
return /*#__PURE__*/_react.default.createElement(Label, {
|
|
79
80
|
hasLabelAsString: !!label,
|
|
80
|
-
labelColour: labelColour
|
|
81
|
+
labelColour: labelColour,
|
|
82
|
+
htmlFor: name
|
|
81
83
|
}, /*#__PURE__*/_react.default.createElement(StyledCheckboxInput, Object.assign({}, rest, {
|
|
84
|
+
name: name,
|
|
82
85
|
value: value,
|
|
83
86
|
ref: ref,
|
|
84
87
|
checkboxBg: checkboxBg,
|
|
@@ -24,13 +24,14 @@ const LongLabel = () => (
|
|
|
24
24
|
|
|
25
25
|
<>
|
|
26
26
|
<p>List of checkboxes</p>
|
|
27
|
-
<Checkbox name="
|
|
28
|
-
<Checkbox name="
|
|
29
|
-
<Checkbox name="
|
|
27
|
+
<Checkbox id="sport1" name="sport1" value="Tennis" label="Tennis" />
|
|
28
|
+
<Checkbox id="sport2" name="sport2" value="Basketball" label="Basketball" />
|
|
29
|
+
<Checkbox id="sport3" name="sport3" value="Cycling" label="Cycling" />
|
|
30
30
|
<Checkbox
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
id="sport4"
|
|
32
|
+
name="sport4"
|
|
33
|
+
value="Football (with wacky styling to test props)"
|
|
34
|
+
label="Football (with wacky styling to test props)"
|
|
34
35
|
labelColour="purple_dark"
|
|
35
36
|
checkboxBg="white"
|
|
36
37
|
checkboxBorder="black"
|
|
@@ -40,7 +41,7 @@ const LongLabel = () => (
|
|
|
40
41
|
/>
|
|
41
42
|
<br/>
|
|
42
43
|
<p>A checkbox with a long label containing links</p>
|
|
43
|
-
<Checkbox name="node_label" value="node_label">
|
|
44
|
+
<Checkbox id="node_label" name="node_label" value="node_label">
|
|
44
45
|
<LongLabel />
|
|
45
46
|
</Checkbox>
|
|
46
47
|
</>
|
|
@@ -15,5 +15,5 @@ it('renders correctly', () => {
|
|
|
15
15
|
value: "Handball",
|
|
16
16
|
label: "Handball"
|
|
17
17
|
}))).toJSON();
|
|
18
|
-
expect(tree).toMatchInlineSnapshot("\n Array [\n .c2 {\n font-size: 1rem;\n line-height: 1rem;\n text-transform: inherit;\n font-weight: bold;\n line-height: normal;\n font-family: 'Montserrat',Helvetica,Arial,sans-serif;\n }\n\n .c0 {\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-align-items: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n margin-bottom: 8px;\n }\n\n .c1 {\n border: 0;\n -webkit-clip: rect(0 0 0 0);\n clip: rect(0 0 0 0);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n }\n\n .c1 + span {\n margin-right: 12px;\n width: 24px;\n height: 24px;\n border-radius: 4px;\n background-color: #FFFFFF;\n border: 1px solid #969598;\n float: left;\n -webkit-flex-shrink: 0;\n -ms-flex-negative: 0;\n flex-shrink: 0;\n }\n\n .c1:checked + span {\n background: url(mock.asset) no-repeat center;\n background-size: contain;\n background-color: #E52630;\n border: 1px solid #E52630;\n }\n\n .c1:focus + span {\n border: 1px solid #E52630;\n }\n\n <label\n className=\"c0\"\n >\n <input\n className=\"c1\"\n name=\"sport\"\n type=\"checkbox\"\n value=\"Tenis\"\n />\n <span />\n <span\n className=\"c2\"\n color=\"inherit\"\n size=\"s\"\n >\n Tenis\n </span>\n </label>,\n .c2 {\n font-size: 1rem;\n line-height: 1rem;\n text-transform: inherit;\n font-weight: bold;\n line-height: normal;\n font-family: 'Montserrat',Helvetica,Arial,sans-serif;\n }\n\n .c0 {\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-align-items: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n margin-bottom: 8px;\n }\n\n .c1 {\n border: 0;\n -webkit-clip: rect(0 0 0 0);\n clip: rect(0 0 0 0);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n }\n\n .c1 + span {\n margin-right: 12px;\n width: 24px;\n height: 24px;\n border-radius: 4px;\n background-color: #FFFFFF;\n border: 1px solid #969598;\n float: left;\n -webkit-flex-shrink: 0;\n -ms-flex-negative: 0;\n flex-shrink: 0;\n }\n\n .c1:checked + span {\n background: url(mock.asset) no-repeat center;\n background-size: contain;\n background-color: #E52630;\n border: 1px solid #E52630;\n }\n\n .c1:focus + span {\n border: 1px solid #E52630;\n }\n\n <label\n className=\"c0\"\n >\n <input\n className=\"c1\"\n name=\"sport\"\n type=\"checkbox\"\n value=\"Handball\"\n />\n <span />\n <span\n className=\"c2\"\n color=\"inherit\"\n size=\"s\"\n >\n Handball\n </span>\n </label>,\n ]\n ");
|
|
18
|
+
expect(tree).toMatchInlineSnapshot("\n Array [\n .c2 {\n font-size: 1rem;\n line-height: 1rem;\n text-transform: inherit;\n font-weight: bold;\n line-height: normal;\n font-family: 'Montserrat',Helvetica,Arial,sans-serif;\n }\n\n .c0 {\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-align-items: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n margin-bottom: 8px;\n }\n\n .c1 {\n border: 0;\n -webkit-clip: rect(0 0 0 0);\n clip: rect(0 0 0 0);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n }\n\n .c1 + span {\n margin-right: 12px;\n width: 24px;\n height: 24px;\n border-radius: 4px;\n background-color: #FFFFFF;\n border: 1px solid #969598;\n float: left;\n -webkit-flex-shrink: 0;\n -ms-flex-negative: 0;\n flex-shrink: 0;\n }\n\n .c1:checked + span {\n background: url(mock.asset) no-repeat center;\n background-size: contain;\n background-color: #E52630;\n border: 1px solid #E52630;\n }\n\n .c1:focus + span {\n border: 1px solid #E52630;\n }\n\n <label\n className=\"c0\"\n htmlFor=\"sport\"\n >\n <input\n className=\"c1\"\n name=\"sport\"\n type=\"checkbox\"\n value=\"Tenis\"\n />\n <span />\n <span\n className=\"c2\"\n color=\"inherit\"\n size=\"s\"\n >\n Tenis\n </span>\n </label>,\n .c2 {\n font-size: 1rem;\n line-height: 1rem;\n text-transform: inherit;\n font-weight: bold;\n line-height: normal;\n font-family: 'Montserrat',Helvetica,Arial,sans-serif;\n }\n\n .c0 {\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-align-items: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n margin-bottom: 8px;\n }\n\n .c1 {\n border: 0;\n -webkit-clip: rect(0 0 0 0);\n clip: rect(0 0 0 0);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n }\n\n .c1 + span {\n margin-right: 12px;\n width: 24px;\n height: 24px;\n border-radius: 4px;\n background-color: #FFFFFF;\n border: 1px solid #969598;\n float: left;\n -webkit-flex-shrink: 0;\n -ms-flex-negative: 0;\n flex-shrink: 0;\n }\n\n .c1:checked + span {\n background: url(mock.asset) no-repeat center;\n background-size: contain;\n background-color: #E52630;\n border: 1px solid #E52630;\n }\n\n .c1:focus + span {\n border: 1px solid #E52630;\n }\n\n <label\n className=\"c0\"\n htmlFor=\"sport\"\n >\n <input\n className=\"c1\"\n name=\"sport\"\n type=\"checkbox\"\n value=\"Handball\"\n />\n <span />\n <span\n className=\"c2\"\n color=\"inherit\"\n size=\"s\"\n >\n Handball\n </span>\n </label>,\n ]\n ");
|
|
19
19
|
});
|
package/package.json
CHANGED
|
@@ -2,7 +2,6 @@ const { test, expect } = require('@playwright/test');
|
|
|
2
2
|
|
|
3
3
|
test.describe('checkbox', () => {
|
|
4
4
|
test('checkbox component', async ({ page }) => {
|
|
5
|
-
|
|
6
5
|
await page.goto('/#checkbox');
|
|
7
6
|
|
|
8
7
|
// checkbox component should be visible
|
|
@@ -27,7 +26,7 @@ test.describe('checkbox', () => {
|
|
|
27
26
|
|
|
28
27
|
// football checkbox
|
|
29
28
|
await page.locator('[data-testid="Checkbox-example-1"] div > label:nth-child(5)').click();
|
|
30
|
-
await expect(page.locator('[data-testid="Checkbox-example-1"] div > label:nth-child(5)')).toHaveValue('Football');
|
|
29
|
+
await expect(page.locator('[data-testid="Checkbox-example-1"] div > label:nth-child(5)')).toHaveValue('Football (with wacky styling to test props)');
|
|
31
30
|
expect(await page.locator('[data-testid="Checkbox-example-1"] div > label:nth-child(5)').isChecked()).toBeTruthy();
|
|
32
31
|
|
|
33
32
|
// terms and conditions
|
|
@@ -52,7 +51,7 @@ test.describe('checkbox', () => {
|
|
|
52
51
|
|
|
53
52
|
// football checkbox
|
|
54
53
|
await page.locator('[data-testid="Checkbox-example-1"] div > label:nth-child(5)').click();
|
|
55
|
-
await expect(page.locator('[data-testid="Checkbox-example-1"] div > label:nth-child(5)')).toHaveValue('Football');
|
|
54
|
+
await expect(page.locator('[data-testid="Checkbox-example-1"] div > label:nth-child(5)')).toHaveValue('Football (with wacky styling to test props)');
|
|
56
55
|
expect(await page.locator('[data-testid="Checkbox-example-1"] div > label:nth-child(5)').isChecked()).toBeFalsy();
|
|
57
56
|
|
|
58
57
|
// terms and conditions
|
|
@@ -59,14 +59,17 @@ const Checkbox = React.forwardRef(({
|
|
|
59
59
|
checkboxBgChecked,
|
|
60
60
|
checkboxBorderChecked,
|
|
61
61
|
checkboxBorderFocus,
|
|
62
|
+
name,
|
|
62
63
|
...rest
|
|
63
64
|
}, ref) => (
|
|
64
65
|
<Label
|
|
65
66
|
hasLabelAsString={!!label}
|
|
66
67
|
labelColour={labelColour}
|
|
68
|
+
htmlFor={name}
|
|
67
69
|
>
|
|
68
70
|
<StyledCheckboxInput
|
|
69
71
|
{...rest}
|
|
72
|
+
name={name}
|
|
70
73
|
value={value}
|
|
71
74
|
ref={ref}
|
|
72
75
|
checkboxBg={checkboxBg}
|
|
@@ -24,13 +24,14 @@ const LongLabel = () => (
|
|
|
24
24
|
|
|
25
25
|
<>
|
|
26
26
|
<p>List of checkboxes</p>
|
|
27
|
-
<Checkbox name="
|
|
28
|
-
<Checkbox name="
|
|
29
|
-
<Checkbox name="
|
|
27
|
+
<Checkbox id="sport1" name="sport1" value="Tennis" label="Tennis" />
|
|
28
|
+
<Checkbox id="sport2" name="sport2" value="Basketball" label="Basketball" />
|
|
29
|
+
<Checkbox id="sport3" name="sport3" value="Cycling" label="Cycling" />
|
|
30
30
|
<Checkbox
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
id="sport4"
|
|
32
|
+
name="sport4"
|
|
33
|
+
value="Football (with wacky styling to test props)"
|
|
34
|
+
label="Football (with wacky styling to test props)"
|
|
34
35
|
labelColour="purple_dark"
|
|
35
36
|
checkboxBg="white"
|
|
36
37
|
checkboxBorder="black"
|
|
@@ -40,7 +41,7 @@ const LongLabel = () => (
|
|
|
40
41
|
/>
|
|
41
42
|
<br/>
|
|
42
43
|
<p>A checkbox with a long label containing links</p>
|
|
43
|
-
<Checkbox name="node_label" value="node_label">
|
|
44
|
+
<Checkbox id="node_label" name="node_label" value="node_label">
|
|
44
45
|
<LongLabel />
|
|
45
46
|
</Checkbox>
|
|
46
47
|
</>
|
|
@@ -73,6 +73,7 @@ it('renders correctly', () => {
|
|
|
73
73
|
|
|
74
74
|
<label
|
|
75
75
|
className="c0"
|
|
76
|
+
htmlFor="sport"
|
|
76
77
|
>
|
|
77
78
|
<input
|
|
78
79
|
className="c1"
|
|
@@ -149,6 +150,7 @@ it('renders correctly', () => {
|
|
|
149
150
|
|
|
150
151
|
<label
|
|
151
152
|
className="c0"
|
|
153
|
+
htmlFor="sport"
|
|
152
154
|
>
|
|
153
155
|
<input
|
|
154
156
|
className="c1"
|