"use client"; import { useMemo, useState } from "react"; import { buildThemeCss, type ThemeInput } from "@/lib/tools/theme"; import { CodeOutput } from "@/components/tools/CodeOutput"; const FIELDS: { key: keyof ThemeInput; label: string }[] = [ { key: "background", label: "Фон" }, { key: "text", label: "Текст" }, { key: "accent", label: "Акцент" }, { key: "link", label: "Ссылки" }, { key: "border", label: "Рамка" }, ]; const fieldStyle = { border: "1px solid var(--border)", borderRadius: "2px", backgroundColor: "var(--background)", color: "var(--foreground)" } as const; export function ThemeForm() { const [theme, setTheme] = useState({ background: "#0F0F0F", text: "#EAEAEA", accent: "#7C3AED", link: "#4EA1FF", border: "#333333", }); const css = useMemo(() => buildThemeCss(theme), [theme]); function update(key: keyof ThemeInput, value: string) { setTheme((prev) => ({ ...prev, [key]: value })); } return (
{FIELDS.map((f) => ( ))}
Превью темы. e.preventDefault()} style={{ color: theme.link }}>ссылка,{" "} акцент.
); }