import { FC } from "react"; import { useTheme } from "next-themes"; import { Controller, useForm } from "react-hook-form"; // ui import { Button, InputColorPicker } from "@plane/ui"; // types import { IUserTheme } from "types"; // mobx react lite import { observer } from "mobx-react-lite"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; type Props = {}; export const CustomThemeSelector: FC = observer(() => { const { user: userStore } = useMobxStore(); const userTheme = userStore?.currentUser?.theme; // hooks const { setTheme } = useTheme(); const { formState: { errors, isSubmitting }, handleSubmit, control, } = useForm({ defaultValues: { background: userTheme?.background !== "" ? userTheme?.background : "#0d101b", text: userTheme?.text !== "" ? userTheme?.text : "#c5c5c5", primary: userTheme?.primary !== "" ? userTheme?.primary : "#3f76ff", sidebarBackground: userTheme?.sidebarBackground !== "" ? userTheme?.sidebarBackground : "#0d101b", sidebarText: userTheme?.sidebarText !== "" ? userTheme?.sidebarText : "#c5c5c5", darkPalette: userTheme?.darkPalette || false, palette: userTheme?.palette !== "" ? userTheme?.palette : "", }, }); const handleUpdateTheme = async (formData: any) => { const payload: IUserTheme = { background: formData.background, text: formData.text, primary: formData.primary, sidebarBackground: formData.sidebarBackground, sidebarText: formData.sidebarText, darkPalette: false, palette: `${formData.background},${formData.text},${formData.primary},${formData.sidebarBackground},${formData.sidebarText}`, theme: "custom", }; setTheme("custom"); return userStore.updateCurrentUser({ theme: payload }); }; return (

Customize your theme

Background color

( )} />

Text color

( )} />

Primary(Theme) color

( )} />

Sidebar background color

( )} />

Sidebar text color

( )} />
); });