ISSUE-017 - Overlay state is streamlined.

Total change to workspaces. Now an object instead of a list.
Utilizing workspace overlays list - prototype currently colors the mock item.
Reset overlay on workspace change.
Improved combined dragging/transition element behavior.
This commit is contained in:
Kyle Geib committed 2022-01-13 14:16:09 -05:00
1 parent a6a5eb7751
commit 861d702a27
11 files changed
+177 -150

No files matched your search

+20 -19
View File
@@ -2,27 +2,20 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import {
RootState,
WorkspaceId,
OverlayPosition,
OverlayId,
OverlayIds,
} from "../../types/state";
const initialState: RootState["overlayTool"] = {
currentWorkspaceId: "",
overlayIds: [],
currentOverlayId: null,
currentOverlayItem: null,
visible: false,
};
const makeNewOverlayItem = (
overlayId: OverlayId,
initialPosition: OverlayPosition,
) => ({
id: overlayId,
position: initialPosition,
opacity: 1,
scale: 1,
});
type InitNewOverlayItemAction = {
overlayId: OverlayId,
@@ -30,16 +23,21 @@ type InitNewOverlayItemAction = {
setVisible: boolean,
};
type NewWorkspaceAction = {
overlayIds: OverlayIds,
workspaceId: WorkspaceId,
}
export const overlayToolSlice = createSlice({
name: "overlayTool",
initialState,
reducers: {
initNewOverlayItem: (state, action: PayloadAction<InitNewOverlayItemAction>) => {
if (state.currentOverlayItem == null) {
state.currentOverlayItem = makeNewOverlayItem(
action.payload.overlayId,
action.payload.initialPosition,
);
state.currentOverlayItem = {
position: action.payload.initialPosition,
opacity: 1,
};
state.currentOverlayId = action.payload.overlayId;
state.visible = action.payload.setVisible;
}
@@ -47,16 +45,12 @@ export const overlayToolSlice = createSlice({
setVisibility: (state, action: PayloadAction<boolean>) => {
state.visible = action.payload;
},
setOverlayIds: (state, action: PayloadAction<Array<OverlayId>>) => {
state.overlayIds = action.payload;
},
setCurrentOverlayId: (state, action: PayloadAction<OverlayId>) => {
if (
action.payload !== state.currentOverlayId &&
state.currentOverlayItem != null
) {
state.currentOverlayId = action.payload;
state.currentOverlayItem.id = action.payload;
}
},
setPosition: (state, action: PayloadAction<OverlayPosition>) => {
@@ -64,14 +58,21 @@ export const overlayToolSlice = createSlice({
state.currentOverlayItem.position = action.payload;
}
},
newWorkspace: (state, action: PayloadAction<NewWorkspaceAction>) => {
state.currentOverlayId = null;
state.currentOverlayItem = null;
state.visible = false;
state.currentWorkspaceId = action.payload.workspaceId;
state.overlayIds = action.payload.overlayIds;
},
},
});
export const {
initNewOverlayItem,
setVisibility,
setOverlayIds,
setCurrentOverlayId,
setPosition,
newWorkspace,
} = overlayToolSlice.actions;
export default overlayToolSlice.reducer;