import { useTranslation } from "~/hooks/useTranslation"; import { Label } from "./Label"; import * as React from "react"; import { Button } from "./Button"; const CUSTOM_COLORS = [ "bg", "bg-darker", "bg-lighter", "text", "text-lighter", "theme", "chat", ] as const; type CustomColorsRecord = Partial< Record<(typeof CUSTOM_COLORS)[number], string> >; export function CustomizedColorsInput({ initialColors, }: { initialColors?: Record | null; }) { const { t } = useTranslation(); const [colors, setColors] = React.useState( initialColors ?? {}, ); return (
{CUSTOM_COLORS.map((cssVar) => { return (
{t(`custom.colors.${cssVar}`)}
{ const extras: Record = {}; if (cssVar === "bg-lighter") { extras["bg-lightest"] = `${e.target.value}80`; } setColors({ ...colors, ...extras, [cssVar]: e.target.value }); }} data-testid={`color-input-${cssVar}`} />
); })}
); }