import { useTranslation } from "react-i18next"; import { toast } from "sonner"; import { Select2 } from "@/components/select2"; import { chooseDefaultLook, chooseLayout, useLookState, } from "@/look/look-store"; import { layoutLabel, useLayouts } from "@/look/layout-registry"; import { themeLabel, useThemes } from "@/look/theme-registry"; const selectClass = "w-full px-2.5 py-1.5 text-xs bg-background border border-border text-foreground outline-none focus:ring-1 focus:ring-ring appearance-none pr-7"; /** * The layout picker, plus the default layout and theme for everyone when an * admin is looking. Lists what the layout and theme registries hold, so * plugin layouts and themes show up as soon as they are installed. */ export function LookSettings({ isAdmin }: { isAdmin: boolean }) { const { t } = useTranslation(); const look = useLookState(); const layouts = useLayouts(); const themes = useThemes(); const response = look.response; const failed = () => toast.error(t("looks.saveFailed")); return (
void chooseLayout(e.target.value || null).catch(failed) } className={selectClass} > {layouts.map((layout) => ( ))}

{t("looks.layoutHint")}

{isAdmin && response && (
{t("looks.defaultsLabel")}

{t("looks.defaultsHint")}

void chooseDefaultLook({ layout: e.target.value || null }) .then(() => toast.success(t("looks.defaultSaved"))) .catch(failed) } className={selectClass} > {layouts.map((layout) => ( ))} void chooseDefaultLook({ theme: e.target.value || null }) .then(() => toast.success(t("looks.defaultSaved"))) .catch(failed) } className={selectClass} > {themes.map((theme) => ( ))}
)}
); }