@@ -6,6 +6,7 @@ import Giscus from '@giscus/react';
66import Box from '@mui/material/Box' ;
77import Button from '@mui/material/Button' ;
88import Grid from '@mui/material/Grid' ;
9+ import Stack from '@mui/material/Stack' ;
910import { useTheme } from '@mui/material/styles' ;
1011import useMediaQuery from '@mui/material/useMediaQuery' ;
1112import { User } from '@supabase/supabase-js' ;
@@ -15,7 +16,7 @@ import PlayPauseButton from 'components/buttons/playpausebutton';
1516import RecordButton from 'components/buttons/recordbutton' ;
1617import ReloadButton from 'components/buttons/reloadbutton' ;
1718import ResetButton from 'components/buttons/resetbutton' ;
18- import ScaleButton from 'components/buttons/scalebutton ' ;
19+ import ResolutionButton from 'components/buttons/resolutionbutton ' ;
1920import VimButton from 'components/buttons/vimbutton' ;
2021import EntryPointDisplay from 'components/editor/entrypointdisplay' ;
2122import { MetadataEditor } from 'components/editor/metadataeditor' ;
@@ -43,21 +44,23 @@ interface EditorProps {
4344
4445function Comments ( ) {
4546 return (
46- < Giscus
47- id = "comments"
48- repo = "compute-toys/comments"
49- repoId = "R_kgDOKRTytw"
50- category = "Announcements"
51- categoryId = "DIC_kwDOKRTyt84CllQC"
52- mapping = "pathname"
53- strict = "0"
54- reactionsEnabled = "1"
55- emitMetadata = "1"
56- inputPosition = "top"
57- theme = "dark"
58- lang = "en"
59- loading = "lazy"
60- />
47+ < Box sx = { { marginTop : { xs : '2em' , sm : 0 } } } >
48+ < Giscus
49+ id = "comments"
50+ repo = "compute-toys/comments"
51+ repoId = "R_kgDOKRTytw"
52+ category = "Announcements"
53+ categoryId = "DIC_kwDOKRTyt84CllQC"
54+ mapping = "pathname"
55+ strict = "0"
56+ reactionsEnabled = "1"
57+ emitMetadata = "1"
58+ inputPosition = "top"
59+ theme = "dark"
60+ lang = "en"
61+ loading = "lazy"
62+ />
63+ </ Box >
6164 ) ;
6265}
6366
@@ -74,9 +77,6 @@ export default function Editor(props: EditorProps) {
7477 } , [ ] ) ;
7578
7679 const Timer = dynamic ( ( ) => import ( 'components/timer' ) , { ssr : false } ) ;
77- const Resolution = dynamic ( ( ) => import ( 'components/resolution' ) , {
78- ssr : false
79- } ) ;
8080
8181 let metadataEditor : JSX . Element | null = null ;
8282 if ( supabase && ! props . standalone ) {
@@ -102,6 +102,40 @@ export default function Editor(props: EditorProps) {
102102 } ;
103103 }
104104
105+ const theme = useTheme ( ) ;
106+ const isMobile = useMediaQuery ( theme . breakpoints . down ( 'md' ) ) ;
107+
108+ const monacoOptions = ( isMobile : boolean ) => ( {
109+ stopRenderingLineAfter : isMobile ? 500 : 1000 ,
110+ fontSize : isMobile ? 12 : 12 ,
111+ lineHeight : isMobile ? 16 : 18 ,
112+ fontFamily : "'Fira Code', monospace" ,
113+ 'bracketPairColorization.enabled' : true ,
114+ mouseWheelZoom : true ,
115+ minimap : { enabled : ! isMobile } ,
116+ scrollBeyondLastLine : ! isMobile ,
117+ automaticLayout : true ,
118+ lineNumbersMinChars : isMobile ? 3 : 4
119+ } ) ;
120+
121+ const monacoEditorWithButtons = (
122+ < ItemWithTransitionSignal transitionAtom = { saveColorTransitionSignalAtom } >
123+ < div className = "vim-status" > </ div >
124+ < Monaco editorOptions = { monacoOptions ( isMobile ) } />
125+ < Box sx = { { paddingTop : '4px' } } >
126+ < Box sx = { { display : 'flex' , justifyContent : 'space-between' } } >
127+ < Button style = { { pointerEvents : 'none' } } />
128+ < div >
129+ < ReloadButton />
130+ < HotReloadToggle />
131+ < Explainer />
132+ </ div >
133+ < VimButton />
134+ </ Box >
135+ </ Box >
136+ </ ItemWithTransitionSignal >
137+ ) ;
138+
105139 const leftPanel = (
106140 < div ref = { renderParentNodeRef } >
107141 < ItemWithTransitionSignal transitionAtom = { saveColorTransitionSignalAtom } >
@@ -117,61 +151,63 @@ export default function Editor(props: EditorProps) {
117151 embed = { props . embed }
118152 />
119153 </ Frame >
120- < Grid container >
121- < Grid item sx = { { textAlign : 'left' } } xs = { 2 } >
122- < Timer />
154+ < Grid
155+ container
156+ sx = { {
157+ display : 'flex' ,
158+ alignItems : 'center' , // Vertically centers
159+ justifyContent : 'center' , // Horizontally centers
160+ height : '100%' , // Ensures vertical alignment works
161+ padding : '5px 5px 4px 5px' // top right bottom left
162+ } }
163+ >
164+ < Grid item xs = { 2 } >
165+ < Stack
166+ direction = "column"
167+ justifyContent = "flex-start"
168+ alignItems = "flex-start"
169+ >
170+ < Timer />
171+ </ Stack >
123172 </ Grid >
124- < Grid item xs = { 7 } >
173+ < Grid item xs = { 8 } >
125174 < PlayPauseButton />
126175 < ResetButton />
127176 < RecordButton />
128177 </ Grid >
129- < Grid item sx = { { textAlign : 'right' } } xs = { 3 } >
130- < Resolution />
131- < ScaleButton />
132- < FullscreenButton />
178+ < Grid item xs = { 2 } >
179+ < Stack direction = "column" justifyContent = "flex-end" alignItems = "flex-end" >
180+ < ResolutionButton />
181+ < FullscreenButton />
182+ </ Stack >
133183 </ Grid >
134184 </ Grid >
135185 < UniformSliders />
136186 </ ItemWithTransitionSignal >
137187 { metadataEditor }
138- { shaderID ? < Comments /> : null }
188+
189+ { /* Show code right after shader metadata on mobile */ }
190+ { isMobile && monacoEditorWithButtons }
191+
192+ { /* Don't show comments on mobile */ }
193+ { ! isMobile && ( shaderID ? < Comments /> : null ) }
139194 </ div >
140195 ) ;
141196
142- const theme = useTheme ( ) ;
143-
144197 const rightPanel = (
145198 < div >
146- < ItemWithTransitionSignal transitionAtom = { saveColorTransitionSignalAtom } >
147- < div className = "vim-status" > </ div >
148- < Monaco
149- editorOptions = { {
150- stopRenderingLineAfter : 1000 ,
151- fontFamily : "'Fira Code', monospace" ,
152- 'bracketPairColorization.enabled' : true ,
153- mouseWheelZoom : true
154- //fontLigatures: true,
155- } }
156- />
157- < Box sx = { { paddingTop : '4px' } } >
158- < Box sx = { { display : 'flex' , justifyContent : 'space-between' } } >
159- < Button style = { { pointerEvents : 'none' } } /> { ' ' }
160- { /* invisible button, used only for centering */ }
161- < div >
162- < ReloadButton />
163- < HotReloadToggle />
164- < Explainer />
165- </ div >
166- < VimButton />
167- </ Box >
168- </ Box >
169- </ ItemWithTransitionSignal >
199+ { ! isMobile && monacoEditorWithButtons }
170200 < Grid
171201 container
172202 spacing = { 2 }
173203 sx = { {
174- flexWrap : useMediaQuery ( theme . breakpoints . up ( 'sm' ) ) ? 'nowrap' : 'wrap'
204+ flexWrap : useMediaQuery ( theme . breakpoints . up ( 'sm' ) ) ? 'nowrap' : 'wrap' ,
205+ '@media (max-width: 600px)' : {
206+ '& > .MuiGrid-item' : {
207+ minHeight : 'none' ,
208+ maxHeight : '350px' // Prevents stretch on mobiles
209+ }
210+ }
175211 } }
176212 >
177213 < Grid item >
@@ -184,6 +220,7 @@ export default function Editor(props: EditorProps) {
184220 < EntryPointDisplay />
185221 </ Grid >
186222 </ Grid >
223+ { isMobile && ( shaderID ? < Comments /> : null ) }
187224 </ div >
188225 ) ;
189226
0 commit comments