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,23 @@
import { createSlice } from '@reduxjs/toolkit';
import { getThemeValue } from '../../helpers/utils';
const initialState = getThemeValue();
export const themeSlice = createSlice({
name: 'theme',
initialState: initialState,
reducers: {
setTheme: (state, action) => {
state = action.payload;
document.documentElement.setAttribute('data-theme', state);
localStorage.setItem('theme', state);
return state;
}
}
})
export const { setTheme } = themeSlice.actions;
export default themeSlice.reducer;

View File

@@ -1,8 +1,10 @@
import { combineReducers, configureStore } from '@reduxjs/toolkit';
import profileSlice from './slices/profileSlice';
import themeSlice from './slices/themeSlice';
const rootReducer = combineReducers({
profile: profileSlice
profile: profileSlice,
theme: themeSlice,
})
export const store = configureStore({