"use client"; import { useTranslations } from 'next-intl'; import { useThemeStore } from '@/stores/theme-store'; import { useSettingsStore, type ToolbarPosition, type Density } from '@/stores/settings-store'; import { LanguageSwitcher } from '@/components/ui/language-switcher'; import { SettingsSection, SettingItem, RadioGroup, ToggleSwitch } from './settings-section'; import { cn } from '@/lib/utils'; import { useTour } from '@/components/tour/tour-provider'; import { Button } from '@/components/ui/button'; import { PlayCircle } from 'lucide-react'; import { usePolicyStore } from '@/stores/policy-store'; const DENSITY_PREVIEW: Record = { 'extra-compact': { py: 'py-0.5', gap: 'gap-1.5', showAvatar: false, showPreview: false }, compact: { py: 'py-1', gap: 'gap-2', showAvatar: true, showPreview: false }, regular: { py: 'py-2.5', gap: 'gap-3', showAvatar: true, showPreview: true }, comfortable: { py: 'py-4', gap: 'gap-4', showAvatar: true, showPreview: true }, }; function DensityPreview({ density }: { density: Density }) { const cfg = DENSITY_PREVIEW[density]; const rows = [ { unread: true, sender: 'Alice Johnson', subject: 'Project update — Q1 roadmap', preview: 'Here are the latest numbers from…' }, { unread: false, sender: 'Bob Smith', subject: 'Re: Meeting notes', preview: 'Thanks, will review and get back...' }, { unread: true, sender: 'Carol Lee', subject: 'Invoice #4092', preview: 'Please find attached the invoice…' }, ]; return (
{rows.map((row, i) => (
{cfg.showAvatar && (
)}
{row.sender} 12:00
{row.subject}
{cfg.showPreview && (
{row.preview}
)}
))}
); } export function AppearanceSettings() { const t = useTranslations('settings.appearance'); const tTour = useTranslations('tour'); const { theme, setTheme } = useThemeStore(); const { fontSize, density, animationsEnabled, toolbarPosition, showToolbarLabels, hideAccountSwitcher, showRailAccountList, updateSetting } = useSettingsStore(); const { startTour, resetTourCompletion } = useTour(); const { isSettingLocked, isSettingHidden } = usePolicyStore(); return ( {/* Theme */} setTheme(value as 'light' | 'dark' | 'system')} options={[ { value: 'light', label: t('theme.light') }, { value: 'dark', label: t('theme.dark') }, { value: 'system', label: t('theme.system') }, ]} /> {/* Language */} {/* Font Size */} {!isSettingHidden('fontSize') && ( updateSetting('fontSize', value as 'small' | 'medium' | 'large')} options={[ { value: 'small', label: t('font_size.small') }, { value: 'medium', label: t('font_size.medium') }, { value: 'large', label: t('font_size.large') }, ]} /> )} {/* Density */} {!isSettingHidden('density') && ( updateSetting('density', value as Density) } options={[ { value: 'extra-compact', label: t('list_density.extra_compact') }, { value: 'compact', label: t('list_density.compact') }, { value: 'regular', label: t('list_density.regular') }, { value: 'comfortable', label: t('list_density.comfortable') }, ]} /> )} {/* Toolbar Position */} updateSetting('toolbarPosition', value as ToolbarPosition)} options={[ { value: 'top', label: t('toolbar_position.top') }, { value: 'below-subject', label: t('toolbar_position.below_subject') }, ]} /> {/* Toolbar Labels */} updateSetting('showToolbarLabels', checked)} /> {/* Hide Account Switcher */} updateSetting('hideAccountSwitcher', checked)} /> {/* Show Rail Account List */} updateSetting('showRailAccountList', checked)} /> {/* Animations */} {!isSettingHidden('animationsEnabled') && ( updateSetting('animationsEnabled', checked)} /> )} {/* Restart Tour */} ); }