Skip to content

Commit ac084ab

Browse files
OpenStaxClaudeRoyEJohnson
authored andcommitted
Address Copilot review comments for CSS class naming and type safety
- Replace generic 'disabled' class with BEM-style modifier classes to avoid CSS collisions with consumer code: - checkbox-label--disabled / checkbox-input--disabled - radio-label--disabled / radio-input--disabled - Add explicit HTMLElement type to ref in Radio.tsx for better type safety - Update all component implementations to use new BEM class names - Update test snapshots All 214 tests passing. Addresses review comments from Copilot about: - Generic class names causing potential conflicts in published component library - Untyped ref leading to potential type errors revert lock files Update index.spec.tsx.snap
1 parent 293d32d commit ac084ab

8 files changed

Lines changed: 19 additions & 19 deletions

File tree

src/components/Checkbox/Checkbox.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
color: var(--checkbox-color, inherit);
88
}
99

10-
.checkbox-label.disabled {
10+
.checkbox-label--disabled {
1111
color: var(--checkbox-disabled-color, #e5e5e5);
1212
}
1313

@@ -45,12 +45,12 @@
4545
opacity: var(--checkbox-checked-opacity, 1);
4646
}
4747

48-
.checkbox-input.disabled {
48+
.checkbox-input--disabled {
4949
opacity: 0.4;
5050
border: var(--checkbox-disabled-border, 1px solid #d5d5d5);
5151
}
5252

53-
.checkbox-input.disabled:checked::before {
53+
.checkbox-input--disabled:checked::before {
5454
opacity: 0;
5555
}
5656

@@ -97,11 +97,11 @@
9797
background-image: var(--checkbox-indeterminate-icon, none);
9898
}
9999

100-
.checkbox-label.disabled [data-slot="selection"] {
100+
.checkbox-label--disabled [data-slot="selection"] {
101101
opacity: 0.4;
102102
border: var(--checkbox-disabled-border, 1px solid #d5d5d5);
103103
}
104104

105-
.checkbox-label.disabled[data-selected] [data-slot="selection"]::before {
105+
.checkbox-label--disabled[data-selected] [data-slot="selection"]::before {
106106
opacity: 0;
107107
}

src/components/Checkbox/Checkbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const Checkbox = ({ children, disabled, variant = 'primary', bold = false
2121
// Merge labelProps className with our label classes
2222
const labelClassName = classNames(
2323
'checkbox-label',
24-
{ 'disabled': disabled },
24+
{ 'checkbox-label--disabled': disabled },
2525
labelProps?.className
2626
);
2727

@@ -36,7 +36,7 @@ export const Checkbox = ({ children, disabled, variant = 'primary', bold = false
3636
// Merge input className
3737
const inputClassName = classNames(
3838
'checkbox-input',
39-
{ 'disabled': disabled },
39+
{ 'checkbox-input--disabled': disabled },
4040
className
4141
);
4242

src/components/Checkbox/__snapshots__/Checkbox.spec.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ exports[`Checkbox allows setting props on label 1`] = `
3434

3535
exports[`Checkbox handles disabled state 1`] = `
3636
<label
37-
className="checkbox-label disabled"
37+
className="checkbox-label checkbox-label--disabled"
3838
style={
3939
Object {
4040
"--checkbox-color": "inherit",
@@ -44,7 +44,7 @@ exports[`Checkbox handles disabled state 1`] = `
4444
}
4545
>
4646
<input
47-
className="checkbox-input disabled"
47+
className="checkbox-input checkbox-input--disabled"
4848
disabled={true}
4949
style={
5050
Object {

src/components/Radio.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
position: relative;
99
}
1010

11-
.radio-label.disabled {
11+
.radio-label--disabled {
1212
color: var(--radio-disabled-color, #d5d5d5);
1313
}
1414

@@ -43,11 +43,11 @@
4343
opacity: var(--radio-checked-opacity, 1);
4444
}
4545

46-
.radio-input.disabled {
46+
.radio-input--disabled {
4747
opacity: 0.4;
4848
}
4949

50-
.radio-input.disabled:checked::before {
50+
.radio-input--disabled:checked::before {
5151
opacity: 0;
5252
}
5353

src/components/Radio.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ export const Radio = ({ children, disabled, labelAs, className, style, tooltipTe
1616
labelAs?: string;
1717
}) => {
1818
const state = useTooltipTriggerState({delay: 0});
19-
const ref = React.useRef(null);
19+
const ref = React.useRef<HTMLElement>(null);
2020

2121
const { triggerProps, tooltipProps } = useTooltipTrigger({delay: 0}, state, ref);
2222

2323
// Label className
2424
const labelClassName = classNames(
2525
'radio-label',
26-
{ 'disabled': disabled }
26+
{ 'radio-label--disabled': disabled }
2727
);
2828

2929
// Label style with CSS variables
@@ -35,7 +35,7 @@ export const Radio = ({ children, disabled, labelAs, className, style, tooltipTe
3535
// Input className
3636
const inputClassName = classNames(
3737
'radio-input',
38-
{ 'disabled': disabled },
38+
{ 'radio-input--disabled': disabled },
3939
className
4040
);
4141

src/components/Tree/TreeCheckbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const TreeCheckbox = ({
3636
// Build className
3737
const checkboxClassName = classNames(
3838
'checkbox-label',
39-
{ 'disabled': isDisabled },
39+
{ 'checkbox-label--disabled': isDisabled },
4040
className
4141
);
4242

src/components/Tree/__snapshots__/TreeCheckbox.spec.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`TreeCheckbox handles disabled state 1`] = `
44
<label
5-
className="checkbox-label disabled"
5+
className="checkbox-label checkbox-label--disabled"
66
data-disabled={true}
77
data-rac=""
88
data-react-aria-pressable={true}

src/components/__snapshots__/Radio.spec.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`Radio matches disabled snapshot 1`] = `
44
<label
5-
className="radio-label disabled"
5+
className="radio-label radio-label--disabled"
66
style={
77
Object {
88
"--radio-disabled-color": "#d5d5d5",
@@ -11,7 +11,7 @@ exports[`Radio matches disabled snapshot 1`] = `
1111
}
1212
>
1313
<input
14-
className="radio-input disabled"
14+
className="radio-input radio-input--disabled"
1515
disabled={true}
1616
style={
1717
Object {

0 commit comments

Comments
 (0)