From eb66eccca16696ecd5ba28a1cbb3857d8af48571 Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Tue, 7 Feb 2023 00:17:06 +0300 Subject: [PATCH] Move selected style source into separate store (#955) Ref https://github.com/webstudio-is/webstudio-designer/issues/807 this will let to reuse the logic and newly generated local style source with style source input. --- apps/designer/app/canvas/canvas.tsx | 2 + apps/designer/app/designer/designer.tsx | 4 +- .../designer/features/inspector/inspector.tsx | 11 +-- .../props-panel/props-panel.stories.tsx | 4 - .../features/props-panel/props-panel.tsx | 10 +-- .../style-panel/shared/use-style-data.ts | 81 ++++++++---------- .../features/style-panel/style-panel.tsx | 10 +-- .../app/shared/nano-states/nano-states.ts | 82 ++++++++++++++----- 8 files changed, 105 insertions(+), 99 deletions(-) diff --git a/apps/designer/app/canvas/canvas.tsx b/apps/designer/app/canvas/canvas.tsx index 1cece89fa6..a0d54ee2cf 100644 --- a/apps/designer/app/canvas/canvas.tsx +++ b/apps/designer/app/canvas/canvas.tsx @@ -37,6 +37,7 @@ import { useSubscribeScrollState, useIsPreviewMode, useSetAssets, + useSetTreeId, } from "~/shared/nano-states"; import { usePublishScrollState } from "./shared/use-publish-scroll-state"; import { useDragAndDrop } from "./shared/use-drag-drop"; @@ -119,6 +120,7 @@ export const Canvas = ({ data }: CanvasProps): JSX.Element | null => { throw new Error("Tree is null"); } const isDesignerReady = useSubscribeDesignerReady(); + useSetTreeId(data.tree.id); useSetAssets(data.assets); useSetBreakpoints(data.build.breakpoints); useSetProps(data.tree.props); diff --git a/apps/designer/app/designer/designer.tsx b/apps/designer/app/designer/designer.tsx index f82602756a..e26039f64a 100644 --- a/apps/designer/app/designer/designer.tsx +++ b/apps/designer/app/designer/designer.tsx @@ -35,6 +35,7 @@ import { useIsPreviewMode, useSetAuthPermit, useSetIsPreviewMode, + useSetTreeId, } from "~/shared/nano-states"; import { useClientSettings } from "./shared/client-settings"; import { Navigator } from "./features/sidebar-left"; @@ -266,6 +267,7 @@ export const Designer = ({ useSetAuthPermit(authPermit); useSubscribeBreakpoints(); useSetProject(project); + useSetTreeId(treeId); useSetPages(pages); useSetCurrentPageId(pageId); const [publish, publishRef] = usePublish(); @@ -354,7 +356,7 @@ export const Designer = ({ {dragAndDropState.isDragging ? ( ) : ( - + )}