diff --git a/src/App.css b/src/App.css index 0056c62..be08fb6 100644 --- a/src/App.css +++ b/src/App.css @@ -108,17 +108,22 @@ code { overflow-y: scroll; } -@media only screen and (max-width: 450px) { +@media only screen and (max-width: 1400px) { .page { flex-direction: column; } .left-pane { width: 100%; + height: calc(50vh - 3rem); + margin-right: 0; } .right-pane { width: 100%; + height: 42vh; + margin-left: 0; + margin-top: 0.6rem; } .links { diff --git a/src/Editor.jsx b/src/Editor.jsx index 5d2f6b5..6c2a0a6 100644 --- a/src/Editor.jsx +++ b/src/Editor.jsx @@ -1,10 +1,25 @@ +import { useState, useEffect } from 'react' import AceEditor from 'react-ace' import 'ace-builds/src-noconflict/mode-flix' import 'ace-builds/src-noconflict/theme-xcode' import 'ace-builds/src-noconflict/theme-tomorrow_night' +function useMediaQuery(query) { + const [matches, setMatches] = useState(() => window.matchMedia(query).matches) + useEffect(() => { + const mql = window.matchMedia(query) + const handler = e => setMatches(e.matches) + mql.addEventListener('change', handler) + return () => mql.removeEventListener('change', handler) + }, [query]) + return matches +} + export default function Editor({ code, notifyOnChange, isDark }) { + const isSmallScreen = useMediaQuery('(max-width: 1400px)') + const editorHeight = isSmallScreen ? 'calc(50vh - 3.5rem)' : 'calc(100vh - 5.8rem)' + return (