@@ -4,7 +4,6 @@ import { useDispatch, useSelector } from 'react-redux';
44import { useTranslation } from 'react-i18next' ;
55import { Helmet } from 'react-helmet' ;
66import SplitPane from 'react-split-pane' ;
7- import MediaQuery from 'react-responsive' ;
87import IDEKeyHandlers from '../components/IDEKeyHandlers' ;
98import Sidebar from '../components/Sidebar' ;
109import PreviewFrame from '../components/PreviewFrame' ;
@@ -27,6 +26,7 @@ import {
2726 PreviewWrapper
2827} from '../components/Editor/MobileEditor' ;
2928import IDEOverlays from '../components/IDEOverlays' ;
29+ import useIsMobile from '../hooks/useIsMobile' ;
3030
3131function getTitle ( project ) {
3232 const { id } = project ;
@@ -90,6 +90,7 @@ function WarnIfUnsavedChanges() {
9090export const CmControllerContext = React . createContext ( { } ) ;
9191
9292const IDEView = ( ) => {
93+ const isMobile = useIsMobile ( ) ;
9394 const ide = useSelector ( ( state ) => state . ide ) ;
9495 const preferences = useSelector ( ( state ) => state . preferences ) ;
9596 const project = useSelector ( ( state ) => state . project ) ;
@@ -175,115 +176,111 @@ const IDEView = () => {
175176 < CmControllerContext . Provider value = { cmRef } >
176177 < Header syncFileContent = { syncFileContent } />
177178 </ 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+ >
182249 < SplitPane
183- split = "vertical"
184- size = { ide . sidebarIsExpanded ? sidebarSize : 20 }
250+ split = "horizontal"
251+ primary = "second"
252+ size = { currentConsoleSize }
253+ minSize = { consoleCollapsedSize }
185254 onChange = { ( size ) => {
186- setSidebarSize ( size ) ;
255+ setConsoleSize ( size ) ;
187256 } }
188- allowResize = { ide . sidebarIsExpanded }
189- minSize = { 150 }
257+ allowResize = { ide . consoleIsExpanded }
258+ className = "editor-preview-subpanel"
190259 >
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 ;
207263 } }
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 />
241266 </ 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" >
266274 < PreviewFrame
267- fullView
268- hide = { ! ide . isPlaying }
269275 cmController = { cmRef . current }
270276 isOverlayVisible = { isOverlayVisible }
271277 />
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+ ) }
287284 < IDEOverlays />
288285 </ RootPage >
289286 ) ;
0 commit comments