diff --git a/src/pages/play/Playground.tsx b/src/pages/play/Playground.tsx index bf87134f..2db27127 100644 --- a/src/pages/play/Playground.tsx +++ b/src/pages/play/Playground.tsx @@ -14,6 +14,24 @@ import styles from "./styles.module.scss"; import { consoleFeedTheme, jsonTreeTheme } from "./themes"; import type { CustomTypeScriptWorker } from "./ts.worker"; +enum PanelKind { + Input, + Output, +} +interface PanelState { + activePanel: PanelKind; +} +interface PanelContext extends PanelState { + setActivePanel(panelID: PanelKind): void; +} + +const PanelContext = React.createContext(null!); + +function PanelContextProvider({ children }: { children: React.ReactNode }) { + const [activePanel, setActivePanel] = useState(PanelKind.Input); + + return {children}; +} interface EditorState { source: string; lua: string; @@ -67,8 +85,10 @@ function InputPane() { [], ); + const { activePanel } = useContext(PanelContext); + return ( -
+
-
{">_"}
-
+
+
{">_"}
+
+
- {isAstView ? "Lua AST" : "TEXT"} + {isAstView ? "Text" : "Lua AST"} Source Map @@ -178,6 +200,8 @@ function PlaygroundNavbar() { const tsMinor = tsVersion.split(".")[1]; const tsLink = `https://www.typescriptlang.org/docs/handbook/release-notes/typescript-${tsMajor}-${tsMinor}.html`; + const { activePanel, setActivePanel } = useContext(PanelContext); + return ( ); } @@ -198,13 +236,15 @@ function PlaygroundNavbar() { export default function Playground() { return ( <> - -
- - - - -
+ + +
+ + + + +
+
); } diff --git a/src/pages/play/styles.module.scss b/src/pages/play/styles.module.scss index 74b53450..0379cc98 100644 --- a/src/pages/play/styles.module.scss +++ b/src/pages/play/styles.module.scss @@ -38,6 +38,7 @@ $navbar-height: 50px; padding-left: 12px; display: flex; align-items: center; + justify-content: space-between; } .navbarVersions { @@ -46,6 +47,11 @@ $navbar-height: 50px; font-family: monospace; } +.navBarPanelSelection { + display: none; + padding-right: 12px; +} + .content { width: 100%; height: calc(100vh - var(--ifm-navbar-height) - #{$navbar-height}); @@ -80,14 +86,14 @@ $output-height: 180px; } } -.editorOutput { +.luaOutput { border-top: 1px var(--monaco-accent) solid; height: $output-height; font-family: Menlo, Monaco, "Lucida Console", "Courier New", monospace; display: flex; } -.editorOutputLineNumbers { +.luaOutputLineNumbers { width: 40px; height: 100%; border-right: 1px var(--monaco-accent) solid; @@ -95,7 +101,49 @@ $output-height: 180px; padding-left: 10px; } -.editorOutputTerminal { +.luaOutputTerminal { width: 100%; overflow-y: auto; } + +@media only screen and (max-width: 400px) { + .navbarVersions { + display: none; + } +} + +@media only screen and (max-width: 996px) { + .content { + flex-flow: column; + } + + .navBarPanelSelection { + display: block; + } + + .contentPane { + width: 100%; + } + + .contentPaneHiddenMobile { + display: none; + } + + .outputControls { + top: 0.5em; + right: 1em; + * { + --ifm-button-size-multiplier: 0.8; + } + } + + $output-height-mobile: 100px; + + .outputEditor { + height: calc(100% - #{$output-height-mobile}); + } + + .luaOutput { + height: $output-height-mobile; + } +}