Adapt redux

Add hover-effect on nodes
Add Setting drawer
Ass auto expansion setting
This commit is contained in:
Thomas Nordquist
2019-01-07 22:47:22 +01:00
parent e945721221
commit e72696dc57
21 changed files with 2667 additions and 139 deletions

50
app/src/reducers/index.ts Normal file
View File

@@ -0,0 +1,50 @@
import { Reducer, Action } from 'redux'
export enum ActionTypes {
setAutoExpandLimit = 'SET_AUTO_EXPAND_LIMIT',
toggleSettingsVisibility = 'TOGGLE_SETTINGS_VISIBILITY',
}
interface SettingsAction extends Action {
type: ActionTypes,
autoExpandLimit: number
}
export interface AppState {
settings: SettingsModel
}
export interface SettingsModel {
autoExpandLimit: number
visible: boolean
}
const reducer: Reducer<AppState | undefined, SettingsAction> = (state, action) => {
if (!state) {
throw Error('No initial state')
}
console.log(action)
switch (action.type) {
case ActionTypes.setAutoExpandLimit:
return {
...state,
settings: {
visible: state.settings.visible,
autoExpandLimit: action.autoExpandLimit,
},
}
case ActionTypes.toggleSettingsVisibility:
return {
...state,
settings: {
visible: !state.settings.visible,
autoExpandLimit: state.settings.autoExpandLimit,
},
}
default:
return state
}
}
export default reducer