Vue kit: Street Level's photo viewer is a view with kit buttons

The photo viewer KartaView and Panoramax share (photoViewer.js) no longer
builds its root, picture, panorama canvas and ‹ › buttons in script. It
presents them through subscribeView(), which the street-level layer
gathers in subscribePhotoViewer(); the application shell publishes that
to the gev-street-level-photo store, and StreetLevelPhotoViewer, beside
the Street Level panel in the layer panels, teleports the viewer into the
viewer host with the same classes, data attributes, labels and order. Its
‹ and › are ghost UiButtons. The view forwards keys, pointers, wheel, the
step clicks and a lost WebGL context to the viewer and hands each element
back: the canvas the panorama is drawn on (a fresh, keyed one after a lost
context, which an open now waits for), and the frame, picture, root and
buttons the viewer measures and keeps focus with. The viewer keeps every
decision: loading, upgrades, size limits, keys, drag, pinch, zoom, Esc on
the viewer's box and focus when a step button disables. The street-level
layer still needs no Vue; with no view subscribed these photos cannot
mount, which docs/VUE-MIGRATION.md records.

The provider and viewer tests draw the viewer with a fake view in
kartaViewFakes.mjs; StreetLevelPhotoViewer.test.mjs runs the real view on
a page, and streetLevelPhotoControls.test.mjs pins the kit controls. The
panel page's lost-graphics notice in globePanelRuntime.js stays built in
script, as the document now says.

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-19 13:33:58 -08:00
1 parent 9423a26487
commit 766364f691
20 files changed
+911 -112

No files matched your search

@@ -0,0 +1,78 @@
<script setup>
import { storeToRefs } from 'pinia';
import UiButton from '../../kit/UiButton.vue';
import { useStreetLevelPhotoStore } from '../../stores/streetLevelPhoto.js';
// The Street Level photo viewer of the providers whose photos are plain
// files (KartaView, Panoramax), in the viewer host the layer mounts it in.
// The viewer (src/layers/streetLevel/photoViewer.js) keeps every decision:
// which photo shows and how, its loading, the panorama it draws, the keys,
// drag and zoom. This view draws what it presents, forwards the events and
// hands each element back: the canvas it draws on, the frame and picture
// it measures, the root and buttons it keeps focus with.
const { photo } = storeToRefs(useStreetLevelPhotoStore());
/** Hand `name`'s element back to the viewer that presented it. */
const keep = (name) => (element) => {
if (element) photo.value?.actions.attach(name, element.$el ?? element);
};
// One function per element: a new one on each render would hand it back
// again each time.
const refs = {
root: keep('root'),
picture: keep('picture'),
canvas: keep('canvas'),
prev: keep('prev'),
next: keep('next'),
};
</script>
<template>
<Teleport v-if="photo" :to="photo.host"
><div
:ref="refs.root"
class="sl-photo-viewer"
:data-provider="photo.providerId"
tabindex="0"
role="group"
:aria-label="photo.label"
:data-kind="photo.kind"
@keydown="photo.actions.keydown"
><img
:ref="refs.picture"
class="sl-photo-flat"
:alt="photo.alt"
draggable="false"
:hidden="photo.kind !== 'flat'"
:src="photo.src ?? undefined"
:style="{ objectFit: photo.fit }" /><canvas
:key="photo.canvasKey"
:ref="refs.canvas"
class="sl-photo-pano"
:class="{ 'sl-photo-dragging': photo.dragging }"
:hidden="photo.kind !== 'pano'"
@pointerdown="photo.actions.pointerdown"
@pointermove="photo.actions.pointermove"
@pointerup="photo.actions.pointerup"
@pointercancel="photo.actions.pointerup"
@wheel="photo.actions.wheel"
@webglcontextlost="photo.actions.contextLost"
></canvas
><UiButton
:ref="refs.prev"
class="sl-photo-step sl-photo-step-prev"
:label="photo.prevLabel"
:disabled="photo.prevDisabled"
@click="photo.actions.step(-1, $event)"
>‹</UiButton
><UiButton
:ref="refs.next"
class="sl-photo-step sl-photo-step-next"
:label="photo.nextLabel"
:disabled="photo.nextDisabled"
@click="photo.actions.step(1, $event)"
>›</UiButton
></div
></Teleport
>
</template>