Change theme

This commit is contained in:
MD. Ariful Alam
2021-08-21 15:27:39 +06:00
parent 0229b5e453
commit e6935a32b9
13 changed files with 2563 additions and 109 deletions

View File

@@ -0,0 +1,30 @@
import { Fragment } from 'react';
import { Select } from 'antd';
import { useDispatch, useSelector } from 'react-redux';
import { setTheme } from '../store/slices/themeSlice';
import config from '../config';
const { Option } = Select;
const ThemeChanger = () => {
const dispatch = useDispatch();
const theme = useSelector(state => state.theme);
const handleChange = (value) => {
dispatch(setTheme(value));
}
return (
<Select defaultValue="lucy" style={{ width: 120 }} onChange={handleChange} bordered={false} value={theme}>
{
config.themes.map((item, index) => (
<Option key={index} value={item}>
<span className="capitalize text-base-content text-opacity-60">{item === config.defaultTheme ? 'Default' : item}</span>
</Option>
))
}
</Select>
)
}
export default ThemeChanger;