Skip to content

Commit e566938

Browse files
committed
got all the flags but 1
1 parent 5f4835a commit e566938

File tree

1 file changed

+63
-54
lines changed
  • packages/app/src/app/pages/common/Modals/ShareModal2

1 file changed

+63
-54
lines changed

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

Lines changed: 63 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const globalOptions = {
2222
fontSize: 14,
2323
highlightLines: null,
2424
initialPath: '/',
25-
useCodemirror: false,
25+
useCodeMirror: false,
2626
enableEslint: false,
2727
defaultFile: null,
2828
showNavigation: false,
@@ -31,7 +31,6 @@ const globalOptions = {
3131
const presets = {
3232
'split-view': {
3333
showEditor: true,
34-
showTabbarSidebar: true,
3534
showPreview: true,
3635
showNavigation: false,
3736
expandDevtools: false,
@@ -46,19 +45,47 @@ const presets = {
4645
},
4746
'code-only': {
4847
showEditor: true,
49-
showTabbarSidebar: false,
5048
showPreview: false,
5149
},
5250
'code-with-tests': {
5351
showEditor: true,
54-
showTabbarSidebar: true,
5552
showPreview: true,
5653
showNavigation: false,
5754
expandDevtools: true,
5855
showTests: true,
5956
},
6057
};
6158

59+
function getUrl(settings, darkMode) {
60+
const flags = {
61+
hidenavigation: settings.showNavigation ? 0 : 1,
62+
theme: darkMode ? 'dark' : 'light',
63+
fontsize: settings.fontSize || 14,
64+
expanddevtools: settings.expandDevTools ? 1 : null,
65+
hidedevtools: settings.expandDevTools ? 0 : 1,
66+
view:
67+
settings.showEditor && settings.showPreview
68+
? 'split'
69+
: settings.showEditor
70+
? 'editor'
71+
: 'preview',
72+
previewwindow: settings.showTests ? 'tests' : null,
73+
codemirror: settings.useCodeMirror ? 1 : null,
74+
highlights: settings.highlightLines || null,
75+
eslint: settings.enableESLint ? 1 : null,
76+
initialpath: settings.initialPath || null,
77+
};
78+
79+
const stringified = queryString.stringify(flags, {
80+
encode: false,
81+
skipNull: true,
82+
});
83+
const url =
84+
`https://codesandbox.io/embed/dark-magic-variant-5pj49?` + stringified;
85+
86+
return url;
87+
}
88+
6289
function ShareSheet() {
6390
const [settings, setSettings] = React.useState({
6491
preset: 'split-view',
@@ -118,16 +145,6 @@ function ShareSheet() {
118145
onChange={() => toggle('showEditor')}
119146
/>
120147
</Option>
121-
<Option disabled={!settings.showEditor}>
122-
<span style={{ textDecoration: 'line-through' }}>
123-
Tabbar + Sidebar
124-
</span>
125-
<Switch
126-
on={settings.showEditorControls}
127-
disabled={!settings.showEditor}
128-
onChange={() => toggle('showEditorControls')}
129-
/>
130-
</Option>
131148
<Option disabled={!settings.showEditor}>
132149
Font-size
133150
<Input
@@ -137,17 +154,6 @@ function ShareSheet() {
137154
onChange={event => change({ fontSize: event.target.value })}
138155
/>
139156
</Option>
140-
<Option disabled={!settings.showEditor}>
141-
Highlight lines (with CodeMirror)
142-
<Input
143-
type="text"
144-
defaultValue={settings.highlightLines}
145-
onChange={event =>
146-
change({ highlightLines: event.target.value })
147-
}
148-
disabled={!settings.showEditor}
149-
/>
150-
</Option>
151157
</Section>
152158

153159
<Section title="Preview">
@@ -182,18 +188,44 @@ function ShareSheet() {
182188
/>
183189
</Option>
184190
</Section>
185-
<Section title="Advanced Options">
191+
<Section title="Advanced Options" disabled={!settings.showEditor}>
186192
<Option>
187193
Use CodeMirror insted of Monaco
188-
<Switch on />
194+
<Switch
195+
on={settings.useCodeMirror}
196+
onChange={() => toggle('useCodeMirror')}
197+
disabled={!settings.showEditor}
198+
/>
199+
</Option>
200+
<Option disabled={!settings.useCodeMirror}>
201+
Highlight lines (with CodeMirror)
202+
<Input
203+
type="text"
204+
defaultValue={settings.highlightLines}
205+
placeholder="1,2,3"
206+
onChange={event =>
207+
change({ highlightLines: event.target.value })
208+
}
209+
disabled={!settings.useCodeMirror}
210+
/>
189211
</Option>
190212
<Option>
191-
Enable eslint (bigger bundle size)
192-
<Switch />
213+
Enable ESLint (bigger bundle size)
214+
<Switch
215+
on={settings.enableESLint}
216+
onChange={() => toggle('enableESLint')}
217+
/>
193218
</Option>
194219
<Option multiline>
195220
Project Initial Path
196-
<Input placeholder="e.g. /home" />
221+
<Input
222+
placeholder="e.g. /home"
223+
onChange={event =>
224+
change({
225+
initialPath: event.target.value,
226+
})
227+
}
228+
/>
197229
</Option>
198230
</Section>
199231
<Section.Body>
@@ -202,7 +234,7 @@ function ShareSheet() {
202234
code
203235
rows="5"
204236
readOnly
205-
value={`<iframe src="https://codesandbox.io/embed/portfolio-danny-ruchtie-4q2i9?autoresize=1&fontsize=14" title="Portfolio Danny Ruchtie"`}
237+
value={getUrl(settings, darkMode)}
206238
/>
207239
<Button>Copy Embed Code</Button>
208240
<Option multiline>
@@ -224,27 +256,4 @@ function ShareSheet() {
224256
);
225257
}
226258

227-
function getUrl(settings, darkMode) {
228-
const flags = {
229-
hidenavigation: settings.showNavigation ? 0 : 1,
230-
theme: darkMode ? 'dark' : 'light',
231-
fontsize: 14,
232-
expanddevtools: settings.expandDevTools ? 1 : null,
233-
hidedevtools: settings.expandDevTools ? 0 : 1,
234-
view:
235-
settings.showEditor && settings.showPreview
236-
? 'split'
237-
: settings.showEditor
238-
? 'editor'
239-
: 'preview',
240-
previewwindow: settings.showTests ? 'tests' : null,
241-
};
242-
243-
const stringified = queryString.stringify(flags, { skipNull: true });
244-
const url =
245-
`https://codesandbox.io/embed/dark-magic-variant-5pj49?` + stringified;
246-
247-
return url;
248-
}
249-
250259
export default ShareSheet;

0 commit comments

Comments
 (0)