Skip to content

Commit

Permalink
enhance(Switch): ensure that disabled also affects styling in active …
Browse files Browse the repository at this point in the history
…state
  • Loading branch information
sjschlapbach committed Oct 3, 2023
1 parent f2386fd commit 47cfa1e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Switch.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ export const Disabled = () => {
)
}

export const DisabledActive = () => {
const [isChecked, setIsChecked] = useState(true)
return (
<Switch
disabled
checked={isChecked}
label="Unchecked"
onCheckedChange={(newValue) => setIsChecked(newValue)}
/>
)
}

export const Sizes = () => {
const [isChecked1, setIsChecked1] = useState(false)
const [isChecked2, setIsChecked2] = useState(false)
Expand Down
1 change: 1 addition & 0 deletions src/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export function Switch({
'relative rounded-full border-0 bg-uzh-grey-80',
disabled && 'cursor-not-allowed bg-uzh-grey-40',
checked && 'bg-primary-60',
checked && disabled && 'bg-primary-20',
rootSize[size || 'md'],
className?.element
)}
Expand Down

0 comments on commit 47cfa1e

Please sign in to comment.