Skip to content

Commit f77a28f

Browse files
committed
feat(checkbox): adding focused and hovered states in test env
1 parent 2523707 commit f77a28f

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

components/checkbox/stories/checkbox.test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ export const CheckboxGroup = Variants({
1313
testHeading: "Emphasized",
1414
isEmphasized: true,
1515
},
16+
{
17+
testHeading: "Focused",
18+
isFocused: true,
19+
},
20+
{
21+
testHeading: "Hovered",
22+
isHovered: true,
23+
},
1624
{
1725
testHeading: "Truncation",
1826
withStates: false,
@@ -78,5 +86,5 @@ export const CheckboxGroup = Variants({
7886
isReadOnly: true,
7987
isChecked: true,
8088
},
81-
]
89+
],
8290
});

components/checkbox/stories/template.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export const Template = ({
1818
isDisabled = false,
1919
isInvalid = false,
2020
isReadOnly = false,
21+
isFocused = false,
22+
isHovered,
2123
title,
2224
value,
2325
id = getRandomId("checkbox"),
@@ -53,18 +55,25 @@ export const Template = ({
5355
["is-disabled"]: isDisabled,
5456
["is-invalid"]: isInvalid,
5557
["is-readOnly"]: isReadOnly,
58+
"is-hover": isHovered,
5659
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
5760
})}
5861
id=${ifDefined(id)}
5962
style=${styleMap(customStyles)}
6063
>
6164
<input
6265
type="checkbox"
63-
class="${rootClass}-input"
66+
class=${classMap({["is-focus-visible"]: isFocused, [`${rootClass}-input`]: true })}
6467
aria-labelledby=${ifDefined(ariaLabelledby)}
6568
aria-disabled=${ifDefined(isReadOnly ? "true" : undefined)}
6669
?checked=${isChecked}
6770
?disabled=${isDisabled}
71+
@focusin=${function() {
72+
updateArgs({ isFocused: true });
73+
}}
74+
@focusout=${function() {
75+
updateArgs({ isFocused: false });
76+
}}
6877
title=${ifDefined(title)}
6978
value=${ifDefined(value)}
7079
@change=${(e) => {

0 commit comments

Comments
 (0)