@@ -2,12 +2,19 @@ import Fullscreen from '@codesandbox/common/lib/components/flex/Fullscreen';
2
2
import getTemplateDefinition from '@codesandbox/common/lib/templates' ;
3
3
import codesandbox from '@codesandbox/common/lib/themes/codesandbox.json' ;
4
4
import { REDESIGNED_SIDEBAR } from '@codesandbox/common/lib/utils/feature-flags' ;
5
- import { ThemeProvider as NewThemeProvider } from '@codesandbox/components' ;
5
+ import {
6
+ ThemeProvider as NewThemeProvider ,
7
+ Stack ,
8
+ Element ,
9
+ } from '@codesandbox/components' ;
10
+ import css from '@styled-system/css' ;
6
11
import { useOvermind } from 'app/overmind' ;
7
12
import { templateColor } from 'app/utils/template-color' ;
8
13
import React , { useEffect , useRef , useState } from 'react' ;
9
14
import SplitPane from 'react-split-pane' ;
10
15
import styled , { ThemeProvider } from 'styled-components' ;
16
+ import VERSION from '@codesandbox/common/lib/version' ;
17
+ import VisuallyHidden from '@reach/visually-hidden' ;
11
18
12
19
import Content from './Content' ;
13
20
import { Container } from './elements' ;
@@ -188,18 +195,33 @@ const Editor = () => {
188
195
) : null }
189
196
</ div >
190
197
191
- < StatusBar
192
- style = { {
193
- position : 'fixed' ,
194
- display : statusBar ? 'block' : 'none' ,
195
- bottom : 0 ,
196
- left : 0 ,
197
- right : 0 ,
198
- height : STATUS_BAR_SIZE ,
199
- } }
200
- className = "monaco-workbench mac nopanel"
201
- ref = { statusbarEl }
202
- />
198
+ < NewThemeProvider theme = { localState . theme . vscodeTheme } >
199
+ < Stack
200
+ justify = "space-between"
201
+ align = "center"
202
+ className = ".monaco-workbench"
203
+ css = { css ( {
204
+ backgroundColor : 'statusBar.background' ,
205
+ color : 'statusBar.foreground' ,
206
+ position : 'fixed' ,
207
+ display : statusBar ? 'flex' : 'none' ,
208
+ bottom : 0 ,
209
+ right : 0 ,
210
+ left : 0 ,
211
+ width : '100%' ,
212
+ height : STATUS_BAR_SIZE ,
213
+ } ) }
214
+ >
215
+ < FakeStatusBarText >
216
+ Version: { VERSION . split ( '-' ) . pop ( ) }
217
+ </ FakeStatusBarText >
218
+ < StatusBar
219
+ className = "monaco-workbench mac nopanel"
220
+ ref = { statusbarEl }
221
+ style = { { width : 'calc(100% - 126px)' } }
222
+ />
223
+ </ Stack >
224
+ </ NewThemeProvider >
203
225
</ Fullscreen >
204
226
205
227
< ForkFrozenSandboxModal />
@@ -212,3 +234,49 @@ const Editor = () => {
212
234
} ;
213
235
214
236
export default Editor ;
237
+
238
+ /** To use the same styles + behavior of the vscode status bar,
239
+ * we recreate the html structure outside of the status bar
240
+ * the code is garbage
241
+ */
242
+ /* eslint-disable */
243
+ const FakeStatusBarText = props => {
244
+ const [ copied , setCopied ] = React . useState ( false ) ;
245
+
246
+ const copyText = ( ) => {
247
+ const inputElement = document . querySelector ( '#status-bar-version' ) ;
248
+ // @ts -ignore it's not even a button!
249
+ inputElement . select ( ) ;
250
+ document . execCommand ( 'copy' ) ;
251
+ setCopied ( true ) ;
252
+ window . setTimeout ( ( ) => setCopied ( false ) , 2000 ) ;
253
+ } ;
254
+
255
+ return (
256
+ < Element
257
+ as = "span"
258
+ className = "part statusbar"
259
+ css = { css ( {
260
+ width : 'auto !important' ,
261
+ minWidth : '120px' ,
262
+ color : 'statusBar.foreground' ,
263
+ } ) }
264
+ { ...props }
265
+ >
266
+ < span className = "statusbar-item" style = { { paddingLeft : '10px' } } >
267
+ < a
268
+ title = "Copy version"
269
+ style = { { color : 'inherit' , padding : '0 5px' } }
270
+ onClick = { copyText }
271
+ >
272
+ { copied ? 'Copied!' : props . children }
273
+ </ a >
274
+
275
+ < VisuallyHidden >
276
+ < input id = "status-bar-version" defaultValue = { props . children } />
277
+ </ VisuallyHidden >
278
+ </ span >
279
+ </ Element >
280
+ ) ;
281
+ } ;
282
+ /* eslint-enable */
0 commit comments