Browse Source

feat(redux): add theme redux

master
farhantock 5 months ago
parent
commit
ec90e93b62
  1. 12
      src/appredux/modules/theme/actions.js
  2. 17
      src/appredux/modules/theme/reducers.js

12
src/appredux/modules/theme/actions.js

@ -0,0 +1,12 @@
export const SET_THEME = 'SET_THEME';
export const SET_SYSTEM_THEME = 'SET_SYSTEM_THEME';
export const setTheme = (theme) => ({
type: SET_THEME,
payload: theme,
});
export const setSystemTheme = (useSystemTheme) => ({
type: SET_SYSTEM_THEME,
payload: useSystemTheme,
});

17
src/appredux/modules/theme/reducers.js

@ -0,0 +1,17 @@
import { SET_THEME, SET_SYSTEM_THEME } from './actions';
const initialState = {
theme: '',
useSystemTheme: true,
};
export default function themeReducer(state = initialState, action) {
switch (action.type) {
case SET_THEME:
return { ...state, theme: action.payload }
case SET_SYSTEM_THEME:
return { ...state, useSystemTheme: action.payload }
default:
return state;
}
}
Loading…
Cancel
Save