|
17 | 17 | /* └─ */ layers: 55, |
18 | 18 | } as const; |
19 | 19 |
|
20 | | - let panelSizes: Record<string, number> = PANEL_SIZES; |
| 20 | + let panelSizes: Record<string, number> = { ...PANEL_SIZES }; |
21 | 21 | let documentPanel: Panel | undefined; |
22 | 22 | let gutterResizeRestore: [number, number] | undefined = undefined; |
23 | 23 | let pointerCaptureId: number | undefined = undefined; |
|
41 | 41 | const editor = getContext<EditorWrapper>("editor"); |
42 | 42 | const portfolio = getContext<PortfolioStore>("portfolio"); |
43 | 43 |
|
| 44 | + function isPanelName(name: string): name is keyof typeof PANEL_SIZES { |
| 45 | + return name in PANEL_SIZES; |
| 46 | + } |
| 47 | +
|
| 48 | + function resetPanelSizes(e: MouseEvent) { |
| 49 | + const gutter = e.currentTarget; |
| 50 | + if (!(gutter instanceof HTMLDivElement)) return; |
| 51 | +
|
| 52 | + const nextSibling = gutter.nextElementSibling; |
| 53 | + const prevSibling = gutter.previousElementSibling; |
| 54 | + if (!(nextSibling instanceof HTMLDivElement) || !(prevSibling instanceof HTMLDivElement)) return; |
| 55 | +
|
| 56 | + const nextSiblingName = nextSibling.getAttribute("data-subdivision-name") || undefined; |
| 57 | + const prevSiblingName = prevSibling.getAttribute("data-subdivision-name") || undefined; |
| 58 | + if (!nextSiblingName || !prevSiblingName || !isPanelName(nextSiblingName) || !isPanelName(prevSiblingName)) return; |
| 59 | +
|
| 60 | + panelSizes = { ...panelSizes, [nextSiblingName]: PANEL_SIZES[nextSiblingName], [prevSiblingName]: PANEL_SIZES[prevSiblingName] }; |
| 61 | + } |
| 62 | +
|
44 | 63 | function resizePanel(e: PointerEvent) { |
45 | 64 | const gutter = e.target; |
46 | 65 | if (!(gutter instanceof HTMLDivElement)) return; |
|
157 | 176 | /> |
158 | 177 | </LayoutRow> |
159 | 178 | {#if $portfolio.dataPanelOpen} |
160 | | - <LayoutRow class="workspace-grid-resize-gutter" data-gutter-vertical on:pointerdown={(e) => resizePanel(e)} /> |
| 179 | + <LayoutRow class="workspace-grid-resize-gutter" data-gutter-vertical on:pointerdown={(e) => resizePanel(e)} on:dblclick={(e) => resetPanelSizes(e)} /> |
161 | 180 | <LayoutRow class="workspace-grid-subdivision" styles={{ "flex-grow": panelSizes["data"] }} data-subdivision-name="data"> |
162 | 181 | <Panel panelType="Data" tabLabels={[{ name: "Data" }]} tabActiveIndex={0} /> |
163 | 182 | </LayoutRow> |
164 | 183 | {/if} |
165 | 184 | </LayoutCol> |
166 | 185 | {#if $portfolio.propertiesPanelOpen || $portfolio.layersPanelOpen} |
167 | | - <LayoutCol class="workspace-grid-resize-gutter" data-gutter-horizontal on:pointerdown={(e) => resizePanel(e)} /> |
| 186 | + <LayoutCol class="workspace-grid-resize-gutter" data-gutter-horizontal on:pointerdown={(e) => resizePanel(e)} on:dblclick={(e) => resetPanelSizes(e)} /> |
168 | 187 | <LayoutCol class="workspace-grid-subdivision" styles={{ "flex-grow": panelSizes["details"] }} data-subdivision-name="details"> |
169 | 188 | {#if $portfolio.propertiesPanelOpen} |
170 | 189 | <LayoutRow class="workspace-grid-subdivision" styles={{ "flex-grow": panelSizes["properties"] }} data-subdivision-name="properties"> |
171 | 190 | <Panel panelType="Properties" tabLabels={[{ name: "Properties" }]} tabActiveIndex={0} /> |
172 | 191 | </LayoutRow> |
173 | 192 | {/if} |
174 | 193 | {#if $portfolio.propertiesPanelOpen && $portfolio.layersPanelOpen} |
175 | | - <LayoutRow class="workspace-grid-resize-gutter" data-gutter-vertical on:pointerdown={(e) => resizePanel(e)} /> |
| 194 | + <LayoutRow class="workspace-grid-resize-gutter" data-gutter-vertical on:pointerdown={(e) => resizePanel(e)} on:dblclick={(e) => resetPanelSizes(e)} /> |
176 | 195 | {/if} |
177 | 196 | {#if $portfolio.layersPanelOpen} |
178 | 197 | <LayoutRow class="workspace-grid-subdivision" styles={{ "flex-grow": panelSizes["layers"] }} data-subdivision-name="layers"> |
|
0 commit comments