Skip to content

Commit 84906f3

Browse files
authored
fix!: convert Field, Switch, Radio, Checkbox BEM classes to flat class names (#5115)
* fix!: convert Field BEM classes to flat class names Renames BEM element classes to flat names scoped by CSS nesting: - eds-field__label → label - eds-field__indicator → indicator - eds-field__description → description - eds-field__helper-message → helper-message Also restructures field.css to nest inner element selectors inside .eds-field using CSS nesting. BREAKING CHANGE: consumers targeting these class names directly in their own CSS must update to the new flat names. * fix!: convert Switch BEM classes to flat class names Renames BEM element classes to flat names scoped by CSS nesting: - eds-switch__control → control - eds-switch__input → input - eds-switch__track → track - eds-switch__handle → handle Also restructures switch.css to use full CSS nesting, moves the checked/disabled handle state rules up to the .eds-switch scope (cleaner than the previous inside-out nesting), and replaces the cross-component .eds-field__label selector with the native label element to remove the coupling to Field's internal class names. BREAKING CHANGE: consumers targeting these class names directly in their own CSS must update to the new flat names. * fix!: convert Radio BEM classes to flat class names Renames BEM element/modifier classes to flat names: - eds-radio__icon-wrapper → icon-wrapper - eds-radio__input → input - eds-radio__icon → icon - eds-radio__icon--checked → icon-checked - eds-radio__icon--unchecked → icon-unchecked - eds-radio--standalone (class modifier) → data-standalone attribute Also restructures radio.css with full CSS nesting, removes the unused classNames helper from Radio.tsx, and replaces the cross-component .eds-field__label selector with the native label element to decouple from Field's internal class names. BREAKING CHANGE: consumers targeting these class names directly in their own CSS must update to the new flat names. * fix!: convert Checkbox BEM classes to flat class names Renames BEM element/modifier classes to flat names: - eds-checkbox__icon-wrapper → icon-wrapper - eds-checkbox__input → input - eds-checkbox__icon → icon - eds-checkbox__icon--checked → icon-checked - eds-checkbox__icon--unchecked → icon-unchecked - eds-checkbox__icon--indeterminate → icon-indeterminate - eds-checkbox--standalone (class modifier) → data-standalone attribute Also restructures checkbox.css with full CSS nesting, removes the unused classNames helper from Checkbox.tsx, and replaces the cross-component .eds-field__label selector with the native label element to decouple from Field's internal class names. BREAKING CHANGE: consumers targeting these class names directly in their own CSS must update to the new flat names. * fix: update TextField snapshot after Field class name changes
1 parent cf43288 commit 84906f3

15 files changed

Lines changed: 457 additions & 440 deletions

File tree

packages/eds-core-react/src/components/next/Checkbox/Checkbox.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import { Field } from '../Field'
99
import { Icon } from '../Icon'
1010
import type { CheckboxProps } from './Checkbox.types'
1111

12-
const classNames = (...classes: (string | boolean | undefined)[]) =>
13-
classes.filter(Boolean).join(' ')
14-
1512
export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
1613
function Checkbox(
1714
{
@@ -44,27 +41,23 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
4441
id={inputId}
4542
aria-checked={indeterminate ? 'mixed' : undefined}
4643
aria-describedby={helperMessage ? helperMessageId : undefined}
47-
className="eds-checkbox__input"
44+
className="input"
4845
disabled={disabled}
4946
ref={inputRef}
5047
data-indeterminate={indeterminate}
5148
{...rest}
5249
/>
53-
<span className="eds-checkbox__icon-wrapper">
54-
<Icon
55-
data={checkbox}
56-
size="lg"
57-
className="eds-checkbox__icon eds-checkbox__icon--checked"
58-
/>
50+
<span className="icon-wrapper">
51+
<Icon data={checkbox} size="lg" className="icon icon-checked" />
5952
<Icon
6053
data={checkbox_outline}
6154
size="lg"
62-
className="eds-checkbox__icon eds-checkbox__icon--unchecked"
55+
className="icon icon-unchecked"
6356
/>
6457
<Icon
6558
data={checkbox_indeterminate}
6659
size="lg"
67-
className="eds-checkbox__icon eds-checkbox__icon--indeterminate"
60+
className="icon icon-indeterminate"
6861
/>
6962
</span>
7063
</>
@@ -96,7 +89,8 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
9689

9790
return (
9891
<span
99-
className={classNames('eds-checkbox', 'eds-checkbox--standalone')}
92+
className="eds-checkbox"
93+
data-standalone={true}
10094
data-color-appearance={disabled ? 'neutral' : 'accent'}
10195
data-disabled={disabled || undefined}
10296
>

packages/eds-core-react/src/components/next/Checkbox/__snapshots__/Checkbox.test.tsx.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ exports[`Checkbox (next) matches snapshot 1`] = `
1010
data-space-proportions="squished"
1111
>
1212
<input
13-
class="eds-checkbox__input"
13+
class="input"
1414
data-indeterminate="false"
1515
id="test-id"
1616
type="checkbox"
1717
/>
1818
<span
19-
class="eds-checkbox__icon-wrapper"
19+
class="icon-wrapper"
2020
>
2121
<svg
2222
aria-hidden="true"
23-
class="eds-icon eds-checkbox__icon eds-checkbox__icon--checked"
23+
class="eds-icon icon icon-checked"
2424
data-icon-size="lg"
2525
data-testid="eds-icon"
2626
fill="currentColor"
@@ -35,7 +35,7 @@ exports[`Checkbox (next) matches snapshot 1`] = `
3535
</svg>
3636
<svg
3737
aria-hidden="true"
38-
class="eds-icon eds-checkbox__icon eds-checkbox__icon--unchecked"
38+
class="eds-icon icon icon-unchecked"
3939
data-icon-size="lg"
4040
data-testid="eds-icon"
4141
fill="currentColor"
@@ -50,7 +50,7 @@ exports[`Checkbox (next) matches snapshot 1`] = `
5050
</svg>
5151
<svg
5252
aria-hidden="true"
53-
class="eds-icon eds-checkbox__icon eds-checkbox__icon--indeterminate"
53+
class="eds-icon icon icon-indeterminate"
5454
data-icon-size="lg"
5555
data-testid="eds-icon"
5656
fill="currentColor"
@@ -65,7 +65,7 @@ exports[`Checkbox (next) matches snapshot 1`] = `
6565
</svg>
6666
</span>
6767
<label
68-
class="eds-field__label"
68+
class="label"
6969
data-baseline="center"
7070
for="test-id"
7171
>

0 commit comments

Comments
 (0)