ISSUE-017 - Improvements to a number of things.
* Moved FullScreenContainer in WorkspacesRoute to make scrolling much better. Seriously, 100% works better. * Simplified dimensions state actions to a shared one. * Abandoned the noisy and useless "AnimatedBG" type. * Added workspace dimensions state (I'll need this later to prevent off-screen dragging). * Placed OverlayDisplay component in PreviewWindow, where it makes more sense. I'll still allow it to roam around outside of it, though. * Renamed "menu" dimensions to "mainMenu". * Improved initNewOverlayItem action to support setting visible. * Correct handling of showing the OverlayItemContainer. * Simplified the initial position of a new OverlayItem to a simple initial value instead of setting it in the middle of provided dimensions. * Made PreviewWindow `position: relative` to allow absolute positioning of OverlayItem from it. * Added importHelpers to tsconfig because VSCode was complaining about it.
This commit is contained in:
1 parent
506491eed9
commit
61b60b9819
16 files changed
+113
-76
No files matched your search
@@ -4,7 +4,6 @@ import {
|
||||
RootState,
|
||||
OverlayPosition,
|
||||
OverlayId,
|
||||
AppDimensions,
|
||||
} from "../../types/state";
|
||||
|
||||
const initialState: RootState["overlayTool"] = {
|
||||
@@ -16,13 +15,10 @@ const initialState: RootState["overlayTool"] = {
|
||||
|
||||
const makeNewOverlayItem = (
|
||||
overlayId: OverlayId,
|
||||
appDimensions: AppDimensions,
|
||||
initialPosition: OverlayPosition,
|
||||
) => ({
|
||||
id: overlayId,
|
||||
position: {
|
||||
x: appDimensions.width / 2,
|
||||
y: appDimensions.height / 2,
|
||||
},
|
||||
position: initialPosition,
|
||||
opacity: 1,
|
||||
scale: 1,
|
||||
});
|
||||
@@ -30,7 +26,8 @@ const makeNewOverlayItem = (
|
||||
|
||||
type InitNewOverlayItemAction = {
|
||||
overlayId: OverlayId,
|
||||
appDimensions: AppDimensions,
|
||||
initialPosition: OverlayPosition,
|
||||
setVisible: boolean,
|
||||
};
|
||||
|
||||
export const overlayToolSlice = createSlice({
|
||||
@@ -41,9 +38,10 @@ export const overlayToolSlice = createSlice({
|
||||
if (state.currentOverlayItem == null) {
|
||||
state.currentOverlayItem = makeNewOverlayItem(
|
||||
action.payload.overlayId,
|
||||
action.payload.appDimensions,
|
||||
action.payload.initialPosition,
|
||||
);
|
||||
state.currentOverlayId = action.payload.overlayId;
|
||||
state.visible = action.payload.setVisible;
|
||||
}
|
||||
},
|
||||
setVisibility: (state, action: PayloadAction<boolean>) => {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { RootState } from "../../types/state";
|
||||
|
||||
export const menuDimensionsSelector = (state: RootState) =>
|
||||
state.pageDimensions.menu;
|
||||
export const mainMenuDimensionsSelector = (state: RootState) =>
|
||||
state.pageDimensions.mainMenu;
|
||||
export const appDimensionsSelector = (state: RootState) =>
|
||||
state.pageDimensions.app;
|
||||
export const workspaceDimensionsSelector = (state: RootState) =>
|
||||
state.pageDimensions.workspace;
|
||||
@@ -1,29 +1,27 @@
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
import { RootState, MenuDimensions, AppDimensions } from "../../types/state";
|
||||
import { RootState, Dimensions } from "../../types/state";
|
||||
|
||||
const initialState: RootState["pageDimensions"] = {
|
||||
menu: {
|
||||
height: 0,
|
||||
},
|
||||
app: {
|
||||
height: 0,
|
||||
width: 0,
|
||||
},
|
||||
mainMenu: { height: 0, width: 0 },
|
||||
app: { height: 0, width: 0 },
|
||||
workspace: { height: 0, width: 0 },
|
||||
};
|
||||
|
||||
type SetDimensionsAction = {
|
||||
name: "mainMenu" | "app" | "workspace",
|
||||
dimensions: Dimensions,
|
||||
};
|
||||
|
||||
export const pageDimensionsSlice = createSlice({
|
||||
name: "pageDimensions",
|
||||
initialState,
|
||||
reducers: {
|
||||
setMenuDimensions: (state, action: PayloadAction<MenuDimensions>) => {
|
||||
state.menu = action.payload;
|
||||
},
|
||||
setAppDimensions: (state, action: PayloadAction<AppDimensions>) => {
|
||||
state.app = action.payload;
|
||||
setDimensions: (state, action: PayloadAction<SetDimensionsAction>) => {
|
||||
state[action.payload.name] = action.payload.dimensions;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setMenuDimensions, setAppDimensions } = pageDimensionsSlice.actions;
|
||||
export const { setDimensions } = pageDimensionsSlice.actions;
|
||||
export default pageDimensionsSlice.reducer;
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import { RootState, WorkspaceId, AnimatedBG } from "../../types/state";
|
||||
import { RootState, WorkspaceId } from "../../types/state";
|
||||
|
||||
const initialState: RootState["workspace"] = {
|
||||
workspaceId: "",
|
||||
@@ -13,7 +13,7 @@ export const workspaceSlice = createSlice({
|
||||
setWorkspaceId: (state, action: PayloadAction<WorkspaceId>) => {
|
||||
state.workspaceId = action.payload;
|
||||
},
|
||||
setAnimatedBG: (state, action: PayloadAction<AnimatedBG>) => {
|
||||
setAnimatedBG: (state, action: PayloadAction<boolean>) => {
|
||||
state.animatedBG = action.payload;
|
||||
},
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user