1
- /** TODO:
1
+ /**
2
+ Done:
2
3
- convert to typescript
4
+ - include darkMode in settings
5
+ TODO:
3
6
- add default module to show
4
7
- check what initial path does
5
8
- visual polish
6
9
- overflow-x
7
10
- multiline
8
11
- style more info in brackets
9
12
- total height of the container is beyond preview
10
- - add postMessage to embed for smoother embed modal
11
- - include darkMode in settings
13
+ - bonus: add postMessage to embed for smoother embed modal
12
14
*/
13
15
14
16
import React from 'react' ;
@@ -32,6 +34,7 @@ import {
32
34
33
35
// outside of presets
34
36
const globalOptions = {
37
+ darkMode : true ,
35
38
fontSize : 14 ,
36
39
highlightLines : null ,
37
40
initialPath : '/' ,
@@ -75,10 +78,10 @@ function getView({ showEditor, showPreview }) {
75
78
return 'preview' ;
76
79
}
77
80
78
- function getUrl ( settings , darkMode ) {
81
+ function getUrl ( settings ) {
79
82
const flags = {
80
83
hidenavigation : settings . showNavigation ? 0 : 1 ,
81
- theme : darkMode ? 'dark' : 'light' ,
84
+ theme : settings . darkMode ? 'dark' : 'light' ,
82
85
fontsize : settings . fontSize || 14 ,
83
86
expanddevtools : settings . expandDevTools ? 1 : null ,
84
87
hidedevtools : settings . expandDevTools ? 0 : 1 ,
@@ -108,8 +111,6 @@ function ShareModal() {
108
111
...presets [ 'split-view' ] ,
109
112
} ) ;
110
113
111
- const [ darkMode , setDarkMode ] = React . useState < boolean > ( true ) ;
112
-
113
114
const change = property => {
114
115
setSettings ( { ...settings , preset : 'custom' , ...property } ) ;
115
116
} ;
@@ -160,7 +161,10 @@ function ShareModal() {
160
161
</ Option >
161
162
< Option >
162
163
Dark theme
163
- < Switch on = { darkMode } onChange = { ( ) => setDarkMode ( ! darkMode ) } />
164
+ < Switch
165
+ on = { settings . darkMode }
166
+ onChange = { ( ) => toggle ( 'darkMode' ) }
167
+ />
164
168
</ Option >
165
169
</ SectionBody >
166
170
@@ -260,7 +264,7 @@ function ShareModal() {
260
264
code
261
265
rows = { 5 }
262
266
readOnly
263
- value = { getUrl ( settings , darkMode ) }
267
+ value = { getUrl ( settings ) }
264
268
ref = { urlContainer }
265
269
/>
266
270
< Button onClick = { copyEmbedCode } >
@@ -271,14 +275,14 @@ function ShareModal() {
271
275
< Input
272
276
code
273
277
readOnly
274
- value = { getUrl ( settings , darkMode ) . replace ( 'embed' , 's' ) }
278
+ value = { getUrl ( settings ) . replace ( 'embed' , 's' ) }
275
279
/>
276
280
</ Option >
277
281
</ SectionBody >
278
282
</ Sidebar >
279
283
< Preview >
280
284
< iframe
281
- src = { getUrl ( settings , darkMode ) }
285
+ src = { getUrl ( settings ) }
282
286
title = "Dark Magic Variant"
283
287
allow = "geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
284
288
sandbox = "allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
0 commit comments