diff --git a/src/components/ThemeChanger.js b/src/components/ThemeChanger.js index 6a930be..454eb16 100644 --- a/src/components/ThemeChanger.js +++ b/src/components/ThemeChanger.js @@ -2,37 +2,62 @@ import { useDispatch, useSelector } from 'react-redux'; import { setTheme } from '../store/slices/themeSlice'; import config from '../config'; import { skeleton } from '../helpers/utils'; +import { IoColorPaletteOutline } from 'react-icons/io5'; +import { memo } from 'react'; const ThemeChanger = () => { const dispatch = useDispatch(); const theme = useSelector(state => state.theme); const loading = useSelector(state => state.loading); - const handleChange = (e) => { - dispatch(setTheme(e.target.value)); + const changeTheme = (e, selectedTheme) => { + e.preventDefault(); + dispatch(setTheme(selectedTheme)); } - + return ( -
+
- {loading ? skeleton({width: 'w-20', height: 'h-8'}) : 'Theme'} + {loading ? skeleton({ width: 'w-20', height: 'h-8' }) : 'Theme'}
- {loading ? skeleton({width: 'w-24', height: 'h-4'}) : 'Change Theme'} + {loading ? skeleton({ width: 'w-16', height: 'h-4' }) : (theme === config.themeConfig.default ? 'Default' : theme)}
{ - loading ? skeleton({width: 'w-28', height: 'h-10'}) : ( - + loading ? skeleton({ width: 'w-14 md:w-28', height: 'h-10' }) : ( +
+
+ + Change Theme + + + + +
+ +
) }
@@ -41,4 +66,4 @@ const ThemeChanger = () => { ) } -export default ThemeChanger; \ No newline at end of file +export default memo(ThemeChanger); \ No newline at end of file