Skip to content

Commit 4c4c47d

Browse files
author
Yann Leflour
committed
Add iframe interactions
1 parent 9d13a6a commit 4c4c47d

File tree

1 file changed

+44
-14
lines changed

1 file changed

+44
-14
lines changed

ui-sketcher-webview/src/PreviewShape.tsx

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ export class PreviewShapeUtil extends BaseBoxShapeUtil<PreviewShape> {
5050
);
5151

5252
const isLoading = false;
53-
// @ts-expect-error TODO: remove this when stable v2
54-
const isEditing = useIsEditing();
53+
const isEditing = useIsEditing(shape.id);
5554
const { source } = shape.props;
5655

5756
return (
@@ -73,18 +72,49 @@ export class PreviewShapeUtil extends BaseBoxShapeUtil<PreviewShape> {
7372
<DefaultSpinner />
7473
</div>
7574
) : (
76-
<iframe
77-
src={source}
78-
width={toDomPrecision(shape.props.w)}
79-
height={toDomPrecision(shape.props.h)}
80-
draggable={false}
81-
style={{
82-
pointerEvents: isEditing ? "auto" : "none",
83-
boxShadow,
84-
border: "1px solid var(--color-panel-contrast)",
85-
borderRadius: "var(--radius-2)",
86-
}}
87-
/>
75+
<>
76+
<iframe
77+
src={source}
78+
width={toDomPrecision(shape.props.w)}
79+
height={toDomPrecision(shape.props.h)}
80+
draggable={false}
81+
style={{
82+
pointerEvents: isEditing ? "auto" : "none",
83+
boxShadow,
84+
border: "1px solid var(--color-panel-contrast)",
85+
borderRadius: "var(--radius-2)",
86+
}}
87+
/>
88+
<div
89+
style={{
90+
textAlign: "center",
91+
position: "absolute",
92+
bottom: isEditing ? -40 : 0,
93+
padding: 4,
94+
fontFamily: "inherit",
95+
fontSize: 12,
96+
left: 0,
97+
width: "100%",
98+
display: "flex",
99+
alignItems: "center",
100+
justifyContent: "center",
101+
pointerEvents: "none",
102+
}}
103+
>
104+
<span
105+
style={{
106+
background: "var(--color-panel)",
107+
padding: "4px 12px",
108+
borderRadius: 99,
109+
border: "1px solid var(--color-muted-1)",
110+
}}
111+
>
112+
{isEditing
113+
? "Click the canvas to exit"
114+
: "Double click to interact"}
115+
</span>
116+
</div>
117+
</>
88118
)}
89119
</HTMLContainer>
90120
);

0 commit comments

Comments
 (0)