import * as React from "react"; import { useTranslation } from "react-i18next"; import { CUSTOM_CSS_VAR_COLORS } from "~/constants"; import { Button } from "./Button"; import { Label } from "./Label"; type CustomColorsRecord = Partial< Record<(typeof CUSTOM_CSS_VAR_COLORS)[number], string> >; export function CustomizedColorsInput({ initialColors, }: { initialColors?: Record | null; }) { const { t } = useTranslation(); const [colors, setColors] = React.useState( initialColors ?? {}, ); return (
{CUSTOM_CSS_VAR_COLORS.filter((cssVar) => cssVar !== "bg-lightest").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}`} />
); }, )}
); }