Import plugins: a side panel like the others (pinned/overlay, swaps with them) instead of a flyout
This commit is contained in:
1 parent
7ea5e72a2c
commit
21c5c2f21b
3 files changed
+36
-19
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+18
-17
@@ -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 = `
|
||||
<button type="button" class="sidebar-icon" title="Import plugins" aria-label="Import plugins">${PLUGIN_ICON}</button>
|
||||
<div class="sidebar-flyout" hidden>
|
||||
<p class="plugins-panel__hint">Runs for whatever area is currently on screen.</p>
|
||||
<ul class="plugins-panel__list"></ul>
|
||||
</div>
|
||||
`;
|
||||
this._container.innerHTML = `<button type="button" class="sidebar-icon" title="Import plugins" aria-label="Import plugins">${PLUGIN_ICON}</button>`;
|
||||
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 = `<li class="plugins-panel__empty">Loading…</li>`;
|
||||
let plugins;
|
||||
|
||||
@@ -104,6 +104,18 @@
|
||||
<div class="debug-panel__body"></div>
|
||||
</div>
|
||||
|
||||
<div id="plugins-panel" class="basemap-panel" hidden>
|
||||
<div class="basemap-panel__header">
|
||||
<strong>Import plugins</strong>
|
||||
<button type="button" class="basemap-panel__close" aria-label="Close">×</button>
|
||||
</div>
|
||||
<!-- Filled by PluginsControl (public/js/plugins.js), logged-in only. -->
|
||||
<div class="plugins-panel__body">
|
||||
<p class="plugins-panel__hint">Runs for whatever area is currently on screen.</p>
|
||||
<ul class="plugins-panel__list"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="route-panel" class="basemap-panel" hidden>
|
||||
<div class="basemap-panel__header">
|
||||
<strong>Route</strong>
|
||||
|
||||
Reference in new issue
Block a user