Skip to content

Commit edeb72d

Browse files
committed
move darkmode to settings
1 parent fb870c3 commit edeb72d

File tree

1 file changed

+15
-11
lines changed
  • packages/app/src/app/pages/common/Modals/ShareModal2

1 file changed

+15
-11
lines changed

packages/app/src/app/pages/common/Modals/ShareModal2/index.tsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
/** TODO:
1+
/**
2+
Done:
23
- convert to typescript
4+
- include darkMode in settings
5+
TODO:
36
- add default module to show
47
- check what initial path does
58
- visual polish
69
- overflow-x
710
- multiline
811
- style more info in brackets
912
- 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
1214
*/
1315

1416
import React from 'react';
@@ -32,6 +34,7 @@ import {
3234

3335
// outside of presets
3436
const globalOptions = {
37+
darkMode: true,
3538
fontSize: 14,
3639
highlightLines: null,
3740
initialPath: '/',
@@ -75,10 +78,10 @@ function getView({ showEditor, showPreview }) {
7578
return 'preview';
7679
}
7780

78-
function getUrl(settings, darkMode) {
81+
function getUrl(settings) {
7982
const flags = {
8083
hidenavigation: settings.showNavigation ? 0 : 1,
81-
theme: darkMode ? 'dark' : 'light',
84+
theme: settings.darkMode ? 'dark' : 'light',
8285
fontsize: settings.fontSize || 14,
8386
expanddevtools: settings.expandDevTools ? 1 : null,
8487
hidedevtools: settings.expandDevTools ? 0 : 1,
@@ -108,8 +111,6 @@ function ShareModal() {
108111
...presets['split-view'],
109112
});
110113

111-
const [darkMode, setDarkMode] = React.useState<boolean>(true);
112-
113114
const change = property => {
114115
setSettings({ ...settings, preset: 'custom', ...property });
115116
};
@@ -160,7 +161,10 @@ function ShareModal() {
160161
</Option>
161162
<Option>
162163
Dark theme
163-
<Switch on={darkMode} onChange={() => setDarkMode(!darkMode)} />
164+
<Switch
165+
on={settings.darkMode}
166+
onChange={() => toggle('darkMode')}
167+
/>
164168
</Option>
165169
</SectionBody>
166170

@@ -260,7 +264,7 @@ function ShareModal() {
260264
code
261265
rows={5}
262266
readOnly
263-
value={getUrl(settings, darkMode)}
267+
value={getUrl(settings)}
264268
ref={urlContainer}
265269
/>
266270
<Button onClick={copyEmbedCode}>
@@ -271,14 +275,14 @@ function ShareModal() {
271275
<Input
272276
code
273277
readOnly
274-
value={getUrl(settings, darkMode).replace('embed', 's')}
278+
value={getUrl(settings).replace('embed', 's')}
275279
/>
276280
</Option>
277281
</SectionBody>
278282
</Sidebar>
279283
<Preview>
280284
<iframe
281-
src={getUrl(settings, darkMode)}
285+
src={getUrl(settings)}
282286
title="Dark Magic Variant"
283287
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
284288
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"

0 commit comments

Comments
 (0)