Skip to content

Commit 7baa042

Browse files
update resized size to reset on target change
1 parent 4959533 commit 7baa042

4 files changed

Lines changed: 27 additions & 43 deletions

File tree

editor/components/app-runner/vanilla-app-runner.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ export function VanillaRunner({
55
height,
66
source,
77
enableInspector = true,
8+
style,
89
}: {
910
width: string;
1011
height: string;
1112
source: string;
1213
componentName: string;
1314
enableInspector?: boolean;
15+
style?: React.CSSProperties;
1416
}) {
1517
const ref = useRef<HTMLIFrameElement>();
1618

@@ -79,6 +81,7 @@ export function VanillaRunner({
7981
return (
8082
<iframe
8183
ref={ref}
84+
style={style}
8285
sandbox="allow-same-origin"
8386
srcDoc={inlinesource}
8487
width={width}

editor/components/canvas/interactive-canvas.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { ZoomControl } from "./controller-zoom-control";
66

77
export function InteractiveCanvas({
88
children,
9+
defaultSize,
910
}: {
11+
defaultSize: { width: number; height: number };
1012
children?: React.ReactNode;
1113
}) {
1214
const [scale, setScale] = useState(1);
@@ -19,7 +21,9 @@ export function InteractiveCanvas({
1921
</Controls>
2022
<ScalingAreaStaticRoot>
2123
<ScalingArea scale={scale}>
22-
<ResizableFrame scale={scale}>{children}</ResizableFrame>
24+
<ResizableFrame defaultSize={defaultSize} scale={scale}>
25+
{children}
26+
</ResizableFrame>
2327
</ScalingArea>
2428
</ScalingAreaStaticRoot>
2529
</ScalableFrame>
@@ -109,15 +113,20 @@ const ScalingArea = ({
109113
function ResizableFrame({
110114
scale,
111115
children,
116+
defaultSize,
112117
}: {
118+
defaultSize?: { width: number; height: number };
113119
scale: number;
114120
children?: React.ReactNode;
115121
}) {
116122
return (
117123
<Resizable
118-
style={{
119-
overflow: "hidden",
120-
}}
124+
defaultSize={
125+
defaultSize ?? {
126+
width: 500,
127+
height: 500,
128+
}
129+
}
121130
scale={scale}
122131
>
123132
{children}

editor/scaffolds/canvas/canvas.tsx

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,50 +20,22 @@ export function Canvas({
2020
return (
2121
<CanvasContainer id="canvas">
2222
<EditorAppbarFragments.Canvas />
23-
{/* {preview ? (
24-
<PreviewAndRunPanel
25-
// key={_key_for_preview}
26-
config={{
27-
src: preview.scaffold.raw,
28-
platform: "vanilla",
29-
componentName: preview.name,
30-
sceneSize: originsize && {
31-
w: originsize.width,
32-
h: originsize.height,
33-
},
34-
initialMode: "run",
35-
fileid: fileid,
36-
sceneid: sceneid,
37-
hideModeChangeControls: true,
38-
}}
39-
/>
40-
) : (
41-
<EditorCanvasSkeleton />
42-
)} */}
43-
<InteractiveCanvas>
23+
<InteractiveCanvas key={fileid + sceneid} defaultSize={originsize}>
4424
{preview ? (
45-
<div
25+
<VanillaRunner
26+
key={preview.scaffold.raw}
4627
style={{
47-
width: originsize.width,
48-
height: originsize.height,
28+
borderRadius: 4,
29+
boxShadow: "0px 0px 48px #00000020",
4930
}}
50-
>
51-
<VanillaRunner
52-
source={preview.scaffold.raw}
53-
width={"100%"}
54-
height={"100%"}
55-
componentName={preview.name}
56-
/>
57-
</div>
31+
source={preview.scaffold.raw}
32+
width="100%"
33+
height="100%"
34+
componentName={preview.name}
35+
/>
5836
) : (
5937
<EditorCanvasSkeleton />
6038
)}
61-
{/* <div
62-
style={{
63-
height: 812,
64-
background: "white",
65-
}}
66-
></div> */}
6739
</InteractiveCanvas>
6840
</CanvasContainer>
6941
);

editor/scaffolds/editor/skeleton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function EditorSkeleton({ percent = 0 }: { percent?: number }) {
1919
<SidebarMock>
2020
<ListMock>
2121
{[1, 2, 3, 4, 5, 6, 7, 8].map((i) => (
22-
<MockItem1>
22+
<MockItem1 key={i.toString()}>
2323
<BaseHierarchyItem>
2424
<Frame55>
2525
<Frame52></Frame52>

0 commit comments

Comments
 (0)