/** * Switch style tokens. * * Kept in a separate module from the component so the file only exports * components — mixing the two breaks Vite's fast refresh. */ export type SwitchSize = 'sm' | 'md' | 'lg' export type SwitchColor = 'blue' | 'red' | 'green' | 'yellow' | 'teal' | 'indigo' | 'purple' | 'pink' export type SwitchSizeData = { /** Track pill. */ toggle: string /** Knob, including its resting offset from the track edge. */ dot: string /** Travel distance of the knob when checked. */ translate: string } /** * Every knob sits on a fixed 0.25rem inset from the track edge, so it can never * render outside the pill. Travel = trackWidth - knobWidth - (2 * inset). */ export const SWITCH_SIZES: Record = { sm: { toggle: 'w-10 h-6 shrink-0', dot: 'w-4 h-4 left-1', translate: 'translate-x-4' }, md: { toggle: 'w-12 h-7 shrink-0', dot: 'w-5 h-5 left-1', translate: 'translate-x-5' }, lg: { toggle: 'w-[3.75rem] h-8 shrink-0', dot: 'w-6 h-6 left-1', translate: 'translate-x-7' }, } export const SWITCH_COLORS: Record = { blue: 'bg-primary-500', red: 'bg-red-500', green: 'bg-green-500', yellow: 'bg-yellow-500', teal: 'bg-teal-500', indigo: 'bg-indigo-500', purple: 'bg-purple-500', pink: 'bg-pink-500', }