feat(ui): render the Street Level panel from a store

The panel's markup moves, verbatim, into StreetLevelPanel, which renders
the presentation StreetLevelControls publishes to the gev-street-level
store, with the EXPAND state. The controls keep their listeners, full
screen and popover handling, focus moves, resizing and transitions. The
SINCE readout follows the thumb while dragging and shows the recorded
window once the thumb is there; the thumb never moves under the user's
hand. Text the panel now renders itself drops its data-i18n markers.
Panels lifted out of a view live in src/ui/views/panels/, kept out of
Prettier like the views.
This commit is contained in:
Sameh Khamis committed 2026-10-30 20:43:42 -07:00
1 parent 3a2acf9b0f
commit e6aee52ea0
8 files changed
+500 -528

No files matched your search

+80
View File
@@ -0,0 +1,80 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* @typedef {object} StreetLevelHandlers
* @property {(stop: number) => void} setSinceStop Record a SINCE stop.
* @property {(stop: number) => string} describeSinceStop A stop's readout.
*/
/**
* The Street Level panel as its view renders it. StreetLevelControls owns
* the presentation (`presentStreetLevelPanel()`), the viewer and EXPAND: it
* publishes here and attaches the actions the view forwards.
*/
export const useStreetLevelStore = defineStore('gev-street-level', () => {
/** The presented panel; null until an owner renders, then its last render. */
const view = shallowRef(null);
/** Whether EXPAND has the viewer full screen; null until first synced. */
const expanded = shallowRef(null);
/** False on a page with neither element fullscreen nor popovers. */
const expandAvailable = shallowRef(true);
/** @type {{handlers: StreetLevelHandlers}|null} */
let owner = null;
/**
* Present the panel for an owner, replacing any earlier owner.
* @param {StreetLevelHandlers} handlers
* @returns {object} Token for detach().
*/
function attach(handlers) {
owner = { handlers };
return owner;
}
/** @param {object} next A fresh presentation; every publish re-renders. */
function publish(next) {
view.value = markRaw(next);
}
/** @param {boolean} on */
function setExpanded(on) {
expanded.value = Boolean(on);
}
/** @param {boolean} available */
function setExpandAvailable(available) {
expandAvailable.value = Boolean(available);
}
/**
* Stop forwarding actions to the owner holding `token`. The panel keeps
* its last render, as the page did when its controls were wired by hand.
*/
function detach(token) {
if (owner === token) owner = null;
}
/** Forward a view action to the owner. */
function act(name, ...args) {
owner?.handlers[name]?.(...args);
}
/** The readout of a SINCE stop while its thumb is dragged. */
function describeSinceStop(stop) {
return owner?.handlers.describeSinceStop?.(stop) ?? '';
}
return {
view,
expanded,
expandAvailable,
attach,
publish,
setExpanded,
setExpandAvailable,
detach,
act,
describeSinceStop,
};
});