"use client"; import { useState } from "react"; import { Sun, Moon, Laptop, Check } from "lucide-react"; import { api } from "@/lib/client/api"; import { useUI } from "@/lib/client/store"; import { cn } from "@/lib/utils"; import { toast } from "@/components/ui/toast"; import { applyPrefs, type Prefs } from "./prefs"; import type { SettingsProfile } from "./SettingsView"; function Choice({ value, options, onChange }: { value: T; options: { id: T; label: string; hint?: string; icon?: React.ReactNode }[]; onChange: (v: T) => void }) { return
{options.map((o) => )}
; } export function AppearanceSection({ profile, refresh }: { profile: SettingsProfile; refresh: () => void }) { const ui = useUI(); const prefs = profile.preferences as Prefs; const [local, setLocal] = useState({ density: prefs.density ?? "comfortable", editorFont: prefs.editorFont ?? "sans", defaultSection: prefs.defaultSection ?? "notes" }); async function set(p: Prefs) { const next = { ...local, ...p }; setLocal(next); applyPrefs(next); try { await api("/api/settings", { method: "PATCH", json: { preferences: p } }); refresh(); } catch (e: any) { toast("Could not save preference", { description: e.message, tone: "danger" }); } } const Row = ({ title, hint, children }: { title: string; hint: string; children: React.ReactNode }) =>

{title}

{hint}

{children}
; return (
ui.setTheme(t)} options={[{ id: "system", label: "System", hint: "Follow macOS / iOS", icon: }, { id: "light", label: "Light", icon: }, { id: "dark", label: "Dark", icon: }]} /> set({ density })} options={[{ id: "comfortable", label: "Comfortable", hint: "16 px base" }, { id: "compact", label: "Compact", hint: "15 px base" }]} /> set({ editorFont })} options={[{ id: "sans", label: "Sans", hint: "Inter", icon: Aa }, { id: "serif", label: "Serif", hint: "Source Serif", icon: Aa }]} /> set({ defaultSection })} options={[{ id: "notes", label: "My Notes" }, { id: "documents", label: "Documents" }, { id: "projects", label: "Projects" }, { id: "research", label: "Research" }]} />
); }