AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

appearance-tabs.tsx 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 {
  7. TabLabel,
  8. tabClass,
  9. tabRowClass,
  10. } from '@/components/stores/section-tabs';
  11. import { cn } from '@/lib/utils';
  12. export default function AppearanceToggleTab({
  13. className = '',
  14. ...props
  15. }: HTMLAttributes<HTMLDivElement>) {
  16. const { appearance, updateAppearance } = useAppearance();
  17. const tabs: { value: Appearance; icon: LucideIcon; label: string }[] = [
  18. { value: 'light', icon: Sun, label: 'Light' },
  19. { value: 'dark', icon: Moon, label: 'Dark' },
  20. { value: 'system', icon: Monitor, label: 'System' },
  21. ];
  22. return (
  23. <div
  24. role="radiogroup"
  25. aria-label="Appearance"
  26. className={cn(tabRowClass, 'inline-flex max-w-full', className)}
  27. {...props}
  28. >
  29. {tabs.map(({ value, icon, label }) => (
  30. <button
  31. key={value}
  32. type="button"
  33. role="radio"
  34. aria-checked={appearance === value}
  35. onClick={() => updateAppearance(value)}
  36. className={tabClass(appearance === value)}
  37. >
  38. <TabLabel
  39. icon={icon}
  40. label={label}
  41. selected={appearance === value}
  42. />
  43. </button>
  44. ))}
  45. </div>
  46. );
  47. }