|
20 | 20 | const EDITOR_OPEN_KEY = "glua-editor-open"; |
21 | 21 |
|
22 | 22 | function updatePanelWidths() { |
23 | | - if (consolePanel && !resizing) { |
24 | | - if ($isEditorOpen) { |
25 | | - const savedWidth = localStorage.getItem(EDITOR_WIDTH_KEY) || "33%"; |
26 | | - const consoleWidth = `calc(100% - ${savedWidth})`; |
27 | | - consolePanel.style.width = consoleWidth; |
28 | | - if (editorPanel) editorPanel.style.width = savedWidth; |
29 | | - } else { |
30 | | - consolePanel.style.width = "100%"; |
31 | | - } |
| 23 | + if (!consolePanel || resizing) return; |
| 24 | +
|
| 25 | + // On mobile, the layout is handled entirely by Tailwind responsive classes. |
| 26 | + // Clear any inline widths so the CSS can take over when crossing the breakpoint. |
| 27 | + const isDesktop = window.matchMedia("(min-width: 768px)").matches; |
| 28 | + if (!isDesktop) { |
| 29 | + consolePanel.style.width = ""; |
| 30 | + if (editorPanel) editorPanel.style.width = ""; |
| 31 | + return; |
| 32 | + } |
| 33 | +
|
| 34 | + if ($isEditorOpen) { |
| 35 | + const savedWidth = localStorage.getItem(EDITOR_WIDTH_KEY) || "33%"; |
| 36 | + const consoleWidth = `calc(100% - ${savedWidth})`; |
| 37 | + consolePanel.style.width = consoleWidth; |
| 38 | + if (editorPanel) editorPanel.style.width = savedWidth; |
| 39 | + } else { |
| 40 | + consolePanel.style.width = "100%"; |
32 | 41 | } |
33 | 42 | } |
34 | 43 |
|
|
49 | 58 | isEditorOpen.update((open) => !open); |
50 | 59 | } |
51 | 60 | }; |
| 61 | + const handleResize = () => updatePanelWidths(); |
52 | 62 | window.addEventListener("keydown", handleKeydown); |
53 | | - return () => window.removeEventListener("keydown", handleKeydown); |
| 63 | + window.addEventListener("resize", handleResize); |
| 64 | + return () => { |
| 65 | + window.removeEventListener("keydown", handleKeydown); |
| 66 | + window.removeEventListener("resize", handleResize); |
| 67 | + }; |
54 | 68 | }); |
55 | 69 |
|
56 | 70 | afterUpdate(() => { |
|
136 | 150 | </script> |
137 | 151 |
|
138 | 152 | <ScriptViewer /> |
139 | | -<main class="flex flex-row h-screen overflow-hidden"> |
| 153 | +<main class="flex flex-row h-dvh overflow-hidden relative"> |
140 | 154 | {#if view === "ip-limited"} |
141 | 155 | <IPLimited limit={ipLimit} /> |
142 | 156 | {:else if view === "modal"} |
|
172 | 186 | </div> |
173 | 187 | {#if $isEditorOpen} |
174 | 188 | <!-- svelte-ignore a11y-no-noninteractive-element-interactions --> |
175 | | - <div id="resizer" on:mousedown={handleMouseDown} role="separator" aria-orientation="vertical"></div> |
176 | | - <div bind:this={editorPanel} class="h-full" style="width: 33%;"> |
| 189 | + <div id="resizer" class="hidden md:block" on:mousedown={handleMouseDown} role="separator" aria-orientation="vertical"></div> |
| 190 | + <div bind:this={editorPanel} class="h-full absolute inset-0 z-30 md:relative md:inset-auto md:z-auto"> |
177 | 191 | <Editor {socket} /> |
178 | 192 | </div> |
179 | 193 | {/if} |
|
0 commit comments