Skip to content

Commit 8ac8299

Browse files
committed
fix(form): MenuItemSwitch spacing styles
Closes #1126
1 parent 9315eff commit 8ac8299

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

packages/form/src/menu/MenuItemInputToggle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export const MenuItemInputToggle = forwardRef<
196196
onCheckedChange(!checked, event);
197197
}}
198198
ref={ref}
199-
className={cn(styles(), className)}
199+
className={cn(styles({ switch: type === "switch" }), className)}
200200
tabIndex={tabIndex}
201201
leftAddon={leftAddon}
202202
leftAddonType={leftAddonType}

packages/form/src/menu/__tests__/__snapshots__/MenuItemInputToggle.tsx.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ exports[`MenuItemInputToggle should render correctly 3`] = `
9393
exports[`MenuItemInputToggle should render correctly 4`] = `
9494
<li
9595
aria-checked="false"
96-
class="rmd-list-item rmd-list-item--medium rmd-list-item--clickable rmd-input-toggle-menu-item"
96+
class="rmd-list-item rmd-list-item--medium rmd-list-item--clickable rmd-input-toggle-menu-item rmd-input-toggle-menu-item--switch"
9797
id="menu-id-4"
9898
role="menuitemcheckbox"
9999
tabindex="-1"
100100
>
101101
<span
102-
class="rmd-switch"
102+
class="rmd-switch rmd-icon--before rmd-list-item__addon rmd-list-item__addon--before"
103103
>
104104
<span
105105
class="rmd-switch__ball"
@@ -206,13 +206,13 @@ exports[`MenuItemInputToggle should render correctly 7`] = `
206206
exports[`MenuItemInputToggle should render correctly 8`] = `
207207
<li
208208
aria-checked="false"
209-
class="rmd-list-item rmd-list-item--medium rmd-list-item--clickable rmd-input-toggle-menu-item"
209+
class="rmd-list-item rmd-list-item--medium rmd-list-item--clickable rmd-input-toggle-menu-item rmd-input-toggle-menu-item--switch"
210210
id="menu-id-4"
211211
role="menuitemcheckbox"
212212
tabindex="-1"
213213
>
214214
<span
215-
class="rmd-switch"
215+
class="rmd-switch rmd-icon--before rmd-list-item__addon rmd-list-item__addon--before"
216216
>
217217
<span
218218
class="rmd-switch__ball"
@@ -319,7 +319,7 @@ exports[`MenuItemInputToggle should render correctly 11`] = `
319319
exports[`MenuItemInputToggle should render correctly 12`] = `
320320
<li
321321
aria-checked="false"
322-
class="rmd-list-item rmd-list-item--medium rmd-list-item--clickable rmd-input-toggle-menu-item"
322+
class="rmd-list-item rmd-list-item--medium rmd-list-item--clickable rmd-input-toggle-menu-item rmd-input-toggle-menu-item--switch"
323323
id="menu-id-4"
324324
role="menuitemcheckbox"
325325
tabindex="-1"
@@ -330,7 +330,7 @@ exports[`MenuItemInputToggle should render correctly 12`] = `
330330
Switch
331331
</span>
332332
<span
333-
class="rmd-switch"
333+
class="rmd-switch rmd-icon--after rmd-list-item__addon"
334334
>
335335
<span
336336
class="rmd-switch__ball"
@@ -453,13 +453,13 @@ exports[`MenuItemInputToggle should render correctly 15`] = `
453453
exports[`MenuItemInputToggle should render correctly 16`] = `
454454
<li
455455
aria-checked="false"
456-
class="rmd-list-item rmd-list-item--extra-large rmd-list-item--clickable rmd-input-toggle-menu-item"
456+
class="rmd-list-item rmd-list-item--extra-large rmd-list-item--clickable rmd-input-toggle-menu-item rmd-input-toggle-menu-item--switch"
457457
id="menu-id-4"
458458
role="menuitemcheckbox"
459459
tabindex="-1"
460460
>
461461
<span
462-
class="rmd-switch"
462+
class="rmd-switch rmd-icon--before rmd-list-item__addon rmd-list-item__addon--before"
463463
>
464464
<span
465465
class="rmd-switch__ball"

packages/form/src/menu/__tests__/__snapshots__/MenuItemSwitch.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
exports[`MenuItemSwitch should update the state and close the menu once clicked 1`] = `
44
<li
55
aria-checked="false"
6-
class="rmd-list-item rmd-list-item--medium rmd-list-item--clickable rmd-input-toggle-menu-item"
6+
class="rmd-list-item rmd-list-item--medium rmd-list-item--clickable rmd-input-toggle-menu-item rmd-input-toggle-menu-item--switch"
77
id="menu-id-1"
88
role="menuitemcheckbox"
99
tabindex="-1"
1010
>
1111
<span
12-
class="rmd-switch"
12+
class="rmd-switch rmd-icon--before rmd-list-item__addon rmd-list-item__addon--before"
1313
>
1414
<span
1515
class="rmd-switch__ball"
@@ -26,13 +26,13 @@ exports[`MenuItemSwitch should update the state and close the menu once clicked
2626
exports[`MenuItemSwitch should update the state and close the menu once clicked 2`] = `
2727
<li
2828
aria-checked="true"
29-
class="rmd-list-item rmd-list-item--medium rmd-list-item--clickable rmd-input-toggle-menu-item"
29+
class="rmd-list-item rmd-list-item--medium rmd-list-item--clickable rmd-input-toggle-menu-item rmd-input-toggle-menu-item--switch"
3030
id="menu-id-1"
3131
role="menuitemcheckbox"
3232
tabindex="-1"
3333
>
3434
<span
35-
class="rmd-switch"
35+
class="rmd-switch rmd-icon--before rmd-list-item__addon rmd-list-item__addon--before"
3636
>
3737
<span
3838
class="rmd-switch__ball rmd-switch__ball--checked"

packages/form/src/toggle/SwitchTrack.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const SwitchTrack = forwardRef<HTMLInputElement, SwitchTrackProps>(
6666
return (
6767
<span
6868
{...containerProps}
69-
className={cn(styles(), containerProps?.className)}
69+
className={cn(styles(), className, containerProps?.className)}
7070
>
7171
{id && (
7272
<>
@@ -75,7 +75,7 @@ export const SwitchTrack = forwardRef<HTMLInputElement, SwitchTrackProps>(
7575
id={id}
7676
ref={ref}
7777
type="checkbox"
78-
className={cn(styles("input"), className)}
78+
className={cn(styles("input"))}
7979
disabled={disabled}
8080
/>
8181
<label

packages/form/src/toggle/_mixins.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@
370370
.rmd-input-toggle-menu-item {
371371
// shrink the checkbox/radio icon size to just be an icon
372372
@include rmd-button-theme-update-var(icon-size, rmd-icon-theme-var(size));
373+
374+
&--switch {
375+
// this makes the spacing correct between the switch and the text
376+
@include rmd-icon-theme-update-var(size, $rmd-switch-track-width);
377+
}
373378
}
374379

375380
.rmd-switch-container {

0 commit comments

Comments
 (0)