Skip to content

Commit

Permalink
ToggleSwitch: removes hover style from disabled state (#5504)
Browse files Browse the repository at this point in the history
* ToggleSwitch: removes hover style from disabled state

* fix prettier and test
  • Loading branch information
Kitty-Al authored Feb 5, 2025
1 parent 4e6d4a2 commit 8fe7419
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-lies-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@kaizen/components': patch
---

ToggleSwitch: removes hover style from disabled state
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@ $focus-ring-offset: 1px;

/* TODO: Fix */
/* stylelint-disable no-descending-specificity */
.checkbox:focus + &,
.checkbox:hover:focus + & {
.checkbox:not(.disabled):focus + &,
.checkbox:not(.disabled):hover:focus + & {
border-color: transparent;
outline: 2px solid $color-blue-500;
outline-offset: $focus-ring-offset;
background-color: $color-gray-600;
}

.checkbox + &:hover,
.checkbox:not(.disabled) + &:hover,
label:hover .checkbox + & {
background-color: $color-purple-500;
background-color: $color-gray-600;
}

/* stylelint-enable no-descending-specificity */
}

Expand Down Expand Up @@ -86,7 +87,7 @@ $focus-ring-offset: 1px;
transition-duration: $animation-duration-fast;
}

.checkbox + .track:hover,
.checkbox:not(.disabled) + .track:hover,
label:hover & .checkbox + .track {
background-color: $color-green-600;
}
Expand Down Expand Up @@ -116,10 +117,11 @@ $focus-ring-offset: 1px;
background-color: rgba($color-white-rgb, 0.65);
}

.checkbox + .track:hover,
.checkbox:not(.disabled) + .track:hover,
label:hover & .checkbox + .track {
background-color: rgba($color-white-rgb, 0.65);
}
}
}

/* stylelint-enable no-descending-specificity */
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const ToggleSwitch = ({
toggledStatus,
onToggle,
reversed,
disabled,
...restProps
}: ToggleSwitchProps): JSX.Element => {
const isOn = toggledStatus === 'on'
Expand All @@ -27,12 +28,13 @@ export const ToggleSwitch = ({
<span className={classnames(isOn ? styles.on : styles.off, reversed && styles.reversed)}>
<input
type="checkbox"
className={styles.checkbox}
className={classnames(styles.checkbox, disabled && styles.disabled)}
checked={isOn ? true : false}
onChange={onToggle}
disabled={disabled}
{...restProps}
/>
<span className={styles.track}>
<span className={classnames(styles.track, disabled && styles.disabled)}>
<span className={styles.thumb}>
<Icon name="check" isPresentational className={styles.checkIcon} />
</span>
Expand Down

0 comments on commit 8fe7419

Please sign in to comment.