@@ -4,7 +4,6 @@ import { useDispatch, useSelector } from 'react-redux';
4
4
import { useTranslation } from 'react-i18next' ;
5
5
import { Helmet } from 'react-helmet' ;
6
6
import SplitPane from 'react-split-pane' ;
7
- import MediaQuery from 'react-responsive' ;
8
7
import IDEKeyHandlers from '../components/IDEKeyHandlers' ;
9
8
import Sidebar from '../components/Sidebar' ;
10
9
import PreviewFrame from '../components/PreviewFrame' ;
@@ -27,6 +26,7 @@ import {
27
26
PreviewWrapper
28
27
} from '../components/Editor/MobileEditor' ;
29
28
import IDEOverlays from '../components/IDEOverlays' ;
29
+ import useIsMobile from '../hooks/useIsMobile' ;
30
30
31
31
function getTitle ( project ) {
32
32
const { id } = project ;
@@ -90,6 +90,7 @@ function WarnIfUnsavedChanges() {
90
90
export const CmControllerContext = React . createContext ( { } ) ;
91
91
92
92
const IDEView = ( ) => {
93
+ const isMobile = useIsMobile ( ) ;
93
94
const ide = useSelector ( ( state ) => state . ide ) ;
94
95
const preferences = useSelector ( ( state ) => state . preferences ) ;
95
96
const project = useSelector ( ( state ) => state . project ) ;
@@ -175,115 +176,111 @@ const IDEView = () => {
175
176
< CmControllerContext . Provider value = { cmRef } >
176
177
< Header syncFileContent = { syncFileContent } />
177
178
</ CmControllerContext . Provider >
178
- < MediaQuery minWidth = { 770 } >
179
- { ( matches ) =>
180
- matches ? (
181
- < main className = "editor-preview-container" >
179
+ { isMobile ? (
180
+ < >
181
+ < FloatingActionButton
182
+ syncFileContent = { syncFileContent }
183
+ offsetBottom = { ide . isPlaying ? currentConsoleSize : 0 }
184
+ />
185
+ < PreviewWrapper show = { ide . isPlaying } >
186
+ < SplitPane
187
+ style = { { position : 'static' } }
188
+ split = "horizontal"
189
+ primary = "second"
190
+ size = { currentConsoleSize }
191
+ minSize = { consoleCollapsedSize }
192
+ onChange = { ( size ) => {
193
+ setConsoleSize ( size ) ;
194
+ setIsOverlayVisible ( true ) ;
195
+ } }
196
+ onDragFinished = { ( ) => {
197
+ setIsOverlayVisible ( false ) ;
198
+ } }
199
+ allowResize = { ide . consoleIsExpanded }
200
+ className = "editor-preview-subpanel"
201
+ >
202
+ < PreviewFrame
203
+ fullView
204
+ hide = { ! ide . isPlaying }
205
+ cmController = { cmRef . current }
206
+ isOverlayVisible = { isOverlayVisible }
207
+ />
208
+ < Console />
209
+ </ SplitPane >
210
+ </ PreviewWrapper >
211
+ < EditorSidebarWrapper show = { ! ide . isPlaying } >
212
+ < Sidebar />
213
+ < Editor
214
+ provideController = { ( ctl ) => {
215
+ cmRef . current = ctl ;
216
+ } }
217
+ />
218
+ </ EditorSidebarWrapper >
219
+ </ >
220
+ ) : (
221
+ < main className = "editor-preview-container" >
222
+ < SplitPane
223
+ split = "vertical"
224
+ size = { ide . sidebarIsExpanded ? sidebarSize : 20 }
225
+ onChange = { ( size ) => {
226
+ setSidebarSize ( size ) ;
227
+ } }
228
+ allowResize = { ide . sidebarIsExpanded }
229
+ minSize = { 150 }
230
+ >
231
+ < Sidebar />
232
+ < SplitPane
233
+ split = "vertical"
234
+ maxSize = { MaxSize * 0.965 }
235
+ defaultSize = "50%"
236
+ onChange = { ( ) => {
237
+ setIsOverlayVisible ( true ) ;
238
+ } }
239
+ onDragFinished = { ( ) => {
240
+ setIsOverlayVisible ( false ) ;
241
+ } }
242
+ resizerStyle = { {
243
+ borderLeftWidth : '2px' ,
244
+ borderRightWidth : '2px' ,
245
+ width : '2px' ,
246
+ margin : '0px 0px'
247
+ } }
248
+ >
182
249
< SplitPane
183
- split = "vertical"
184
- size = { ide . sidebarIsExpanded ? sidebarSize : 20 }
250
+ split = "horizontal"
251
+ primary = "second"
252
+ size = { currentConsoleSize }
253
+ minSize = { consoleCollapsedSize }
185
254
onChange = { ( size ) => {
186
- setSidebarSize ( size ) ;
255
+ setConsoleSize ( size ) ;
187
256
} }
188
- allowResize = { ide . sidebarIsExpanded }
189
- minSize = { 150 }
257
+ allowResize = { ide . consoleIsExpanded }
258
+ className = "editor-preview-subpanel"
190
259
>
191
- < Sidebar />
192
- < SplitPane
193
- split = "vertical"
194
- maxSize = { MaxSize * 0.965 }
195
- defaultSize = "50%"
196
- onChange = { ( ) => {
197
- setIsOverlayVisible ( true ) ;
198
- } }
199
- onDragFinished = { ( ) => {
200
- setIsOverlayVisible ( false ) ;
201
- } }
202
- resizerStyle = { {
203
- borderLeftWidth : '2px' ,
204
- borderRightWidth : '2px' ,
205
- width : '2px' ,
206
- margin : '0px 0px'
260
+ < Editor
261
+ provideController = { ( ctl ) => {
262
+ cmRef . current = ctl ;
207
263
} }
208
- >
209
- < SplitPane
210
- split = "horizontal"
211
- primary = "second"
212
- size = { currentConsoleSize }
213
- minSize = { consoleCollapsedSize }
214
- onChange = { ( size ) => {
215
- setConsoleSize ( size ) ;
216
- } }
217
- allowResize = { ide . consoleIsExpanded }
218
- className = "editor-preview-subpanel"
219
- >
220
- < Editor
221
- provideController = { ( ctl ) => {
222
- cmRef . current = ctl ;
223
- } }
224
- />
225
- < Console />
226
- </ SplitPane >
227
- < section className = "preview-frame-holder" >
228
- < header className = "preview-frame__header" >
229
- < h2 className = "preview-frame__title" >
230
- { t ( 'Toolbar.Preview' ) }
231
- </ h2 >
232
- </ header >
233
- < div className = "preview-frame__content" >
234
- < PreviewFrame
235
- cmController = { cmRef . current }
236
- isOverlayVisible = { isOverlayVisible }
237
- />
238
- </ div >
239
- </ section >
240
- </ SplitPane >
264
+ />
265
+ < Console />
241
266
</ SplitPane >
242
- </ main >
243
- ) : (
244
- < >
245
- < FloatingActionButton
246
- syncFileContent = { syncFileContent }
247
- offsetBottom = { ide . isPlaying ? currentConsoleSize : 0 }
248
- />
249
- < PreviewWrapper show = { ide . isPlaying } >
250
- < SplitPane
251
- style = { { position : 'static' } }
252
- split = "horizontal"
253
- primary = "second"
254
- size = { currentConsoleSize }
255
- minSize = { consoleCollapsedSize }
256
- onChange = { ( size ) => {
257
- setConsoleSize ( size ) ;
258
- setIsOverlayVisible ( true ) ;
259
- } }
260
- onDragFinished = { ( ) => {
261
- setIsOverlayVisible ( false ) ;
262
- } }
263
- allowResize = { ide . consoleIsExpanded }
264
- className = "editor-preview-subpanel"
265
- >
267
+ < section className = "preview-frame-holder" >
268
+ < header className = "preview-frame__header" >
269
+ < h2 className = "preview-frame__title" >
270
+ { t ( 'Toolbar.Preview' ) }
271
+ </ h2 >
272
+ </ header >
273
+ < div className = "preview-frame__content" >
266
274
< PreviewFrame
267
- fullView
268
- hide = { ! ide . isPlaying }
269
275
cmController = { cmRef . current }
270
276
isOverlayVisible = { isOverlayVisible }
271
277
/>
272
- < Console />
273
- </ SplitPane >
274
- </ PreviewWrapper >
275
- < EditorSidebarWrapper show = { ! ide . isPlaying } >
276
- < Sidebar />
277
- < Editor
278
- provideController = { ( ctl ) => {
279
- cmRef . current = ctl ;
280
- } }
281
- />
282
- </ EditorSidebarWrapper >
283
- </ >
284
- )
285
- }
286
- </ MediaQuery >
278
+ </ div >
279
+ </ section >
280
+ </ SplitPane >
281
+ </ SplitPane >
282
+ </ main >
283
+ ) }
287
284
< IDEOverlays />
288
285
</ RootPage >
289
286
) ;
0 commit comments