2022-05-12 08:55:28 +00:00
|
|
|
import { ToggleButton, ToggleButtonGroup } from '@mui/material';
|
|
|
|
import React from 'react';
|
|
|
|
import DarkModeIcon from '@mui/icons-material/DarkMode';
|
|
|
|
import LightModeIcon from '@mui/icons-material/LightMode';
|
2023-01-16 09:17:37 +00:00
|
|
|
import { THEME_COLOR } from 'constants/theme';
|
2022-05-12 08:55:28 +00:00
|
|
|
interface Iprops {
|
2023-04-12 07:33:23 +00:00
|
|
|
themeColor: THEME_COLOR;
|
|
|
|
setThemeColor: (theme: THEME_COLOR) => void;
|
2022-05-12 08:55:28 +00:00
|
|
|
}
|
2023-04-12 07:33:23 +00:00
|
|
|
export default function ThemeSwitcher({ themeColor, setThemeColor }: Iprops) {
|
|
|
|
const handleChange = (event, themeColor: THEME_COLOR) => {
|
|
|
|
if (themeColor !== null) {
|
|
|
|
setThemeColor(themeColor);
|
2022-05-12 10:48:00 +00:00
|
|
|
}
|
2022-05-12 08:55:28 +00:00
|
|
|
};
|
2022-05-12 07:39:05 +00:00
|
|
|
|
2022-05-12 08:55:28 +00:00
|
|
|
return (
|
|
|
|
<ToggleButtonGroup
|
|
|
|
size="small"
|
2023-04-12 07:33:23 +00:00
|
|
|
value={themeColor}
|
2022-05-12 08:55:28 +00:00
|
|
|
exclusive
|
|
|
|
onChange={handleChange}>
|
2023-01-16 09:17:37 +00:00
|
|
|
<ToggleButton value={THEME_COLOR.LIGHT}>
|
2022-05-12 08:55:28 +00:00
|
|
|
<LightModeIcon />
|
|
|
|
</ToggleButton>
|
2023-01-16 09:17:37 +00:00
|
|
|
<ToggleButton value={THEME_COLOR.DARK}>
|
2022-05-12 08:55:28 +00:00
|
|
|
<DarkModeIcon />
|
|
|
|
</ToggleButton>
|
|
|
|
</ToggleButtonGroup>
|
|
|
|
);
|
2022-05-12 07:39:05 +00:00
|
|
|
}
|