Skip to content

Commit df89e1c

Browse files
aquaductapeMilo
authored andcommitted
fix styling to scale iframe devtools properly when zooming page
1 parent eb69972 commit df89e1c

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

packages/solid-repl/src/components/preview.tsx

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -269,22 +269,24 @@ export const Preview: Component<Props> = (props) => {
269269
});
270270
return (
271271
<div class="flex min-h-0 flex-1 flex-col" ref={outerContainer} classList={props.classList}>
272-
<iframe
273-
title="Solid REPL"
274-
class="dark:bg-other block min-h-0 min-w-0 overflow-scroll bg-white p-0"
275-
style={styleScale() + `flex: ${props.devtools ? iframeHeight() : 1};`}
276-
ref={iframe}
277-
src={iframeSrcUrl()}
278-
onload={() => {
279-
isIframeReady = true;
280-
281-
if (devtoolsLoaded) iframe.contentWindow!.postMessage({ event: 'LOADED' }, '*');
282-
if (props.code) iframe.contentWindow!.postMessage({ event: 'CODE_UPDATE', value: props.code }, '*');
283-
iframe.contentDocument!.documentElement.classList.toggle('dark', props.isDark);
284-
}}
285-
// @ts-ignore
286-
sandbox="allow-popups-to-escape-sandbox allow-scripts allow-popups allow-forms allow-pointer-lock allow-top-navigation allow-modals allow-same-origin"
287-
/>
272+
<div class="min-h-0 min-w-0" style={`flex: ${props.devtools ? iframeHeight() : 1};`}>
273+
<iframe
274+
title="Solid REPL"
275+
class="dark:bg-other block h-full w-full overflow-scroll bg-white p-0"
276+
style={styleScale()}
277+
ref={iframe}
278+
src={iframeSrcUrl()}
279+
onload={() => {
280+
isIframeReady = true;
281+
282+
if (devtoolsLoaded) iframe.contentWindow!.postMessage({ event: 'LOADED' }, '*');
283+
if (props.code) iframe.contentWindow!.postMessage({ event: 'CODE_UPDATE', value: props.code }, '*');
284+
iframe.contentDocument!.documentElement.classList.toggle('dark', props.isDark);
285+
}}
286+
// @ts-ignore
287+
sandbox="allow-popups-to-escape-sandbox allow-scripts allow-popups allow-forms allow-pointer-lock allow-top-navigation allow-modals allow-same-origin"
288+
/>
289+
</div>
288290
<Show when={props.devtools}>
289291
<GridResizer
290292
ref={resizer}
@@ -294,15 +296,17 @@ export const Preview: Component<Props> = (props) => {
294296
}}
295297
/>
296298
</Show>
297-
<iframe
298-
title="Devtools"
299-
class="min-h-0 min-w-0"
300-
style={`flex: ${1 - iframeHeight()};`}
301-
ref={devtoolsIframe}
302-
src={devtoolsSrc}
303-
onload={() => (devtoolsLoaded = true)}
304-
classList={{ block: props.devtools, hidden: !props.devtools }}
305-
/>
299+
<div class="min-h-0 min-w-0" style={`flex: ${1 - iframeHeight()};`}>
300+
<iframe
301+
title="Devtools"
302+
class="h-full w-full"
303+
style={styleScale()}
304+
ref={devtoolsIframe}
305+
src={devtoolsSrc}
306+
onload={() => (devtoolsLoaded = true)}
307+
classList={{ block: props.devtools, hidden: !props.devtools }}
308+
/>
309+
</div>
306310
</div>
307311
);
308312
};

0 commit comments

Comments
 (0)