Skip to content

Commit 5610e1d

Browse files
committed
feat: add a panels=collapsed embed layout option
Embeds could either show the side panels open or hide them entirely. This adds a middle ground that keeps the Layers and Style icon rails reachable while starting both panels collapsed, so an embed can lead with the map without giving up access to the panels.
1 parent 1196333 commit 5610e1d

5 files changed

Lines changed: 33 additions & 4 deletions

File tree

apps/geolibre-desktop/src/components/layout/DesktopShell.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,7 +2227,9 @@ export function DesktopShell({
22272227
// On a phone-width viewport both start collapsed (panels overlay
22282228
// there), matching the mobile "panels default collapsed" behavior.
22292229
initialBuiltinExpanded={
2230-
replaceLayersPanelId === BROWSER_PANEL_ID && !getIsMobileViewport()
2230+
replaceLayersPanelId === BROWSER_PANEL_ID &&
2231+
!getIsMobileViewport() &&
2232+
!layoutOptions.panelsCollapsed
22312233
}
22322234
// The story-map presentation is the only standalone Layers
22332235
// autoCollapse trigger (the notebook collapses Style, not Layers).
@@ -2267,7 +2269,11 @@ export function DesktopShell({
22672269
openRasterLayerPanel(createAppAPI(mapControllerRef))
22682270
}
22692271
onOpenRasterSubset={setRasterSubsetLayer}
2270-
autoCollapse={storymapPresenting || autoCollapsedPanel === "layers"}
2272+
autoCollapse={
2273+
storymapPresenting ||
2274+
layoutOptions.panelsCollapsed ||
2275+
autoCollapsedPanel === "layers"
2276+
}
22712277
/>
22722278
)}
22732279
</SectionErrorBoundary>
@@ -2508,7 +2514,10 @@ export function DesktopShell({
25082514
mapControllerRef={mapControllerRef}
25092515
onResizeStart={startStylePanelResize}
25102516
autoCollapse={
2511-
notebookOpen || storymapPresenting || autoCollapsedPanel === "style"
2517+
notebookOpen ||
2518+
storymapPresenting ||
2519+
layoutOptions.panelsCollapsed ||
2520+
autoCollapsedPanel === "style"
25122521
}
25132522
/>
25142523
</SectionErrorBoundary>

apps/geolibre-desktop/src/hooks/useLayoutOptions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export interface LayoutOptions {
1414
* shared rail — so a map-only embed shows nothing but the map.
1515
*/
1616
panelsHidden: boolean;
17+
/** Start the Layers and Style panels on their rails without hiding them. */
18+
panelsCollapsed: boolean;
1719
showProjectInfo: boolean;
1820
statusBarVisible: boolean;
1921
stylePanelVisible: boolean;
@@ -41,6 +43,7 @@ export function layoutOptionsFromLocation(layoutSettings: DesktopLayoutSettings)
4143
attributePanelVisible: true,
4244
compact: false,
4345
panelsHidden: false,
46+
panelsCollapsed: false,
4447
statusBarVisible: true,
4548
toolbarVisible: true,
4649
viewer: false,
@@ -67,6 +70,7 @@ export function layoutOptionsFromLocation(layoutSettings: DesktopLayoutSettings)
6770
mapOnly ||
6871
HIDDEN_PANEL_VALUES.has(panels) ||
6972
normalizedParam(params.get("hidePanels")) === "true";
73+
const panelsCollapsed = !panelsHidden && panels === "collapsed";
7074
const toolbarLabels =
7175
!compact && !ICON_TOOLBAR_VALUES.has(toolbar) ? layoutSettings.toolbarLabels : false;
7276
const showProjectInfo = compact ? false : layoutSettings.showProjectInfo;
@@ -82,6 +86,7 @@ export function layoutOptionsFromLocation(layoutSettings: DesktopLayoutSettings)
8286
compact,
8387
layerPanelVisible,
8488
panelsHidden,
89+
panelsCollapsed,
8590
showProjectInfo,
8691
statusBarVisible: !mapOnly,
8792
stylePanelVisible,

docs/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ https://web.geolibre.app/?url=https://share.geolibre.app/giswqs/3d-tiles.geolibr
152152

153153
Use `toolbar=icons` when you only want icon-only toolbar buttons. `panels=hidden`, `panels=hide`, `panels=off`, and `hidePanels=true` are accepted aliases for hiding panels.
154154

155+
Use `panels=collapsed` to keep the Layers and Style icon rails visible while
156+
starting both panels collapsed.
157+
155158
For a fully chrome-free, map-only embed, add `&maponly` to hide the toolbar menu, all panels, and the status bar:
156159

157160
```text

docs/user-guide/embedding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ A chrome-free `maponly` embed shows only the map, as in this shared 3D Tiles pro
2525
| `url` | `url=https://share.geolibre.app/you/project.geolibre.json` | Loads a `.geolibre.json` project from a public URL. |
2626
| `layout` | `layout=viewer` | `viewer` provides read-only chrome: Layers, View, Controls, basemaps, search/identify, and Help, with authoring UI hidden. `compact` is the icon-only full-app layout; `embed` and `iframe` are aliases. |
2727
| `toolbar` | `toolbar=icons` | Icon-only toolbar buttons without the full compact layout. `icon` and `icon-only` are aliases. |
28-
| `panels` | `panels=none` | Hides the Layers, Style, and Attribute table panels. `hidden`, `hide`, and `off` are aliases. |
28+
| `panels` | `panels=collapsed` | Starts Layers and Style collapsed to their icon rails. Use `none` to hide all panels; `hidden`, `hide`, and `off` are aliases. |
2929
| `hidePanels` | `hidePanels=true` | Alternative way to hide those panels. |
3030
| `maponly` | `maponly` | Hides all chrome (toolbar, panels, and status bar), leaving only the map. The bare flag or `true`, `1`, `yes`, `on` enable it. |
3131
| `welcome` | `welcome=0` | Hides the first-launch welcome wizard. Accepts `0`, `false`, `off`, or `no`. A `url=` deep link already suppresses it automatically. |

tests/layout-options.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ describe("layoutOptionsFromLocation", () => {
2929
assert.equal(options.stylePanelVisible, true);
3030
assert.equal(options.attributePanelVisible, true);
3131
assert.equal(options.panelsHidden, false);
32+
assert.equal(options.panelsCollapsed, false);
3233
});
3334

3435
it("hides every chrome element when maponly is set as a bare flag", () => {
@@ -88,6 +89,17 @@ describe("layoutOptionsFromLocation", () => {
8889
assert.equal(options.panelsHidden, true);
8990
});
9091

92+
it("starts side panels collapsed without hiding their rails", () => {
93+
withSearch("?panels=collapsed");
94+
const options = layoutOptionsFromLocation(DEFAULT_DESKTOP_LAYOUT_SETTINGS);
95+
assert.equal(options.toolbarVisible, true);
96+
assert.equal(options.layerPanelVisible, true);
97+
assert.equal(options.stylePanelVisible, true);
98+
assert.equal(options.attributePanelVisible, true);
99+
assert.equal(options.panelsHidden, false);
100+
assert.equal(options.panelsCollapsed, true);
101+
});
102+
91103
it("provides read-only viewer chrome between the full app and maponly", () => {
92104
withSearch("?layout=viewer");
93105
const options = layoutOptionsFromLocation(DEFAULT_DESKTOP_LAYOUT_SETTINGS);

0 commit comments

Comments
 (0)