File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ const props = defineProps<{ show: boolean; ssr: boolean }>()
20
20
21
21
const store = inject (' store' ) as Store
22
22
const clearConsole = inject (' clear-console' ) as Ref <boolean >
23
+ const theme = inject (' theme' ) as Ref <' dark' | ' light' >
23
24
24
25
const previewOptions = inject (' preview-options' ) as Props [' previewOptions' ]
25
26
@@ -85,6 +86,7 @@ function createSandbox() {
85
86
importMap .imports .vue = store .state .vueRuntimeURL
86
87
}
87
88
const sandboxSrc = srcdoc
89
+ .replace (/ <html>/ , ` <html class="${theme .value }"> ` )
88
90
.replace (/ <!--IMPORT_MAP-->/ , JSON .stringify (importMap ))
89
91
.replace (
90
92
/ <!-- PREVIEW-OPTIONS-HEAD-HTML -->/ ,
@@ -277,7 +279,12 @@ defineExpose({ reload })
277
279
</script >
278
280
279
281
<template >
280
- <div class =" iframe-container" v-show =" show" ref =" container" ></div >
282
+ <div
283
+ class =" iframe-container"
284
+ :class =" theme"
285
+ v-show =" show"
286
+ ref =" container"
287
+ ></div >
281
288
<Message :err =" runtimeError" />
282
289
<Message v-if =" !runtimeError" :warn =" runtimeWarning" />
283
290
</template >
@@ -290,4 +297,7 @@ defineExpose({ reload })
290
297
border : none ;
291
298
background-color : #fff ;
292
299
}
300
+ .iframe-container.dark :deep(iframe ) {
301
+ background-color : #1e1e1e ;
302
+ }
293
303
</style >
You can’t perform that action at this time.
0 commit comments