bruno/renderer/providers/ReduxStore/slices/app.js

43 lines
1.0 KiB
JavaScript
Raw Normal View History

import { createSlice } from '@reduxjs/toolkit'
const initialState = {
2022-03-22 13:48:20 +01:00
isDragging: false,
idbConnectionReady: false,
2022-03-22 13:48:20 +01:00
leftSidebarWidth: 270,
leftMenuBarOpen: true,
screenWidth: 500
};
export const appSlice = createSlice({
name: 'app',
initialState,
reducers: {
2022-03-22 13:48:20 +01:00
idbConnectionReady: (state) => {
state.idbConnectionReady = true;
},
toggleLeftMenuBar: (state) => {
state.leftMenuBarOpen = !state.leftMenuBarOpen;
state.leftSidebarWidth = state.leftMenuBarOpen ? 270 : 222;
},
2022-03-22 13:48:20 +01:00
refreshScreenWidth: (state) => {
state.screenWidth = window.innerWidth;
},
updateLeftSidebarWidth: (state, action) => {
state.leftSidebarWidth = action.payload.leftSidebarWidth;
},
updateIsDragging: (state, action) => {
state.isDragging = action.payload.isDragging;
},
}
});
2022-03-22 13:48:20 +01:00
export const {
idbConnectionReady,
toggleLeftMenuBar,
refreshScreenWidth,
updateLeftSidebarWidth,
updateIsDragging
} = appSlice.actions;
export default appSlice.reducer;