Skip to content

Commit 539e083

Browse files
authored
fix: Show extended panels (#4493)
## Description 1. What is this PR about (link the issue and add a short description) ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
1 parent f837456 commit 539e083

File tree

8 files changed

+80
-52
lines changed

8 files changed

+80
-52
lines changed

apps/builder/app/builder/builder.tsx

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Topbar } from "./features/topbar";
1919
import { Footer } from "./features/footer";
2020
import {
2121
CanvasIframe,
22+
CanvasToolsContainer,
2223
useReadCanvasRect,
2324
Workspace,
2425
} from "./features/workspace";
@@ -93,7 +94,6 @@ const SidePanel = ({
9394
}: SidePanelProps) => {
9495
return (
9596
<Box
96-
id="jopa"
9797
as="aside"
9898
css={{
9999
position: "relative",
@@ -115,13 +115,14 @@ const SidePanel = ({
115115
);
116116
};
117117

118-
const Main = ({ children }: { children: ReactNode }) => (
118+
const Main = ({ children, css }: { children: ReactNode; css?: CSS }) => (
119119
<Flex
120120
as="main"
121121
direction="column"
122122
css={{
123123
gridArea: "main",
124124
position: "relative",
125+
...css,
125126
}}
126127
>
127128
{children}
@@ -361,24 +362,6 @@ export const Builder = ({
361362
navigatorLayout={navigatorLayout}
362363
>
363364
<ProjectSettings />
364-
<Topbar
365-
project={project}
366-
hasProPlan={userPlanFeatures.hasProPlan}
367-
css={{ gridArea: "header" }}
368-
loading={
369-
<LoadingBackground
370-
// Looks nicer when topbar is already visible earlier, so user has more sense of progress.
371-
show={
372-
loadingState.readyStates.get("dataLoadingState")
373-
? false
374-
: true
375-
}
376-
/>
377-
}
378-
/>
379-
<SidePanel gridArea="sidebar">
380-
<SidebarLeft publish={publish} />
381-
</SidePanel>
382365
<Main>
383366
<Workspace onTransitionEnd={onTransitionEnd}>
384367
{dataLoadingState === "loaded" && (
@@ -392,6 +375,10 @@ export const Builder = ({
392375

393376
{isDesignMode && <AiCommandBar />}
394377
</Main>
378+
379+
<SidePanel gridArea="sidebar">
380+
<SidebarLeft publish={publish} />
381+
</SidePanel>
395382
<SidePanel
396383
gridArea="inspector"
397384
isPreviewMode={isPreviewMode}
@@ -411,6 +398,24 @@ export const Builder = ({
411398
>
412399
<Inspector navigatorLayout={navigatorLayout} />
413400
</SidePanel>
401+
<Main css={{ pointerEvents: "none" }}>
402+
<CanvasToolsContainer />
403+
</Main>
404+
<Topbar
405+
project={project}
406+
hasProPlan={userPlanFeatures.hasProPlan}
407+
css={{ gridArea: "header" }}
408+
loading={
409+
<LoadingBackground
410+
// Looks nicer when topbar is already visible earlier, so user has more sense of progress.
411+
show={
412+
loadingState.readyStates.get("dataLoadingState")
413+
? false
414+
: true
415+
}
416+
/>
417+
}
418+
/>
414419
{isPreviewMode === false && <Footer />}
415420
<CloneProjectDialog
416421
isOpen={isCloneDialogOpen}

apps/builder/app/builder/features/marketplace/marketplace.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,16 @@ export const MarketplacePanel = ({ onClose }: { onClose: () => void }) => {
8787
<SpinnerIcon size={rawTheme.spacing[15]} />
8888
</Flex>
8989
)}
90-
<ExtendedPanel isOpen={openAboutItem !== undefined}>
91-
<About
92-
item={openAboutItem}
93-
onClose={() => {
94-
setOpenAbout(undefined);
95-
}}
96-
/>
97-
</ExtendedPanel>
90+
{openAboutItem !== undefined && (
91+
<ExtendedPanel>
92+
<About
93+
item={openAboutItem}
94+
onClose={() => {
95+
setOpenAbout(undefined);
96+
}}
97+
/>
98+
</ExtendedPanel>
99+
)}
98100
</>
99101
);
100102
};

apps/builder/app/builder/features/pages/pages.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,9 +575,8 @@ export const PagesPanel = ({ onClose }: { onClose: () => void }) => {
575575
$editingPageId.set(itemId);
576576
}}
577577
/>
578-
579-
<ExtendedPanel isOpen={editingItemId !== undefined}>
580-
{editingItemId !== undefined && (
578+
{editingItemId !== undefined && (
579+
<ExtendedPanel>
581580
<>
582581
{isFolder(editingItemId, pages.folders) ? (
583582
<FolderEditor
@@ -591,8 +590,8 @@ export const PagesPanel = ({ onClose }: { onClose: () => void }) => {
591590
/>
592591
)}
593592
</>
594-
)}
595-
</ExtendedPanel>
593+
</ExtendedPanel>
594+
)}
596595
</>
597596
);
598597
};

apps/builder/app/builder/features/workspace/canvas-tools/canvas-tools.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
$instances,
66
$isPreviewMode,
77
$dragAndDropState,
8+
$canvasToolsVisible,
89
} from "~/shared/nano-states";
910
import {
1011
CollaborativeInstanceOutline,
@@ -37,11 +38,16 @@ const containerStyle = css({
3738
export const CanvasTools = () => {
3839
// @todo try to setup cross-frame atoms to avoid this
3940
useSubscribeDragAndDropState();
40-
41+
const canvasToolsVisible = useStore($canvasToolsVisible);
4142
const isPreviewMode = useStore($isPreviewMode);
4243
const dragAndDropState = useStore($dragAndDropState);
4344
const instances = useStore($instances);
4445
const scale = useStore($scale);
46+
47+
if (!canvasToolsVisible) {
48+
return;
49+
}
50+
4551
if (
4652
dragAndDropState.isDragging &&
4753
dragAndDropState.placementIndicator !== undefined

apps/builder/app/builder/features/workspace/workspace.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ const useOutlineStyle = () => {
8383

8484
return {
8585
...style,
86-
pointerEvents: "none",
8786
width:
8887
canvasWidth === undefined ? "100%" : (canvasWidth ?? 0) * (scale / 100),
8988
} as const;
@@ -96,7 +95,6 @@ type WorkspaceProps = {
9695

9796
export const Workspace = ({ children, onTransitionEnd }: WorkspaceProps) => {
9897
const canvasStyle = useCanvasStyle();
99-
const outlineStyle = useOutlineStyle();
10098
const workspaceRef = useMeasureWorkspace();
10199
useSetCanvasWidth();
102100
const handleWorkspaceClick = () => {
@@ -118,13 +116,23 @@ export const Workspace = ({ children, onTransitionEnd }: WorkspaceProps) => {
118116
>
119117
{children}
120118
</div>
121-
<div
122-
data-name="canvas-tools-wrapper"
123-
className={canvasContainerStyle()}
124-
style={outlineStyle}
125-
>
126-
<CanvasTools />
127-
</div>
119+
</div>
120+
</>
121+
);
122+
};
123+
124+
export const CanvasToolsContainer = () => {
125+
const outlineStyle = useOutlineStyle();
126+
useSetCanvasWidth();
127+
128+
return (
129+
<>
130+
<div
131+
data-name="canvas-tools-wrapper"
132+
className={canvasContainerStyle()}
133+
style={outlineStyle}
134+
>
135+
<CanvasTools />
128136
</div>
129137
<Toaster />
130138
</>

apps/builder/app/builder/shared/extended-sidebar-panel.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { styled, Collapsible, Flex } from "@webstudio-is/design-system";
22
import { theme } from "@webstudio-is/design-system";
3-
import { useRef } from "react";
3+
import { useEffect, useRef } from "react";
44
import { BindingPopoverProvider } from "~/builder/shared/binding-popover";
5+
import { $canvasToolsVisible } from "~/shared/nano-states";
56

67
const CollapsibleRoot = styled(Collapsible.Root, {
78
position: "absolute",
@@ -20,16 +21,20 @@ const CollapsibleContent = styled(Collapsible.Content, {
2021
flexDirection: "column",
2122
});
2223

23-
export const ExtendedPanel = ({
24-
children,
25-
isOpen,
26-
}: {
27-
children: React.ReactNode;
28-
isOpen: boolean;
29-
}) => {
24+
export const ExtendedPanel = ({ children }: { children: React.ReactNode }) => {
3025
const settingsRef = useRef<HTMLDivElement>(null);
26+
27+
useEffect(() => {
28+
// Quick workaround to hide the outline above extended panels.
29+
// These panels should ideally be implemented as `Sheet`-style dialogs.
30+
$canvasToolsVisible.set(false);
31+
return () => {
32+
$canvasToolsVisible.set(true);
33+
};
34+
}, []);
35+
3136
return (
32-
<CollapsibleRoot ref={settingsRef} open={isOpen}>
37+
<CollapsibleRoot ref={settingsRef} open={true}>
3338
<CollapsibleContent>
3439
<Flex
3540
direction="column"

apps/builder/app/shared/nano-states/misc.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,3 +459,5 @@ export const $dragAndDropState = atom<DragAndDropState>({
459459
});
460460

461461
export const $marketplaceProduct = atom<undefined | MarketplaceProduct>();
462+
463+
export const $canvasToolsVisible = atom<boolean>(true);

packages/design-system/src/components/toast.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ const InternalToast = ({
128128
css={{
129129
display: "grid",
130130
gridTemplateColumns: "8px 1fr",
131+
pointerEvents: "all",
131132
}}
132133
>
133134
<Box

0 commit comments

Comments
 (0)