2023-10-17 07:16:38 +00:00
|
|
|
import { FC } from "react";
|
2023-05-11 13:10:17 +00:00
|
|
|
// constants
|
2023-10-17 07:16:38 +00:00
|
|
|
import { THEME_OPTIONS, I_THEME_OPTION } from "constants/themes";
|
2023-05-11 13:10:17 +00:00
|
|
|
// ui
|
2023-10-19 09:54:51 +00:00
|
|
|
import { CustomSelect } from "@plane/ui";
|
2023-05-11 13:10:17 +00:00
|
|
|
|
|
|
|
type Props = {
|
2023-10-17 07:16:38 +00:00
|
|
|
value: I_THEME_OPTION | null;
|
|
|
|
onChange: (value: I_THEME_OPTION) => void;
|
2023-05-11 13:10:17 +00:00
|
|
|
};
|
2023-04-20 08:11:24 +00:00
|
|
|
|
2023-10-17 07:16:38 +00:00
|
|
|
export const ThemeSwitch: FC<Props> = (props) => {
|
|
|
|
const { value, onChange } = props;
|
2023-08-10 07:33:42 +00:00
|
|
|
|
2023-10-17 07:16:38 +00:00
|
|
|
return (
|
|
|
|
<CustomSelect
|
|
|
|
value={value}
|
|
|
|
label={
|
|
|
|
value ? (
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
<div
|
|
|
|
className="border-1 relative flex h-4 w-4 rotate-45 transform items-center justify-center rounded-full border"
|
|
|
|
style={{
|
|
|
|
borderColor: value.icon.border,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
className="h-full w-1/2 rounded-l-full"
|
|
|
|
style={{
|
|
|
|
background: value.icon.color1,
|
|
|
|
}}
|
|
|
|
/>
|
2023-05-11 13:10:17 +00:00
|
|
|
<div
|
2023-10-17 07:16:38 +00:00
|
|
|
className="h-full w-1/2 rounded-r-full border-l"
|
2023-05-11 13:10:17 +00:00
|
|
|
style={{
|
2023-10-17 07:16:38 +00:00
|
|
|
borderLeftColor: value.icon.border,
|
|
|
|
background: value.icon.color2,
|
2023-05-11 13:10:17 +00:00
|
|
|
}}
|
2023-10-17 07:16:38 +00:00
|
|
|
/>
|
2023-05-11 13:10:17 +00:00
|
|
|
</div>
|
2023-10-17 07:16:38 +00:00
|
|
|
{value.label}
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
"Select your theme"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
onChange={onChange}
|
|
|
|
input
|
|
|
|
>
|
|
|
|
{THEME_OPTIONS.map((themeOption) => (
|
|
|
|
<CustomSelect.Option key={themeOption.value} value={themeOption}>
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
<div
|
|
|
|
className="border-1 relative flex h-4 w-4 rotate-45 transform items-center justify-center rounded-full border"
|
|
|
|
style={{
|
|
|
|
borderColor: themeOption.icon.border,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
className="h-full w-1/2 rounded-l-full"
|
|
|
|
style={{
|
|
|
|
background: themeOption.icon.color1,
|
|
|
|
}}
|
|
|
|
/>
|
2023-08-03 09:58:22 +00:00
|
|
|
<div
|
2023-10-17 07:16:38 +00:00
|
|
|
className="h-full w-1/2 rounded-r-full border-l"
|
2023-05-11 13:10:17 +00:00
|
|
|
style={{
|
2023-10-17 07:16:38 +00:00
|
|
|
borderLeftColor: themeOption.icon.border,
|
|
|
|
background: themeOption.icon.color2,
|
2023-05-11 13:10:17 +00:00
|
|
|
}}
|
2023-10-17 07:16:38 +00:00
|
|
|
/>
|
2023-05-11 13:10:17 +00:00
|
|
|
</div>
|
2023-10-17 07:16:38 +00:00
|
|
|
{themeOption.label}
|
|
|
|
</div>
|
|
|
|
</CustomSelect.Option>
|
|
|
|
))}
|
|
|
|
</CustomSelect>
|
|
|
|
);
|
|
|
|
};
|