File tree Expand file tree Collapse file tree 3 files changed +37
-15
lines changed Expand file tree Collapse file tree 3 files changed +37
-15
lines changed Original file line number Diff line number Diff line change @@ -12,17 +12,17 @@ import styles from "./styles.module.css";
12
12
13
13
interface Props {
14
14
children : ReactNode ;
15
- minHeight : number ;
16
- url : string ;
15
+ height : string ;
16
+ url ? : string ;
17
17
}
18
18
19
19
export default function BrowserWindow ( {
20
20
children,
21
- minHeight ,
21
+ height ,
22
22
url = "http://localhost:3000" ,
23
23
} : Props ) : JSX . Element {
24
24
return (
25
- < div className = { styles . browserWindow } style = { { minHeight } } >
25
+ < div className = { styles . browserWindow } style = { { height } } >
26
26
< div className = { styles . browserWindowHeader } >
27
27
< div className = { styles . buttons } >
28
28
< span className = { styles . dot } style = { { background : "#f25f58" } } />
@@ -41,7 +41,9 @@ export default function BrowserWindow({
41
41
</ div >
42
42
</ div >
43
43
44
- < div className = { styles . browserWindowBody } > { children } </ div >
44
+ < div className = { styles . browserWindowBody } style = { { height : "90%" } } >
45
+ { children }
46
+ </ div >
45
47
</ div >
46
48
) ;
47
49
}
Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
import BrowserWindow from "@site/src/components/BrowserWindow" ;
3
3
4
- export default function IframeOutput ( { children } : { children : string } ) {
4
+ export default function IframeOutput ( {
5
+ children,
6
+ height,
7
+ } : {
8
+ children : string ;
9
+ height ?: string ;
10
+ } ) {
5
11
return (
6
12
< >
7
- < BrowserWindow minHeight = { 200 } >
13
+ < BrowserWindow height = { height === undefined ? "200px" : height } >
8
14
< iframe
9
15
width = "100%"
10
16
height = "100%"
@@ -13,10 +19,12 @@ export default function IframeOutput({ children }: { children: string }) {
13
19
onLoad = { ( e ) => {
14
20
setInterval (
15
21
( e ) => {
16
- const iframe = e . target as HTMLIFrameElement ;
17
- iframe . height = "100%" ;
18
- iframe . height =
19
- iframe . contentDocument . documentElement . scrollHeight + "px" ;
22
+ if ( height == undefined ) {
23
+ const iframe = e . target as HTMLIFrameElement ;
24
+ iframe . height = "100%" ;
25
+ iframe . height =
26
+ iframe . contentDocument . documentElement . scrollHeight + "px" ;
27
+ }
20
28
} ,
21
29
3000 ,
22
30
e
Original file line number Diff line number Diff line change @@ -11,22 +11,34 @@ export default function Home(): JSX.Element {
11
11
return (
12
12
< Layout
13
13
title = { `Hello from ${ siteConfig . title } ` }
14
- description = "Description will go into a meta tag in <head /> "
14
+ description = "This is a playground of HTML "
15
15
>
16
16
< Box p = { 2 } mt = { 2 } >
17
17
< Grid container direction = "row" spacing = { 2 } >
18
18
< Grid item xs = { 6 } >
19
19
< Editor
20
- height = "400px "
20
+ height = "80vh "
21
21
defaultLanguage = "html"
22
- defaultValue = { "aouesa" }
22
+ defaultValue = { `\
23
+ <!DOCTYPE html>
24
+ <html lang="ja">
25
+ <head>
26
+ <meta charset="UTF-8" />
27
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
28
+ <title>Document</title>
29
+ </head>
30
+ <body>
31
+ <p>Hello World!</p>
32
+ </body>
33
+ </html>\
34
+ ` }
23
35
onChange = { ( value ) => {
24
36
setHTML ( value ) ;
25
37
} }
26
38
/>
27
39
</ Grid >
28
40
< Grid item xs = { 6 } >
29
- < IframeOutput > { html } </ IframeOutput >
41
+ < IframeOutput height = "80vh" > { html } </ IframeOutput >
30
42
</ Grid >
31
43
</ Grid >
32
44
</ Box >
You can’t perform that action at this time.
0 commit comments