Skip to content

Commit 3a87233

Browse files
authored
feat: Content Block publish component generator (#4495)
## Description 1 commit = fixtures 2nd commit = code changes 3rd = size changes ref #3994 Publish result: https://webstudio-fixture-project-a-0su3o.wstd.work/content-block See fixtures for generated code. ## 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 69fd855 commit 3a87233

File tree

14 files changed

+1264
-22
lines changed

14 files changed

+1264
-22
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
const results = [
8686
await assertSize('./fixtures/ssg/dist/client', 288),
8787
await assertSize('./fixtures/webstudio-remix-netlify-functions/build/client', 376),
88-
await assertSize('./fixtures/webstudio-remix-vercel/build/client', 904),
88+
await assertSize('./fixtures/webstudio-remix-vercel/build/client', 908),
8989
]
9090
for (const result of results) {
9191
if (result.passed) {

apps/builder/app/builder/builder.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ import { migrateWebstudioDataMutable } from "~/shared/webstudio-data-migrator";
6464
import { Loading, LoadingBackground } from "./shared/loading";
6565
import { mergeRefs } from "@react-aria/utils";
6666
import { CommandPanel } from "./features/command-panel";
67+
6768
import {
6869
initCopyPaste,
6970
initCopyPasteForContentEditMode,
7071
} from "~/shared/copy-paste/init-copy-paste";
7172
import { useInertHandlers } from "./shared/inert-handlers";
73+
import { TextToolbar } from "./features/workspace/canvas-tools/text-toolbar";
7274

7375
registerContainers();
7476

@@ -122,6 +124,7 @@ const Main = ({ children, css }: { children: ReactNode; css?: CSS }) => (
122124
css={{
123125
gridArea: "main",
124126
position: "relative",
127+
isolation: "isolate",
125128
...css,
126129
}}
127130
>
@@ -416,6 +419,9 @@ export const Builder = ({
416419
/>
417420
}
418421
/>
422+
<Main css={{ pointerEvents: "none" }}>
423+
<TextToolbar />
424+
</Main>
419425
{isPreviewMode === false && <Footer />}
420426
<CloneProjectDialog
421427
isOpen={isCloneDialogOpen}

apps/builder/app/builder/features/footer/footer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const Footer = () => {
77
as="footer"
88
align="center"
99
css={{
10+
isolation: "isolate",
1011
gridArea: "footer",
1112
height: theme.spacing[11],
1213
background: theme.colors.backgroundTopbar,

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ import {
1212
HoveredInstanceOutline,
1313
SelectedInstanceOutline,
1414
} from "./outline";
15-
import { TextToolbar } from "./text-toolbar";
15+
1616
import { Label } from "./outline/label";
1717
import { Outline } from "./outline/outline";
1818
import { useSubscribeDragAndDropState } from "./use-subscribe-drag-drop-state";
19-
import { ResizeHandles } from "./resize-handles";
20-
import { MediaBadge } from "./media-badge";
2119
import { applyScale } from "./outline";
2220
import { $scale } from "~/builder/shared/nano-states";
2321
import { BlockChildHoveredInstanceOutline } from "./outline/block-instance-outline";
@@ -73,15 +71,11 @@ export const CanvasTools = () => {
7371

7472
return (
7573
<>
76-
<MediaBadge />
77-
<ResizeHandles />
7874
{isPreviewMode === false && (
7975
<>
8076
<SelectedInstanceOutline />
8177
<HoveredInstanceOutline />
8278
<CollaborativeInstanceOutline />
83-
<TextToolbar />
84-
8579
<BlockChildHoveredInstanceOutline />
8680
</>
8781
)}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { $textEditingInstanceSelector } from "~/shared/nano-states";
1010
import { CanvasTools } from "./canvas-tools";
1111
import { useSetCanvasWidth } from "../breakpoints";
1212
import { selectInstance } from "~/shared/awareness";
13+
import { ResizeHandles } from "./canvas-tools/resize-handles";
14+
import { MediaBadge } from "./canvas-tools/media-badge";
1315

1416
const workspaceStyle = css({
1517
flexGrow: 1,
@@ -101,6 +103,7 @@ export const Workspace = ({ children, onTransitionEnd }: WorkspaceProps) => {
101103
selectInstance(undefined);
102104
$textEditingInstanceSelector.set(undefined);
103105
};
106+
const outlineStyle = useOutlineStyle();
104107

105108
return (
106109
<>
@@ -116,14 +119,21 @@ export const Workspace = ({ children, onTransitionEnd }: WorkspaceProps) => {
116119
>
117120
{children}
118121
</div>
122+
<div
123+
data-name="canvas-tools-wrapper"
124+
className={canvasContainerStyle({ css: { pointerEvents: "none" } })}
125+
style={outlineStyle}
126+
>
127+
<MediaBadge />
128+
<ResizeHandles />
129+
</div>
119130
</div>
120131
</>
121132
);
122133
};
123134

124135
export const CanvasToolsContainer = () => {
125136
const outlineStyle = useOutlineStyle();
126-
useSetCanvasWidth();
127137

128138
return (
129139
<>

0 commit comments

Comments
 (0)