2
0
mirror of https://github.com/hibiken/asynqmon.git synced 2025-10-26 08:16:10 +08:00

add dark theme preference

This commit is contained in:
Peizhi Zheng
2021-01-13 12:02:53 -08:00
parent e7cfbc6bf7
commit 54d1efc6d8
6 changed files with 74 additions and 55 deletions

View File

@@ -1,17 +1,22 @@
import {
POLL_INTERVAL_CHANGE,
SettingsActionTypes,
TOGGLE_DARK_THEME,
SELECT_THEME,
} from "../actions/settingsActions";
export enum themeKind {
SystemDefault = "SYETEM DEFAULT",
Always = "ALWAYS",
Never = "NEVER",
}
interface SettingsState {
pollInterval: number;
isDarkTheme: boolean;
themePreference: themeKind;
}
const initialState: SettingsState = {
pollInterval: 8,
isDarkTheme: true,
themePreference: themeKind.SystemDefault,
};
function settingsReducer(
@@ -21,10 +26,10 @@ function settingsReducer(
switch (action.type) {
case POLL_INTERVAL_CHANGE:
return { ...state, pollInterval: action.value };
case TOGGLE_DARK_THEME:
case SELECT_THEME:
return {
...state,
isDarkTheme: !state.isDarkTheme,
themePreference: action.value,
};
default:
return state;