AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

appearance-tabs.tsx 1.7KB

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