Add theme toggle

This commit is contained in:
Thomas Nordquist
2019-04-03 01:55:57 +02:00
parent 84a92ad522
commit 6f86a8d471
6 changed files with 84 additions and 29 deletions

View File

@@ -1,6 +1,13 @@
import { ActionTypes } from '../reducers'
import { ActionTypes, AppState, CustomAction } from '../reducers'
import { Dispatch } from 'redux';
export const showError = (error?: string) => ({
error,
type: ActionTypes.showError,
})
export const toggleTheme = () => (dispatch: Dispatch<CustomAction>, getState: () => AppState) => {
dispatch({
type: getState().globalState.theme === 'light' ? ActionTypes.setDarkTheme : ActionTypes.setLightTheme,
})
}