({ checked, onChange, size = 'md' }: ToggleProps)
| 5 | } |
| 6 | |
| 7 | export function Toggle({ checked, onChange, size = 'md' }: ToggleProps) { |
| 8 | const track = size === 'sm' ? 'w-8 h-[18px]' : 'w-10 h-[22px]' |
| 9 | const thumb = size === 'sm' ? 'w-3 h-3 bottom-[2.5px] left-[3px]' : 'w-4 h-4 bottom-[3px] left-[3px]' |
| 10 | const translate = size === 'sm' ? 'translate-x-[14px]' : 'translate-x-[18px]' |
| 11 | |
| 12 | return ( |
| 13 | <button |
| 14 | role="switch" |
| 15 | aria-checked={checked} |
| 16 | onClick={() => onChange(!checked)} |
| 17 | className={`relative rounded-full cursor-pointer transition-colors ${track} ${ |
| 18 | checked ? 'bg-accent' : 'bg-bg-tertiary' |
| 19 | }`} |
| 20 | > |
| 21 | <span |
| 22 | className={`absolute rounded-full transition-all ${thumb} ${ |
| 23 | checked ? `${translate} bg-white` : 'bg-text-muted' |
| 24 | }`} |
| 25 | /> |
| 26 | </button> |
| 27 | ) |
| 28 | } |
nothing calls this directly
no outgoing calls
no test coverage detected