AppearanceTabs.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { LucideIcon, Monitor, Moon, Sun } from 'lucide-react';
  2. import { HTMLAttributes } from 'react';
  3. import { cn } from '@/common/helpers/cn';
  4. import { Appearance, useAppearance } from '@/common/hooks/useAppearance';
  5. export function AppearanceTabs({ className = '', ...props }: HTMLAttributes<HTMLDivElement>) {
  6. const { appearance, updateAppearance } = useAppearance();
  7. const tabs: { value: Appearance; icon: LucideIcon; label: string }[] = [
  8. { value: 'light', icon: Sun, label: 'Light' },
  9. { value: 'dark', icon: Moon, label: 'Dark' },
  10. { value: 'system', icon: Monitor, label: 'System' },
  11. ];
  12. return (
  13. <div className={cn('inline-flex gap-1 rounded-lg bg-neutral-100 p-1 dark:bg-neutral-800', className)} {...props}>
  14. {tabs.map(({ value, icon: Icon, label }) => (
  15. <button
  16. key={value}
  17. onClick={() => updateAppearance(value)}
  18. className={cn(
  19. 'flex items-center rounded-md px-3.5 py-1.5 transition-colors',
  20. appearance === value
  21. ? 'bg-white shadow-xs dark:bg-neutral-700 dark:text-neutral-100'
  22. : 'text-neutral-500 hover:bg-neutral-200/60 hover:text-black dark:text-neutral-400 dark:hover:bg-neutral-700/60',
  23. )}
  24. >
  25. <Icon className="-ml-1 h-4 w-4" />
  26. <span className="ml-1.5 text-sm">{label}</span>
  27. </button>
  28. ))}
  29. </div>
  30. );
  31. }