agroptima-design-system 0.26.8 → 0.26.9
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/package.json +1 -1
- package/src/atoms/Checkbox.scss +21 -44
- package/src/atoms/Checkbox.tsx +13 -16
- package/src/stories/Changelog.mdx +8 -0
- package/tests/Checkbox.spec.tsx +1 -1
package/package.json
CHANGED
package/src/atoms/Checkbox.scss
CHANGED
|
@@ -3,66 +3,43 @@
|
|
|
3
3
|
@use '../settings/config';
|
|
4
4
|
|
|
5
5
|
.checkbox-group {
|
|
6
|
-
.checkbox-label
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
@include typography.checkbox-label;
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: flex-start;
|
|
9
|
+
align-items: center;
|
|
10
|
+
gap: config.$space-1x;
|
|
11
|
+
|
|
12
|
+
.checkbox {
|
|
13
|
+
-webkit-appearance: none;
|
|
14
|
+
-moz-appearance: none;
|
|
15
|
+
appearance: none;
|
|
16
|
+
width: config.$icon-size-4x;
|
|
17
|
+
height: config.$icon-size-4x;
|
|
18
|
+
min-width: config.$icon-size-4x;
|
|
19
|
+
}
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
21
|
+
&.disabled {
|
|
22
|
+
@include typography.checkbox-disabled-label;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
&.primary {
|
|
23
|
-
|
|
24
|
-
display: none;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
input[type='checkbox'] + .checkbox-label-container .background-icon {
|
|
26
|
+
.checkbox {
|
|
28
27
|
background: url('../icons/checkbox-primary-inactive.svg') left top
|
|
29
28
|
no-repeat;
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
input[type='checkbox']:checked
|
|
33
|
-
+ .checkbox-label-container
|
|
34
|
-
.background-icon {
|
|
30
|
+
.checkbox:checked {
|
|
35
31
|
background: url('../icons/checkbox-primary-active.svg') left top no-repeat;
|
|
36
32
|
}
|
|
37
|
-
|
|
38
|
-
// Disabled
|
|
39
|
-
input[type='checkbox']
|
|
40
|
-
+ .checkbox-label-container.disabled
|
|
41
|
-
.background-icon {
|
|
33
|
+
.checkbox:disabled {
|
|
42
34
|
background: url('../icons/checkbox-disabled-inactive.svg') left top
|
|
43
35
|
no-repeat;
|
|
44
36
|
}
|
|
45
|
-
|
|
46
|
-
input[type='checkbox']:checked
|
|
47
|
-
+ .checkbox-label-container.disabled
|
|
48
|
-
.background-icon {
|
|
37
|
+
.checkbox:checked:disabled {
|
|
49
38
|
background: url('../icons/checkbox-disabled-active.svg') left top
|
|
50
39
|
no-repeat;
|
|
51
40
|
}
|
|
52
|
-
|
|
53
|
-
.checkbox-label-container {
|
|
54
|
-
&.disabled {
|
|
55
|
-
.label {
|
|
56
|
-
@include typography.checkbox-disabled-label;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Hover
|
|
62
41
|
&:hover {
|
|
63
|
-
|
|
64
|
-
+ .checkbox-label-container:not(.disabled)
|
|
65
|
-
.background-icon {
|
|
42
|
+
.checkbox:not(:checked):not(.disabled) {
|
|
66
43
|
background: url('../icons/checkbox-primary-hover-inactive.svg') left top
|
|
67
44
|
no-repeat;
|
|
68
45
|
}
|
package/src/atoms/Checkbox.tsx
CHANGED
|
@@ -4,45 +4,42 @@ import './Checkbox.scss'
|
|
|
4
4
|
export type Variant = 'primary'
|
|
5
5
|
|
|
6
6
|
export interface CheckboxProps extends React.ComponentPropsWithoutRef<'input'> {
|
|
7
|
-
label
|
|
7
|
+
label: string
|
|
8
|
+
accessibilityLabel?: string
|
|
8
9
|
hideLabel?: boolean
|
|
9
10
|
variant?: Variant
|
|
10
11
|
id?: string
|
|
11
|
-
accessibilityLabel: string
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function Checkbox({
|
|
15
|
-
accessibilityLabel,
|
|
16
15
|
label,
|
|
17
|
-
|
|
16
|
+
accessibilityLabel,
|
|
17
|
+
hideLabel = false,
|
|
18
18
|
disabled,
|
|
19
19
|
variant = 'primary',
|
|
20
20
|
id,
|
|
21
21
|
name,
|
|
22
|
+
className,
|
|
22
23
|
...props
|
|
23
24
|
}: CheckboxProps) {
|
|
24
25
|
const identifier = id || name
|
|
25
|
-
const inputCss = classNames('checkbox', variant)
|
|
26
|
-
const labelCss = classNames('checkbox-label-container', {
|
|
27
|
-
disabled: disabled,
|
|
28
|
-
})
|
|
29
26
|
|
|
30
27
|
return (
|
|
31
|
-
<div
|
|
28
|
+
<div
|
|
29
|
+
className={classNames('checkbox-group', variant, className, {
|
|
30
|
+
disabled: disabled,
|
|
31
|
+
})}
|
|
32
|
+
>
|
|
32
33
|
<input
|
|
33
34
|
id={identifier}
|
|
34
35
|
name={name}
|
|
35
36
|
type="checkbox"
|
|
36
|
-
className=
|
|
37
|
+
className="checkbox"
|
|
37
38
|
disabled={disabled}
|
|
38
|
-
aria-label={accessibilityLabel}
|
|
39
|
+
aria-label={accessibilityLabel || label}
|
|
39
40
|
{...props}
|
|
40
41
|
/>
|
|
41
|
-
|
|
42
|
-
<label className={labelCss} htmlFor={identifier}>
|
|
43
|
-
<span className="background-icon"></span>
|
|
44
|
-
{!hideLabel && <span className="label">{label}</span>}
|
|
45
|
-
</label>
|
|
42
|
+
{!hideLabel && <label htmlFor={identifier}>{label}</label>}
|
|
46
43
|
</div>
|
|
47
44
|
)
|
|
48
45
|
}
|
|
@@ -4,6 +4,14 @@ import { Meta } from "@storybook/blocks";
|
|
|
4
4
|
|
|
5
5
|
# Changelog
|
|
6
6
|
|
|
7
|
+
# 0.26.9
|
|
8
|
+
|
|
9
|
+
* Update Checkbox component to use input and not span
|
|
10
|
+
|
|
11
|
+
BREAKING CHANGES
|
|
12
|
+
|
|
13
|
+
* Checkbox component make label mandatory and accessibilityLabel optional
|
|
14
|
+
|
|
7
15
|
# 0.26.8
|
|
8
16
|
|
|
9
17
|
* Set check value in CheckableTag
|
package/tests/Checkbox.spec.tsx
CHANGED
|
@@ -15,7 +15,7 @@ describe('Checkbox', () => {
|
|
|
15
15
|
/>,
|
|
16
16
|
)
|
|
17
17
|
expect(getAllByRole('generic')[1]).toHaveClass(`checkbox-group ${variant}`)
|
|
18
|
-
expect(getByRole('checkbox')).toHaveClass(
|
|
18
|
+
expect(getByRole('checkbox')).toHaveClass('checkbox')
|
|
19
19
|
expect(getByText(/Do you like videogames/i)).toBeInTheDocument()
|
|
20
20
|
})
|
|
21
21
|
})
|