diff --git a/public/css/style.css b/public/css/style.css index 4e0a219..fe22a58 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -2290,9 +2290,13 @@ body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .pr color: #c3c2b7; } +.plugins-panel__body { + padding: 8px 12px; + overflow-y: auto; +} + .plugins-panel__hint { margin: 0 0 6px; - max-width: 200px; color: #888; font-size: 11px; } @@ -2342,7 +2346,7 @@ body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .pr font-size: 11px; /* Overrides the parent's nowrap: "Running…"/"Done" never wrap either way, but a real RunError message (e.g. "plugin exited with status 1") - needs to, or it just overflows the flyout unreadably. */ + needs to, or it just overflows the panel unreadably. */ white-space: normal; } diff --git a/public/js/plugins.js b/public/js/plugins.js index 2c6a983..a45674b 100644 --- a/public/js/plugins.js +++ b/public/js/plugins.js @@ -1,7 +1,7 @@ import { PLUGIN_ICON } from "/js/icons.js"; -import { notifyGpxStoreChanged } from "/js/panels.js"; +import { notifyGpxStoreChanged, notifySidePanelOpen, onlyOneSidePanelOpen } from "/js/panels.js"; -// A sidebar flyout listing whatever import plugins are on disk (see +// A side panel (#plugins-panel) listing whatever import plugins are on disk (see // lib/maptool/plugins.rb for the contract) — each one just a "Run for // this area" button using the current map viewport as the bbox, so there's // no separate area-picker to build: pan/zoom to where you want, click Run. @@ -16,27 +16,28 @@ export class PluginsControl { mount(sidebar) { this._container = document.createElement("div"); this._container.className = "sidebar-item"; - this._container.innerHTML = ` - -
- `; + this._container.innerHTML = ``; this._icon = this._container.querySelector(".sidebar-icon"); - this._flyout = this._container.querySelector(".sidebar-flyout"); - this._list = this._container.querySelector(".plugins-panel__list"); + this._icon.addEventListener("click", () => this._togglePanel()); - this._icon.addEventListener("click", () => { - const opening = this._flyout.hidden; - this._flyout.hidden = !opening; - this._icon.classList.toggle("active", opening); - if (opening) this._loadPlugins(); - }); + this._panel = document.getElementById("plugins-panel"); + this._list = this._panel.querySelector(".plugins-panel__list"); + this._panel.querySelector(".basemap-panel__close").addEventListener("click", () => this._togglePanel(false)); + onlyOneSidePanelOpen(this._panel, () => this._icon.classList.remove("active")); sidebar.appendChild(this._container); } + _togglePanel(force) { + const open = force === undefined ? this._panel.hidden : force; + this._panel.hidden = !open; + this._icon.classList.toggle("active", open); + if (open) { + notifySidePanelOpen(this._panel); + this._loadPlugins(); + } + } + async _loadPlugins() { this._list.innerHTML = `Runs for whatever area is currently on screen.
+