Skip to content

Commit

Permalink
Merge pull request #152 from brainstormforce/switch-fixes
Browse files Browse the repository at this point in the history
SUR-310 - Switch fixes
  • Loading branch information
vrundakansara authored Oct 16, 2024
2 parents 9ee14b0 + 52cc569 commit 24d3cb0
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/components/switch/switch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,26 +118,23 @@ const SwitchComponent = (

const colorClassNames = {
primary: {
input: 'bg-toggle-off hover:bg-toggle-off-hover checked:bg-toggle-on checked:hover:bg-toggle-on focus:ring focus:ring-toggle-on focus:ring-offset-4 border border-solid border-toggle-off-border checked:border-toggle-on-border shadow-toggleContainer focus:outline-none checked:focus:border-toggle-on-border focus:border-toggle-off-border',
input: 'bg-toggle-off hover:bg-toggle-off-hover checked:bg-toggle-on focus:ring focus:ring-toggle-on focus:ring-offset-4 checked:hover:bg-toggle-on border border-solid border-toggle-off-border checked:border-toggle-on-border shadow-toggleContainer focus:outline-none checked:focus:border-toggle-on-border focus:border-toggle-off-border',
toggleDial: 'bg-toggle-dial-background shadow-toggleDial',
},
};

const sizeClassNames = {
lg: {
container: 'w-11 h-6',
toggleDial:
'size-4 top-2/4 left-1 -translate-y-2/4 peer-checked:translate-x-5 before:w-10 before:h-10 before:rounded-full before:absolute before:top-2/4 before:left-2/4 before:-translate-y-2/4 before:-translate-x-2/4',
toggleDial: 'size-4 peer-checked:translate-x-5',
},
md: {
container: 'w-10 h-5',
toggleDial:
'size-3 top-2/4 left-1 -translate-y-2/4 peer-checked:translate-x-5 before:w-10 before:h-10 before:rounded-full before:absolute before:top-2/4 before:left-2/4 before:-translate-y-2/4 before:-translate-x-2/4',
toggleDial: 'size-3 peer-checked:translate-x-5',
},
sm: {
container: 'w-8 h-4',
toggleDial:
'size-2.5 top-2/4 left-1 -translate-y-2/4 peer-checked:translate-x-4 before:w-10 before:h-10 before:rounded-full before:absolute before:top-2/4 before:left-2/4 before:-translate-y-2/4 before:-translate-x-2/4',
toggleDial: 'size-2.5 peer-checked:translate-x-3.5',
},
};

Expand Down Expand Up @@ -178,7 +175,7 @@ const SwitchComponent = (
<label
htmlFor={ switchId }
className={ cn(
"bg-white border border-blue-gray-100 rounded-full absolute cursor-pointer shadow-md before:content[''] before:transition-opacity before:opacity-0 hover:before:opacity-10 before:hidden border-none transition-all duration-300",
"bg-white border border-blue-gray-100 rounded-full absolute cursor-pointer shadow-md before:content[''] before:transition-opacity before:opacity-0 hover:before:opacity-10 before:hidden border-none transition-all duration-300 top-2/4 left-1 -translate-y-2/4 before:w-10 before:h-10 before:rounded-full before:absolute before:top-2/4 before:left-2/4 before:-translate-y-2/4 before:-translate-x-2/4",
sizeClassNames[ size ].toggleDial,
colorClassNames[ color ].toggleDial,
disabled && disabledClassNames.toggleDial
Expand Down

0 comments on commit 24d3cb0

Please sign in to comment.