| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import type { LucideIcon } from 'lucide-react';
- import { Monitor, Moon, Sun } from 'lucide-react';
- import type { HTMLAttributes } from 'react';
- import type { Appearance } from '@/hooks/use-appearance';
- import { useAppearance } from '@/hooks/use-appearance';
- import {
- TabLabel,
- tabClass,
- tabRowClass,
- } from '@/components/stores/section-tabs';
- import { cn } from '@/lib/utils';
-
- export default function AppearanceToggleTab({
- className = '',
- ...props
- }: HTMLAttributes<HTMLDivElement>) {
- const { appearance, updateAppearance } = useAppearance();
-
- const tabs: { value: Appearance; icon: LucideIcon; label: string }[] = [
- { value: 'light', icon: Sun, label: 'Light' },
- { value: 'dark', icon: Moon, label: 'Dark' },
- { value: 'system', icon: Monitor, label: 'System' },
- ];
-
- return (
- <div
- role="radiogroup"
- aria-label="Appearance"
- className={cn(tabRowClass, 'inline-flex max-w-full', className)}
- {...props}
- >
- {tabs.map(({ value, icon, label }) => (
- <button
- key={value}
- type="button"
- role="radio"
- aria-checked={appearance === value}
- onClick={() => updateAppearance(value)}
- className={tabClass(appearance === value)}
- >
- <TabLabel
- icon={icon}
- label={label}
- selected={appearance === value}
- />
- </button>
- ))}
- </div>
- );
- }
|