|
| 1 | +import { Settings } from 'lucide-react'; |
| 2 | +import { Button } from '@/components/ui/button'; |
| 3 | +import { |
| 4 | + Sheet, |
| 5 | + SheetContent, |
| 6 | + SheetDescription, |
| 7 | + SheetHeader, |
| 8 | + SheetTitle, |
| 9 | + SheetTrigger, |
| 10 | +} from '@/components/ui/sheet'; |
| 11 | + |
| 12 | +import { useTheme } from '@/hooks/use-theme'; |
| 13 | +import type { ThemeScheme, ThemeColor } from '@/hooks/use-theme'; |
| 14 | + |
| 15 | +const schemes: ThemeScheme[] = ['light', 'dark', 'system']; |
| 16 | +const colors: ThemeColor[] = [ |
| 17 | + 'neutral', |
| 18 | + 'red', |
| 19 | + 'blue', |
| 20 | + 'green', |
| 21 | + 'amber', |
| 22 | + 'rose', |
| 23 | + 'purple', |
| 24 | + 'orange', |
| 25 | + 'teal', |
| 26 | + 'yellow', |
| 27 | + 'violet', |
| 28 | +]; |
| 29 | + |
| 30 | +export function SettingDrawer() { |
| 31 | + const { scheme, setScheme, color, setColor } = useTheme(); |
| 32 | + |
| 33 | + return ( |
| 34 | + <Sheet> |
| 35 | + <SheetTrigger asChild> |
| 36 | + <Button |
| 37 | + size='icon' |
| 38 | + variant='outline' |
| 39 | + aria-label='Open settings' |
| 40 | + aria-describedby='config-drawer-description' |
| 41 | + className='rounded-full fixed right-4 top-40 z-40' |
| 42 | + > |
| 43 | + <Settings aria-hidden='true' /> |
| 44 | + </Button> |
| 45 | + </SheetTrigger> |
| 46 | + <SheetContent className='flex flex-col'> |
| 47 | + <SheetHeader className='pb-0 text-start'> |
| 48 | + <SheetTitle>Settings</SheetTitle> |
| 49 | + <SheetDescription className='text-sm text-muted-foreground'> |
| 50 | + Configure your preferences for the application. |
| 51 | + </SheetDescription> |
| 52 | + </SheetHeader> |
| 53 | + <div className='space-y-6 overflow-y-auto px-4'> |
| 54 | + <div> |
| 55 | + <div className='font-semibold'>Scheme:</div> |
| 56 | + <div className='mt-4 grid grid-cols-3 gap-3'> |
| 57 | + {schemes.map((s) => ( |
| 58 | + <Button |
| 59 | + key={s} |
| 60 | + variant='outline' |
| 61 | + className='capitalize' |
| 62 | + onClick={() => setScheme(s)} |
| 63 | + > |
| 64 | + {s} |
| 65 | + </Button> |
| 66 | + ))} |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + <div> |
| 70 | + <div className='font-semibold'>Theme:</div> |
| 71 | + <div className='mt-4 grid grid-cols-3 gap-3'> |
| 72 | + {colors.map((c) => ( |
| 73 | + <Button |
| 74 | + key={c} |
| 75 | + variant='outline' |
| 76 | + onClick={() => setColor(c)} |
| 77 | + > |
| 78 | + {c} |
| 79 | + </Button> |
| 80 | + ))} |
| 81 | + </div> |
| 82 | + </div> |
| 83 | + </div> |
| 84 | + </SheetContent> |
| 85 | + </Sheet> |
| 86 | + ); |
| 87 | +} |
0 commit comments