File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4343 --color-grey : # f5f5f5 ;
4444 --color-red : # ff5255 ;
4545
46+ --color-gray-200 : # eaecf0 ;
47+
4648 --color-brand-burnt-orange : # da4a11 ;
4749 --color-brand-burnt-orange-100 : # f8dbcf ;
4850 --color-brand-burnt-orange-200 : # f3c3b0 ;
Original file line number Diff line number Diff line change 1+ import type { ComponentProps } from 'svelte' ;
2+ import Toggle from './Toggle.svelte' ;
3+
4+ export default {
5+ title : 'UI/Toggle' ,
6+ component : Toggle ,
7+ tags : [ 'autodocs' ] ,
8+ render : ( args : { Component : Toggle ; props : ComponentProps < typeof Toggle > } ) => ( {
9+ Component : Toggle ,
10+ props : args
11+ } )
12+ } ;
13+
14+ export const Primary = {
15+ args : { }
16+ } ;
Original file line number Diff line number Diff line change 1+ <script lang =" ts" >
2+ import { cn } from ' $lib/utils' ;
3+ import type { HTMLAttributes } from ' svelte/elements' ;
4+
5+ interface IToggleProps extends HTMLAttributes <HTMLElement > {
6+ checked: boolean ;
7+ }
8+
9+ let { checked = $bindable (false ), ... restProps }: IToggleProps = $props ();
10+
11+ let uniqueId = Math .random ().toString ().split (' .' )[1 ];
12+ </script >
13+
14+ <label
15+ {...restProps }
16+ for ={uniqueId }
17+ class ={cn ([" relative" ,restProps .class ].join (" " ))}
18+ aria-label ={restProps [' aria-label' ] || ' Toggle' }
19+ role =" switch"
20+ aria-checked ={checked }
21+ >
22+ <div
23+ class ={` h-6 w-11 rounded-full ${checked ? ' bg-brand-burnt-orange' : ' bg-gray-200' } transition duration-300 ` }
24+ >
25+ <div
26+ class ={` absolute top-0.5 left-0.5 h-5 w-5 rounded-full bg-white ${checked ? ' translate-x-5' : ' translate-x-0' } transition duration-300 ` }
27+ ></div >
28+ </div >
29+ </label >
30+
31+ <input id ={uniqueId } type =" checkbox" bind:checked class =" hidden" aria-hidden =" true" />
Original file line number Diff line number Diff line change 11export { default as Button } from './Button/Button.svelte' ;
22export { default as Avatar } from './Avatar/Avatar.svelte' ;
33export { default as Input } from './Input/Input.svelte' ;
4+ export { default as Toggle } from './Toggle/Toggle.svelte' ;
You can’t perform that action at this time.
0 commit comments