mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 17:38:10 +00:00
PageEnigma refactor Phase 5f: migrate sizing slice to the store
sizing.ts (deleted). Was already minimal -- just sidePanelWidth, the last survivor after the timeline-related sizing exports were stripped in Phase 2. Three consumers migrated: - PageEditor's mount-time setup: store.setSidePanelWidth(340) - PreviewFrameImage: pulls sidePanelWidth off the store alongside sidePanelVisible - SidePanel: same pattern (already reading sidePanelVisible / dndSidePanelWidth from the store; sidePanelWidth joins them) - StyleSelection: subscribes to sidePanelWidth via the store signals/ down to 10 files: camera, demoAssets, dragAndDrop, engine, objectPanel, outliner, precisionSelectorMenu, promptBox, stylizeTab.
This commit is contained in:
1 parent
e0c04efa8f
commit
ea49ddf60a
6 files changed
+25
-29
No files matched your search
@@ -22,7 +22,6 @@ import { Storyboard } from "../PageStoryboard";
|
||||
import { useStoryboardPageEnabled } from "@storyteller/ui-settings-modal";
|
||||
|
||||
import {
|
||||
sidePanelWidth,
|
||||
cameraAspectRatio,
|
||||
outlinerIsShowing,
|
||||
gridVisibility,
|
||||
@@ -113,7 +112,7 @@ export const PageEditor = () => {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
sidePanelWidth.value = 340;
|
||||
usePageEnigmaStore.getState().setSidePanelWidth(340);
|
||||
window.onbeforeunload = () => {
|
||||
return "You may have unsaved changes.";
|
||||
};
|
||||
|
||||
@@ -4,18 +4,19 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { EditorStates } from "~/pages/PageEnigma/enums";
|
||||
import { pageHeight, pageWidth } from "~/signals";
|
||||
import { sidePanelWidth } from "~/pages/PageEnigma/signals";
|
||||
import { usePageEnigmaStore } from "~/pages/PageEnigma/PageEnigmaStore";
|
||||
|
||||
export const PreviewFrameImage = () => {
|
||||
useSignals();
|
||||
const { editorState, previewSrc, sidePanelVisible } = usePageEnigmaStore(
|
||||
useShallow((s) => ({
|
||||
editorState: s.editorState,
|
||||
previewSrc: s.previewSrc,
|
||||
sidePanelVisible: s.sidePanelVisible,
|
||||
})),
|
||||
);
|
||||
const { editorState, previewSrc, sidePanelVisible, sidePanelWidth } =
|
||||
usePageEnigmaStore(
|
||||
useShallow((s) => ({
|
||||
editorState: s.editorState,
|
||||
previewSrc: s.previewSrc,
|
||||
sidePanelVisible: s.sidePanelVisible,
|
||||
sidePanelWidth: s.sidePanelWidth,
|
||||
})),
|
||||
);
|
||||
|
||||
if (editorState !== EditorStates.PREVIEW) {
|
||||
return null;
|
||||
@@ -23,7 +24,7 @@ export const PreviewFrameImage = () => {
|
||||
|
||||
const width =
|
||||
pageWidth.value -
|
||||
(sidePanelVisible ? sidePanelWidth.value : 0) -
|
||||
(sidePanelVisible ? sidePanelWidth : 0) -
|
||||
84;
|
||||
const height = pageHeight.value - 56;
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import { useSignals } from "@preact/signals-react/runtime";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { sidePanelWidth } from "~/pages/PageEnigma/signals";
|
||||
import { usePageEnigmaStore } from "~/pages/PageEnigma/PageEnigmaStore";
|
||||
|
||||
import { SidePanelTabs } from "~/pages/PageEnigma/comps/SidePanelTabs";
|
||||
@@ -9,13 +7,14 @@ import { SidePanelMenu } from "~/pages/PageEnigma/comps/SidePanelMenu";
|
||||
import { TabItem, tabList } from "./tabList";
|
||||
|
||||
export const SidePanel = () => {
|
||||
useSignals();
|
||||
const { sidePanelVisible, dndSidePanelWidth } = usePageEnigmaStore(
|
||||
useShallow((s) => ({
|
||||
sidePanelVisible: s.sidePanelVisible,
|
||||
dndSidePanelWidth: s.dndSidePanelWidth,
|
||||
})),
|
||||
);
|
||||
const { sidePanelVisible, dndSidePanelWidth, sidePanelWidth } =
|
||||
usePageEnigmaStore(
|
||||
useShallow((s) => ({
|
||||
sidePanelVisible: s.sidePanelVisible,
|
||||
dndSidePanelWidth: s.dndSidePanelWidth,
|
||||
sidePanelWidth: s.sidePanelWidth,
|
||||
})),
|
||||
);
|
||||
|
||||
const initialTabIdx = 0;
|
||||
const [selectedTab, setSelectedTab] = useState<TabItem>(
|
||||
@@ -23,7 +22,7 @@ export const SidePanel = () => {
|
||||
);
|
||||
|
||||
const displayWidth =
|
||||
dndSidePanelWidth > -1 ? dndSidePanelWidth : sidePanelWidth.value;
|
||||
dndSidePanelWidth > -1 ? dndSidePanelWidth : sidePanelWidth;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
+5
-4
@@ -6,8 +6,8 @@ import { EngineContext } from "~/pages/PageEnigma/contexts/EngineContext";
|
||||
import { ArtStyle } from "~/pages/PageEnigma/Editor/api_manager";
|
||||
import { faAngleLeft, faAngleRight } from "@fortawesome/pro-solid-svg-icons";
|
||||
import { styleList } from "~/pages/PageEnigma/styleList";
|
||||
import { sidePanelWidth } from "~/pages/PageEnigma/signals";
|
||||
import { pageHeight } from "~/signals";
|
||||
import { usePageEnigmaStore } from "~/pages/PageEnigma/PageEnigmaStore";
|
||||
import { ItemPicker } from "./ItemPicker";
|
||||
import { useSignals } from "@preact/signals-react/runtime";
|
||||
|
||||
@@ -17,11 +17,12 @@ interface Props {
|
||||
}
|
||||
export const StyleSelection = ({ setSelection, selection }: Props) => {
|
||||
useSignals();
|
||||
const sidePanelWidth = usePageEnigmaStore((s) => s.sidePanelWidth);
|
||||
const [scrollPosition, setScrollPosition] = useState(0);
|
||||
|
||||
const shownImageCount = Math.floor((sidePanelWidth.value - 32) / 104);
|
||||
const shownImageCount = Math.floor((sidePanelWidth - 32) / 104);
|
||||
const imageWidth =
|
||||
96 + (sidePanelWidth.value - 32 - shownImageCount * 104) / shownImageCount;
|
||||
96 + (sidePanelWidth - 32 - shownImageCount * 104) / shownImageCount;
|
||||
const imageHeight = (54 * imageWidth) / 90;
|
||||
|
||||
const imageRows = Math.min(
|
||||
@@ -49,7 +50,7 @@ export const StyleSelection = ({ setSelection, selection }: Props) => {
|
||||
<div
|
||||
className="relative overflow-hidden"
|
||||
style={{
|
||||
width: sidePanelWidth.value - 32,
|
||||
width: sidePanelWidth - 32,
|
||||
height: imageHeight * imageRows + 8 * imageRows,
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -3,5 +3,4 @@ export * from "./engine";
|
||||
export * from "./dragAndDrop";
|
||||
export * from "./objectPanel";
|
||||
export * from "./outliner";
|
||||
export * from "./sizing";
|
||||
export * from "./stylizeTab";
|
||||
@@ -1,3 +0,0 @@
|
||||
import { signal } from "@preact/signals-core";
|
||||
|
||||
export const sidePanelWidth = signal(0);
|
||||
Reference in new issue
Block a user