Stories: GEV scenes as stories on the live globe

A Stories button (top right) opens Explore: a feed of GEV scenes over
GEV's own Cesium globe, with a pin per story. Explore opens at country
level over the first story and, while idle, flies on from story to story
for a minute. A picked story is framed in the middle of the view; a pin
plays its story on a second click. The Story page plays the scene through
SceneDirector with a timeline, chapters, key moments, sources and
background, then Close (or Back) puts the person's camera, clock, layers,
style and AUTHORING selection back. Open in GEV hands the scene to the
Scenes panel at its current shot.

Stories lists the scenes GEV ships with a camera path (while they are in
the project), the scenes saved with SAVE TO STORIES in AUTHORING, and the
person's other scenes as drafts. The person's own stories live in the
project on this device, so they have no Share; a link to a story that is
not here opens Explore and says so. Each shipped story's
context comes from what GEV knows: what it shows, the place each shot goes,
and each layer's data sources as DATA_SOURCES.md lists them; the Nepal
story carries the event pack's facts and CC BY-NC sources. Card images are
a captured THUMBNAIL or drawn from the keyless Esri World Imagery.

AUTHORING has no scene picker: it starts with no scene, NEW SCENE (or
CAPTURE SHOT) makes one, and Stories' Open in GEV selects one. Before SAVE
TO STORIES it offers topic tags and THUMBNAIL. A scene's stories flag,
storyThumb and storyTags are saved with the project and kept through
export and import.

Only the closed state loads with the page; the screens, styles, story data
and controller load on first open. Stories keeps its place in the query
(one history entry per screen) and holds the share link's hash writes
while open. Keyboard input and voice tools stay with Stories while it is
open. Explore's pins move on every drawn frame without asking for frames;
the idle tour and tile settling are bounded.

All strings are translated in the 13 locales.
This commit is contained in:
Manjunath committed 2026-11-16 20:12:10 +05:30
1 parent da81cf743b
commit 5418438339
77 files changed
+14975 -260

No files matched your search

+782
View File
@@ -0,0 +1,782 @@
<script setup>
import {
computed,
nextTick,
onBeforeUnmount,
onMounted,
ref,
watch,
} from 'vue';
import { storeToRefs } from 'pinia';
import { t, tn } from '../../../i18n/index.js';
import { useStoriesStore } from '../../stores/stories.js';
import {
FILTERS,
clamp,
fmtDur,
layersFor,
metaFor,
topicsOf,
storyText,
windowText,
} from '../../../stories/storyMeta.js';
import StoriesHeader from './StoriesHeader.vue';
/**
* Explore (prototype `.scr-explore`): the feed beside GEV's Cesium globe,
* which shows through the map area and takes input where nothing of
* Stories sits on it.
*/
const emit = defineEmits(['play']);
const store = useStoriesStore();
const { query, chips, sort, filters, picked, pins, feedSnap } =
storeToRefs(store);
const all = computed(() => store.stories);
// A story's card picture, when there is one; otherwise the card shows its
// placeholder (CSS), never a broken image.
const thumbFor = (s) => (s && store.thumbs?.[s.id]) || '';
const titleOf = (s) => storyText(s.title);
const layerNames = (s) => layersFor(s).map((l) => storyText(l[2]));
// What a story is found by in the feed's search, in the page's language.
function searchText(s) {
const m = metaFor(s);
return [
titleOf(s),
s.creator,
windowText(s),
m.region,
m.place,
...m.topics,
...layerNames(s),
]
.join(' ')
.toLowerCase();
}
const shown = computed(() => {
const words = query.value.toLowerCase().split(/\s+/).filter(Boolean);
const f = filters.value;
const list = all.value.filter((s) => {
const m = metaFor(s);
const txt = searchText(s);
if (words.some((w) => !txt.includes(w))) return false;
if (
chips.value.length &&
!chips.value.some((c) => (c === 'Live' ? s.live : m.topics.includes(c)))
)
return false;
if (f.region?.length && !f.region.includes(m.region)) return false;
if (
f.length?.length &&
!f.length.includes(s.durationMs < 60000 ? 'short' : 'long')
)
return false;
return true;
});
const end = (s) => s.tMaxMs ?? 0;
const by = {
new: (a, b) => end(b) - end(a),
long: (a, b) => b.durationMs - a.durationMs,
az: (a, b) => titleOf(a).localeCompare(titleOf(b)),
}[sort.value];
return [...list].sort(by);
});
const shownIds = computed(() => new Set(shown.value.map((s) => s.id)));
const count = computed(() =>
shown.value.length === all.value.length
? `${all.value.length}`
: `${shown.value.length}/${all.value.length}`,
);
// ── Chips and filters ──
// Every story is a GEV scene: a "made with" filter would not narrow anything.
// The topic chips and region choices are the ones the stories carry, so
// none of them narrows the feed to nothing.
const topics = computed(() => topicsOf(all.value));
const filterGroups = computed(() =>
FILTERS.map(([key, label, opts]) => {
if (key !== 'region') return [key, label, opts];
const regions = new Set(all.value.map((s) => metaFor(s).region));
return [key, label, opts.filter(([value]) => regions.has(value))];
}).filter(([, , opts]) => opts.length > 1),
);
function toggleChip(c) {
if (!c) chips.value = [];
else if (chips.value.includes(c))
chips.value = chips.value.filter((x) => x !== c);
else chips.value = [...chips.value, c];
}
const filterOpen = ref(false);
const filterCount = computed(() =>
filterGroups.value.reduce(
(n, [key]) => n + (filters.value[key]?.length ?? 0),
0,
),
);
function toggleFilter(key, value, on) {
const list = filters.value[key] ?? [];
filters.value = {
...filters.value,
[key]: on ? [...list, value] : list.filter((v) => v !== value),
};
}
function clearFilters() {
filters.value = { region: [], length: [] };
}
function resetAll() {
clearFilters();
chips.value = [];
query.value = '';
filterOpen.value = false;
}
const filterEl = ref(null);
const filterBtn = ref(null);
function onDocDown(e) {
if (
filterOpen.value &&
!filterEl.value?.contains(e.target) &&
!filterBtn.value?.contains(e.target)
)
filterOpen.value = false;
}
// ── Search ──
const searchEl = ref(null);
function onSearchKey(e) {
if (e.key === 'Escape') {
query.value = '';
e.target.blur();
e.preventDefault();
} else if (e.key === 'Enter') {
const first = shown.value[0];
if (first) pick(first.id);
}
}
function onSlash(e) {
if (
e.key === '/' &&
!/INPUT|TEXTAREA|SELECT/.test(document.activeElement?.tagName ?? '')
) {
e.preventDefault();
searchEl.value?.focus();
}
}
function headerSearch() {
if (feedSnap.value === 'map') setFeed('split');
searchEl.value?.focus();
}
// ── Picking and playing ──
const feedEl = ref(null);
function pick(id) {
if (picked.value === id) return;
if (innerWidth <= 700 && feedSnap.value === 'list') setFeed('split');
store.controller.pick(id);
nextTick(() =>
feedEl.value
?.querySelector(`.card[data-id="${CSS.escape(id)}"]`)
?.scrollIntoView({ block: 'nearest', behavior: 'smooth' }),
);
}
function play(id, from) {
emit('play', { id, from });
}
function onCardKey(e, s) {
if ((e.key === 'Enter' || e.key === ' ') && e.target === e.currentTarget) {
e.preventDefault();
if (picked.value === s.id)
play(s.id, e.currentTarget.querySelector('.thumb'));
else pick(s.id);
}
}
// The pin last clicked: a pin plays on its own second click, so a story
// picked from the feed first shows its play button on the pin.
let armedPin = null;
watch(picked, (id) => {
if (id !== armedPin) armedPin = null;
});
function onPin(e, id) {
if (picked.value === id && armedPin === id)
play(id, e.currentTarget.querySelector('.pin-thumb'));
else {
armedPin = id;
if (picked.value !== id) pick(id);
}
}
const pickedStory = computed(() =>
picked.value ? store.byId(picked.value) : null,
);
// ── Pins: projected in window pixels, placed inside the map area ──
const pinsEl = ref(null);
const origin = ref({ x: 0, y: 0 });
function measure() {
const r = pinsEl.value?.getBoundingClientRect();
if (r) origin.value = { x: r.left, y: r.top };
}
watch(pins, measure);
const placedPins = computed(() =>
pins.value.map((p) => ({
...p,
story: store.byId(p.id),
style: {
transform: `translate(${p.x - origin.value.x}px, ${p.y - origin.value.y}px) translate(-50%, -100%)`,
},
})),
);
// ── Phone: drag the list header to trade globe space for list space ──
const FEED = { map: 0.3, split: 0.56, list: 0.86 };
const FEED_ORDER = ['map', 'split', 'list'];
const bodyEl = ref(null);
const dragging = ref(false);
const feedH = ref(null);
function setFeed(snap) {
feedSnap.value = snap;
feedH.value = null;
setTimeout(() => store.controller.reframe(), 320);
}
let fd = null;
function onHeadDown(e) {
if (innerWidth > 700 || e.target.closest('.fh-tools')) return;
try {
e.currentTarget.setPointerCapture(e.pointerId);
} catch {
/* nothing to capture */
}
const body = bodyEl.value;
fd = {
y: e.clientY,
frac: body.querySelector('.ex-feed').offsetHeight / body.clientHeight,
H: body.clientHeight,
lastY: e.clientY,
lastT: performance.now(),
v: 0,
moved: false,
};
}
function onHeadMove(e) {
if (!fd) return;
const dy = e.clientY - fd.y;
if (!fd.moved && Math.abs(dy) > 4) {
fd.moved = true;
dragging.value = true;
}
if (!fd.moved) return;
feedH.value = clamp(fd.frac - dy / fd.H, 0.18, 0.9);
const now = performance.now();
fd.v = (e.clientY - fd.lastY) / Math.max(1, now - fd.lastT);
fd.lastY = e.clientY;
fd.lastT = now;
}
function onHeadUp() {
if (!fd) return;
if (fd.moved) {
const f = feedH.value ?? FEED[feedSnap.value];
let snap;
if (fd.v < -0.5) snap = f < FEED.split ? 'split' : 'list';
else if (fd.v > 0.5) snap = f > FEED.split ? 'split' : 'map';
else
snap = FEED_ORDER.reduce((a, b) =>
Math.abs(FEED[b] - f) < Math.abs(FEED[a] - f) ? b : a,
);
dragging.value = false;
setFeed(snap);
} else setFeed(FEED_ORDER[(FEED_ORDER.indexOf(feedSnap.value) + 1) % 3]);
fd = null;
}
function onGripKey(e) {
const i = FEED_ORDER.indexOf(feedSnap.value);
if (e.key === 'ArrowUp') {
e.preventDefault();
setFeed(FEED_ORDER[Math.min(2, i + 1)]);
} else if (e.key === 'ArrowDown') {
e.preventDefault();
setFeed(FEED_ORDER[Math.max(0, i - 1)]);
} else if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
setFeed(FEED_ORDER[(i + 1) % 3]);
}
}
// Desktop and tablet: drag the feed's right edge to widen it, up to 50 px
// past its default; double-click puts it back.
const FEED_W = 340;
const FEED_W_MAX = FEED_W + 50;
const FEED_W_MIN = 280;
const feedW = ref(FEED_W);
try {
const saved = +localStorage.getItem('gevFeedW');
if (saved) feedW.value = clamp(saved, FEED_W_MIN, FEED_W_MAX);
} catch {
/* storage off: the default width */
}
// The feed sits over the map on desktop: a new width moves the free part of
// the map, which a resize of the map itself would not report.
watch(feedW, () => nextTick(() => store.controller.reframe()));
const resizing = ref(false);
let rw = null;
function setFeedW(px) {
feedW.value = Math.round(clamp(px, FEED_W_MIN, FEED_W_MAX));
try {
localStorage.setItem('gevFeedW', feedW.value);
} catch {
/* storage off: the width lasts this visit */
}
}
function onResizeDown(e) {
try {
e.currentTarget.setPointerCapture(e.pointerId);
} catch {
/* nothing to capture */
}
rw = { x: e.clientX, w: feedW.value };
resizing.value = true;
e.preventDefault();
}
function onResizeMove(e) {
if (rw) setFeedW(rw.w + (e.clientX - rw.x));
}
function onResizeUp() {
rw = null;
resizing.value = false;
}
function onResizeKey(e) {
const d = { ArrowRight: 10, ArrowLeft: -10 }[e.key];
if (!d) return;
e.preventDefault();
setFeedW(feedW.value + d);
}
function onResizeReset() {
feedW.value = FEED_W;
try {
localStorage.removeItem('gevFeedW');
} catch {
/* storage off */
}
}
const bodyStyle = computed(() => ({
'--feed-h': `${(feedH.value ?? FEED[feedSnap.value]) * 100}%`,
...(innerWidth > 700
? {
'--feedw': `${feedW.value}px`,
gridTemplateColumns: `${feedW.value}px minmax(0, 1fr)`,
}
: {}),
}));
onMounted(() => {
document.addEventListener('pointerdown', onDocDown);
// On the window: the Stories keyboard guard stops keys before the document.
addEventListener('keydown', onSlash, true);
addEventListener('resize', measure);
measure();
});
onBeforeUnmount(() => {
document.removeEventListener('pointerdown', onDocDown);
removeEventListener('keydown', onSlash, true);
removeEventListener('resize', measure);
});
defineExpose({
cardThumb: (id) =>
feedEl.value?.querySelector(`.card[data-id="${CSS.escape(id)}"]`),
});
</script>
<template>
<section
id="scrExplore"
class="scr scr-explore"
:aria-label="t('GEV Stories explore')"
>
<StoriesHeader
screen="explore"
@back="store.controller.close()"
@home="store.controller.close()"
@search="headerSearch"
/>
<div
id="exBody"
ref="bodyEl"
class="ex-body"
:class="{ 'feed-dragging': dragging }"
data-side="left"
:style="bodyStyle"
>
<div
class="ex-feed-resize"
:class="{ on: resizing }"
role="separator"
aria-orientation="vertical"
:aria-label="t('Resize story list')"
:aria-valuenow="feedW"
:aria-valuemin="FEED_W_MIN"
:aria-valuemax="FEED_W_MAX"
tabindex="0"
:style="{ left: `${feedW - 5}px` }"
@pointerdown="onResizeDown"
@pointermove="onResizeMove"
@pointerup="onResizeUp"
@pointercancel="onResizeUp"
@dblclick="onResizeReset"
@keydown="onResizeKey"
></div>
<aside class="ex-feed" :aria-label="t('Stories')">
<div class="ex-feed-top">
<div
id="feedHead"
class="ex-feed-head"
@pointerdown="onHeadDown"
@pointermove="onHeadMove"
@pointerup="onHeadUp"
@pointercancel="onHeadUp"
>
<button
id="feedGrip"
class="feed-grip"
type="button"
:aria-label="t('Story list size. Drag, or press to change')"
@keydown="onGripKey"
></button>
<h1>{{ t('GEV Stories') }}</h1>
<span
id="exCount"
:aria-label="
tn(
all.length,
'{n} of {count} story',
'{n} of {count} stories',
{
n: shown.length,
},
)
"
>{{ count }}</span
>
<div class="fh-tools">
<label class="sr" for="exSort">{{ t('Sort stories') }}</label>
<select id="exSort" v-model="sort" class="fh-sort">
<option value="new">{{ t('Newest') }}</option>
<option value="long">{{ t('Longest') }}</option>
<option value="az">{{ t('A–Z') }}</option>
</select>
<button
id="exFilterBtn"
ref="filterBtn"
type="button"
class="fh-filter"
:class="{ on: filterCount }"
:aria-expanded="filterOpen"
aria-controls="exFilter"
:aria-label="
filterCount
? tn(filterCount, '{count} filter on', '{count} filters on')
: t('Filters')
"
@click.stop="filterOpen = !filterOpen"
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.9"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M4 6h16M7 12h10M10 18h4" />
</svg>
<b v-if="filterCount" id="exFilterN">{{ filterCount }}</b>
</button>
</div>
</div>
<div id="exTools" class="ex-tools" @pointerdown.stop @wheel.stop>
<div class="fh-search m-only-search" role="search">
<label class="sr" for="exQm">{{ t('Search stories') }}</label>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
aria-hidden="true"
>
<circle cx="11" cy="11" r="6.5" />
<path d="m16 16 4.5 4.5" />
</svg>
<input
id="exQm"
ref="searchEl"
v-model="query"
class="ex-q"
type="search"
:placeholder="t('Search stories, places, creators')"
autocomplete="off"
@keydown="onSearchKey"
/>
<button
v-if="query"
type="button"
class="ex-qx"
:aria-label="t('Clear search')"
@click="
query = '';
searchEl?.focus();
"
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2.2"
stroke-linecap="round"
aria-hidden="true"
>
<path d="M6 6l12 12M18 6 6 18" />
</svg>
</button>
<kbd class="hide-m">/</kbd>
</div>
<div class="fh-row">
<div
id="exChips"
class="fh-chips"
role="group"
:aria-label="t('Topics')"
>
<button
type="button"
class="chip"
:aria-pressed="!chips.length"
@click="toggleChip('')"
>{{ t('All') }}</button
>
<button
v-for="c in topics"
:key="c"
type="button"
class="chip"
:class="{ live: c === 'Live' }"
:aria-pressed="chips.includes(c)"
@click="toggleChip(c)"
><i v-if="c === 'Live'"></i>{{ t(c) }}</button
>
</div>
</div>
<div
v-if="filterOpen"
id="exFilter"
ref="filterEl"
class="ex-filter"
role="dialog"
:aria-label="t('Filter stories')"
>
<fieldset v-for="[key, label, opts] in filterGroups" :key="key">
<legend>{{ t(label) }}</legend>
<label v-for="[value, text] in opts" :key="value" class="fopt">
<input
type="checkbox"
:checked="filters[key]?.includes(value)"
@change="toggleFilter(key, value, $event.target.checked)"
/>
<span>{{ t(text) }}</span>
</label>
</fieldset>
<div class="fact">
<button type="button" class="tbtn" @click="clearFilters">{{
t('Clear')
}}</button>
<button
type="button"
class="tbtn solid"
@click="
filterOpen = false;
filterBtn?.focus();
"
>
{{
tn(
shown.length,
'Show {count} story',
'Show {count} stories',
)
}}
</button>
</div>
</div>
</div>
</div>
<ul id="feed" ref="feedEl" class="feed">
<li v-if="!shown.length" class="feed-empty">
<b>{{ t('No stories match') }}</b>
<span>{{ t('Try another word or clear the filters.') }}</span>
<button type="button" class="tbtn" @click="resetAll">{{
t('Clear all')
}}</button>
</li>
<li v-for="s in shown" :key="s.id">
<div
class="card"
role="button"
tabindex="0"
:data-id="s.id"
:aria-pressed="picked === s.id"
@click="pick(s.id)"
@keydown="onCardKey($event, s)"
>
<span class="thumb">
<img
v-if="thumbFor(s)"
:src="thumbFor(s)"
alt=""
loading="lazy"
/>
<span v-if="s.live" class="chip"
><span class="dot"></span>{{ t('LIVE') }}</span
>
<span v-else class="chip">{{
s.draft ? t('DRAFT') : t('STORY')
}}</span>
<span class="dur">{{ fmtDur(s.durationMs) }}</span>
<button
class="thumb-play"
type="button"
:aria-label="t('Play {title}', { title: titleOf(s) })"
@click.stop="play(s.id, $event.currentTarget.parentElement)"
>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M9 6.5v11l9-5.5z" fill="currentColor" />
</svg>
</button>
</span>
<span class="c-title">{{ titleOf(s) }}</span>
<span class="c-meta">{{ s.creator }} · {{ windowText(s) }}</span>
<span class="c-layers"
><span v-for="l in layerNames(s)" :key="l">{{ l }}</span></span
>
<span class="c-play">
<button
class="tbtn solid"
type="button"
@click.stop="
play(
s.id,
$event.currentTarget
.closest('.card')
.querySelector('.thumb'),
)
"
>
<svg viewBox="0 0 24 24" fill="currentColor">
<path d="M7 4.5v15l12.5-7.5z" /></svg
>{{ t('Play story') }}
</button>
</span>
</div>
</li>
</ul>
</aside>
<div class="ex-map">
<div class="map-slot"></div>
<div id="pins" ref="pinsEl" class="pins">
<button
v-for="p in placedPins"
:key="p.id"
class="pin"
:class="{ out: !shownIds.has(p.id), hidden: !p.visible }"
type="button"
:data-id="p.id"
:aria-pressed="picked === p.id"
:aria-label="t('Preview {title}', { title: titleOf(p.story) })"
:style="p.style"
@click="onPin($event, p.id)"
>
<span
class="pin-thumb"
:data-preview="t('Click to preview')"
:data-play="t('Click to play')"
:data-tap="t('Tap to play')"
:data-play-short="t('Play')"
><img v-if="thumbFor(p.story)" :src="thumbFor(p.story)" alt=""
/></span>
<span class="pin-lbl">{{ titleOf(p.story).split(':')[0] }}</span>
<span class="pin-dot"></span>
</button>
</div>
<div class="ex-msearch glass" role="search">
<label class="sr" for="exQ">{{ t('Search stories') }}</label>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
aria-hidden="true"
>
<circle cx="11" cy="11" r="6.5" />
<path d="m16 16 4.5 4.5" />
</svg>
<input
id="exQ"
v-model="query"
class="ex-q"
type="search"
:placeholder="t('Search stories, places, creators')"
autocomplete="off"
@keydown="onSearchKey"
/>
<button
v-if="query"
type="button"
class="ex-qx"
:aria-label="t('Clear search')"
@click="query = ''"
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2.2"
stroke-linecap="round"
aria-hidden="true"
>
<path d="M6 6l12 12M18 6 6 18" />
</svg>
</button>
<kbd>/</kbd>
</div>
<div
v-if="pickedStory"
id="exPreview"
class="ex-preview glass"
aria-live="polite"
>
<span class="k"><i></i>{{ t('PREVIEW') }}</span>
<h2>{{ titleOf(pickedStory) }}</h2>
<span class="c-meta"
>{{ pickedStory.creator }} · {{ windowText(pickedStory) }}</span
>
<span class="c-layers"
><span v-for="l in layerNames(pickedStory)" :key="l">{{
l
}}</span></span
>
<button
class="tbtn solid"
type="button"
@click="play(pickedStory.id, null)"
>
<svg viewBox="0 0 24 24" fill="currentColor">
<path d="M7 4.5v15l12.5-7.5z" /></svg
>{{ t('Play story') }}
</button>
</div>
<div v-else class="ex-hint glass">{{
t('Pick a story or a pin to preview it here')
}}</div>
</div>
</div>
</section>
</template>
+181
View File
@@ -0,0 +1,181 @@
<script setup>
import {
computed,
nextTick,
onBeforeUnmount,
onMounted,
ref,
watch,
} from 'vue';
import { t } from '../../../i18n/index.js';
import { useStoriesStore } from '../../stores/stories.js';
/**
* The Stories top bar (prototype `.h-top.s-head`): back, GEV logo and
* wordmark, breadcrumb, the phone title (scrolls when it is too long) and
* the right-hand buttons.
*/
const props = defineProps({
screen: { type: String, required: true },
title: { type: String, default: '' },
});
const emit = defineEmits(['back', 'home', 'crumb', 'search']);
const store = useStoriesStore();
// A scene saved on this device only: a link to it opens nothing elsewhere.
const localOnly = computed(() => !!store.byId(store.storyId)?.mine);
async function share() {
const what = props.screen === 'story' ? t('Story') : t('Stories');
try {
await navigator.clipboard.writeText(store.controller.shareLink());
store.flashToast(t('{what} link copied', { what }));
} catch {
store.flashToast(t('Copy this link: {url}', { url: location.href }), 4000);
}
}
// Long titles scroll gently so the whole name can be read.
const mtitle = ref(null);
let observer = null;
function fitTitle() {
const el = mtitle.value;
const sp = el?.firstElementChild;
if (!sp) return;
const over = sp.scrollWidth - el.clientWidth;
el.classList.toggle('marquee', over > 4);
el.style.setProperty('--mq', `${-(over + 22)}px`);
el.style.setProperty('--mq-dur', `${Math.max(5, (over + 22) / 22)}s`);
}
onMounted(() => {
if (globalThis.ResizeObserver && mtitle.value) {
observer = new ResizeObserver(fitTitle);
observer.observe(mtitle.value);
}
fitTitle();
});
watch(
() => props.title,
() => nextTick(fitTitle),
);
onBeforeUnmount(() => observer?.disconnect());
</script>
<template>
<header class="h-top s-head">
<button
class="s-back glass"
type="button"
:aria-label="
screen === 'story' ? t('Back to stories') : t('Back to the globe')
"
@click="emit('back')"
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M15 6l-6 6 6 6" />
</svg>
</button>
<div class="h-brand">
<div class="h-brand-row">
<button
class="s-home"
type="button"
:aria-label="t('Back to the globe')"
@click="emit('home')"
>
<svg class="eye" viewBox="0 0 775 520" aria-hidden="true">
<use href="#gevLogo" />
</svg>
</button>
<span class="h-word" translate="no">GOD'S EYE <b>VIEW</b></span>
</div>
<nav class="h-tag s-trail" :aria-label="t('Breadcrumb')">
<template v-if="screen === 'explore'">
<button type="button" @click="emit('home')">{{ t('Globe') }}</button>
<span aria-hidden="true">/</span>
<b>{{ t('Stories') }}</b>
</template>
<template v-else>
<button type="button" @click="emit('crumb')">{{
t('Stories')
}}</button>
<span aria-hidden="true">/</span>
<b>{{ title }}</b>
</template>
</nav>
</div>
<span ref="mtitle" class="s-mtitle glass"
><span>{{ screen === 'explore' ? t('Stories') : title }}</span></span
>
<div class="h-right">
<button
v-if="screen === 'explore'"
class="s-msearch ibtn"
type="button"
:aria-label="t('Search')"
@click="emit('search')"
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<circle cx="11" cy="11" r="6.5" />
<path d="m16 16 4.5 4.5" />
</svg>
</button>
<button
v-if="!(screen === 'story' && localOnly)"
class="tbtn hide-m"
type="button"
:aria-label="t('Share')"
@click="share"
>
<span class="share-icon" aria-hidden="true">&#x1F517;</span>
<span>{{ t('Share') }}</span>
</button>
<button
v-if="screen === 'explore'"
class="tbtn accent hide-m"
type="button"
@click="emit('home')"
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.8"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M19 12H5M11 6l-6 6 6 6" />
</svg>
<span>{{ t('Back to GEV') }}</span>
</button>
<button
v-else
class="tbtn accent hide-m gs-back-stories"
type="button"
@click="emit('crumb')"
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.8"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M19 12H5M11 6l-6 6 6 6" />
</svg>
<span>{{ t('GEV Stories') }}</span>
</button>
</div>
</header>
</template>
+414
View File
@@ -0,0 +1,414 @@
<script setup>
import { computed, ref } from 'vue';
import { storeToRefs } from 'pinia';
import { t, tn } from '../../../i18n/index.js';
import { useStoriesStore } from '../../stores/stories.js';
import { chapterAt } from '../../../stories/format.js';
import {
anchorStamp,
chapterStamp,
chapterTitle,
clamp,
nowFacts,
storyText,
windowText,
} from '../../../stories/storyMeta.js';
/**
* The context panel (prototype `.st-ctx`): docked on the right on desktop,
* a sheet that peeks above the timeline on a phone. It shows what a GEV
* scene carries: right-now facts, chapters, key moments, sources and
* background, with a search over its chapters, key moments and sources.
*/
const props = defineProps({
story: { type: Object, required: true },
nudge: Boolean,
});
const emit = defineEmits(['chapter', 'anchor', 'open', 'hide']);
const store = useStoriesStore();
const { playback, sheet } = storeToRefs(store);
const k = computed(() => chapterAt(props.story, playback.value.wallMs));
const chTitle = (c) => chapterTitle(props.story, c);
const events = computed(() => props.story.events ?? []);
// The background in the page's language: one text, or parts (a shipped
// scene's layers) translated one by one.
const background = computed(() =>
[]
.concat(props.story.background || [])
.map((part) => storyText(part))
.join(' '),
);
const stamp = (ms, world) => anchorStamp(props.story, ms, world);
const facts = computed(() =>
nowFacts(props.story, playback.value.worldMs, playback.value.wallMs),
);
const peekFacts = computed(() => facts.value.slice(0, 3));
const sheetSum = computed(
() =>
`${k.value + 1}/${props.story.chapters.length} · ${chTitle(props.story.chapters[k.value])} · ${tn(props.story.sources.length, '{count} source', '{count} sources')}`,
);
const titleOf = (s) => storyText(s.title);
const related = computed(() =>
store.stories.filter((x) => x.id !== props.story.id).slice(0, 3),
);
// A related story's card picture, when there is one (CSS draws a placeholder).
const thumbOf = (s) => store.thumbs?.[s.id] || '';
// ── Search this story: its chapters, key moments and sources ──
const GLYPH = { ch: '#', ev: '•', src: '↗' };
const query = ref('');
const active = ref(-1);
const results = computed(() => {
const q = query.value.trim().toLowerCase();
if (!q) return null;
const hit = (x) => `${x.title} ${x.sub}`.toLowerCase().includes(q);
const chs = props.story.chapters
.map((c, i) => ({
type: 'ch',
k: i,
title: chTitle(c),
sub: `${t('Chapter {n}', { n: i + 1 })} · ${chapterStamp(props.story, c)}`,
}))
.filter(hit);
const evs = events.value
.map((ev, i) => ({
type: 'ev',
k: i,
ev,
title: storyText(ev.label),
sub: `${t('Key moments')} · ${stamp(ev.wallMs, ev.tMs)}`,
}))
.filter(hit);
const srcs = props.story.sources
.map((x) => ({
type: 'src',
href: x[2],
title: storyText(x[0]),
sub: storyText(x[1]),
}))
.filter(hit);
return [...chs, ...evs, ...srcs].slice(0, 9);
});
function onQuery() {
active.value = results.value?.length ? 0 : -1;
}
function choose(x) {
if (!x) return;
query.value = '';
if (x.type === 'ch') emit('chapter', x.k);
else if (x.type === 'ev') emit('anchor', x.ev);
else if (x.type === 'src' && x.href && x.href !== '#')
window.open(x.href, '_blank', 'noopener');
}
function onSearchKey(e) {
const list = results.value ?? [];
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
e.preventDefault();
if (!list.length) return;
active.value =
(active.value + (e.key === 'ArrowDown' ? 1 : -1) + list.length) %
list.length;
} else if (e.key === 'Enter') {
e.preventDefault();
choose(list[active.value]);
} else if (e.key === 'Escape') query.value = '';
}
// ── Phone sheet: follows the finger, snaps to peek / half / full ──
const SNAPS = ['peek', 'half', 'full'];
const el = ref(null);
const dragH = ref(null);
const dragging = ref(false);
let sd = null;
function heights() {
const H = el.value?.closest('.st-body')?.clientHeight || innerHeight;
return { peek: 100, half: H * 0.54, full: H * 0.88, H };
}
function setSheet(s) {
sheet.value = s;
dragH.value = null;
setTimeout(() => store.controller.reframe(), 320);
}
function onHandleDown(e) {
if (innerWidth > 700) return;
try {
e.currentTarget.setPointerCapture(e.pointerId);
} catch {
/* nothing to capture */
}
sd = {
y: e.clientY,
h: el.value.offsetHeight,
lastY: e.clientY,
lastT: performance.now(),
v: 0,
moved: false,
};
}
function onHandleMove(e) {
if (!sd) return;
const dy = e.clientY - sd.y;
if (!sd.moved && Math.abs(dy) > 4) {
sd.moved = true;
dragging.value = true;
}
if (!sd.moved) return;
dragH.value = clamp(sd.h - dy, 100, heights().H * 0.92);
const now = performance.now();
sd.v = (e.clientY - sd.lastY) / Math.max(1, now - sd.lastT);
sd.lastY = e.clientY;
sd.lastT = now;
}
let justDragged = false;
function onHandleUp() {
if (!sd) return;
if (sd.moved) {
const hs = heights();
const h = dragH.value ?? hs[sheet.value];
let target;
if (sd.v < -0.5) target = h < hs.half ? 'half' : 'full';
else if (sd.v > 0.5) target = h > hs.half ? 'half' : 'peek';
else
target = SNAPS.reduce((a, b) =>
Math.abs(hs[b] - h) < Math.abs(hs[a] - h) ? b : a,
);
dragging.value = false;
justDragged = true;
setSheet(target);
}
sd = null;
}
function onHandleClick() {
if (justDragged) {
justDragged = false;
return;
}
setSheet(SNAPS[(SNAPS.indexOf(sheet.value) + 1) % 3]);
}
function onHandleKey(e) {
const i = SNAPS.indexOf(sheet.value);
if (e.key === 'ArrowUp') {
e.preventDefault();
setSheet(SNAPS[Math.min(2, i + 1)]);
} else if (e.key === 'ArrowDown') {
e.preventDefault();
setSheet(SNAPS[Math.max(0, i - 1)]);
}
}
defineExpose({ dragging });
</script>
<template>
<aside
id="stCtx"
ref="el"
class="st-ctx"
:class="{ nudge }"
:aria-label="t('Context')"
:style="dragH != null ? { height: `${dragH}px` } : null"
>
<button
id="sheetHandle"
class="sheet-handle"
type="button"
:aria-expanded="sheet !== 'peek'"
:aria-label="
sheet === 'peek'
? t('Context. Swipe up or press to open')
: t('Context. Swipe down or press to close')
"
@pointerdown="onHandleDown"
@pointermove="onHandleMove"
@pointerup="onHandleUp"
@pointercancel="onHandleUp"
@click="onHandleClick"
@keydown="onHandleKey"
>
<span class="pk-top">
<span class="lbl">{{ t('Context') }}</span>
<span id="sheetSum" class="sum">{{ sheetSum }}</span>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M6 15l6-6 6 6" />
</svg>
</span>
<span id="peekFacts" class="pk-facts" aria-hidden="true">
<span v-for="f in peekFacts" :key="f[1]"
><b :class="{ warn: f[2] }">{{ f[0] }}</b
>{{ t(f[1]) }}</span
>
</span>
</button>
<div class="cx-search-wrap">
<div class="cx-search">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
aria-hidden="true"
>
<circle cx="11" cy="11" r="6.5" />
<path d="m16 16 4.5 4.5" />
</svg>
<input
id="cxQ"
v-model="query"
type="search"
:placeholder="t('Search this story')"
autocomplete="off"
spellcheck="false"
:aria-label="t('Search this story')"
role="combobox"
:aria-expanded="!!results"
aria-controls="cxResults"
@input="onQuery"
@keydown="onSearchKey"
/>
<button
class="cx-ic"
type="button"
disabled
:aria-label="t('Voice search (not in this build)')"
:title="t('Voice search (not in this build)')"
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.9"
stroke-linecap="round"
>
<rect x="9" y="3" width="6" height="11" rx="3" />
<path d="M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21" />
</svg>
</button>
</div>
<ul
v-if="results"
id="cxResults"
class="cx-results"
role="listbox"
:aria-label="t('Search results')"
>
<li v-for="(x, i) in results" :key="`${x.type}:${x.k ?? x.title}`">
<button
type="button"
role="option"
:aria-selected="i === active"
@click="choose(x)"
>
<span class="ic" aria-hidden="true">{{ GLYPH[x.type] }}</span>
<span
><b>{{ x.title }}</b
><span class="sub">{{ x.sub }}</span></span
>
</button>
</li>
<li v-if="!results.length" class="empty">{{
t('Nothing in this story matches.')
}}</li>
</ul>
</div>
<div id="cxScroll" class="cx-scroll">
<div class="cx-sec cx-chapters">
<div class="cx-h">{{ t('Chapters') }}</div>
<ul class="cx-list">
<li v-for="(c, i) in story.chapters" :key="c.id">
<a href="#" @click.prevent="emit('chapter', i)"
>{{ i + 1 }}. {{ chTitle(c) }}</a
>
<span
>{{ chapterStamp(story, c)
}}{{ i === k ? ` · ${t('now')}` : '' }}</span
>
</li>
</ul>
</div>
<div class="cx-sec">
<div class="cx-h">
{{ t('About') }}
<button
class="tbtn cx-close"
type="button"
style="height: 28px; padding: 0 8px"
@click="emit('hide')"
>{{ t('Close') }}</button
>
</div>
<p class="cx-p">
<b>{{ titleOf(story) }}</b
><br />{{ t('by {creator}', { creator: story.creator }) }} ·
{{ windowText(story) }}
</p>
<p v-if="story.description" class="cx-p">{{
storyText(story.description)
}}</p>
</div>
<div v-if="events.length" class="cx-sec">
<div class="cx-h">{{ t('Key moments') }}</div>
<ul class="cx-anchors">
<li v-for="(ev, i) in events" :key="i">
<button
type="button"
:class="{ past: playback.wallMs >= ev.wallMs }"
@click="emit('anchor', ev)"
>
<span class="tchip">{{ stamp(ev.wallMs, ev.tMs) }}</span>
<span class="al"
><i :style="{ background: ev.color }"></i
>{{ storyText(ev.label) }}</span
>
</button>
</li>
</ul>
</div>
<div v-if="story.sources.length" class="cx-sec">
<div class="cx-h">{{ t('Sources') }}</div>
<ul class="cx-list">
<li v-for="src in story.sources" :key="src[0]">
<a :href="src[2] || '#'" target="_blank" rel="noopener"
>{{ storyText(src[0]) }} ↗</a
>
<span>{{ storyText(src[1]) }}</span>
</li>
</ul>
</div>
<div v-if="background" class="cx-sec">
<div class="cx-h">{{ t('Background') }}</div>
<p class="cx-p">{{ background }}</p>
</div>
<div class="cx-sec">
<div class="cx-h">{{ t('Related stories') }}</div>
<div class="cx-related">
<button
v-for="x in related"
:key="x.id"
type="button"
@click="emit('open', x.id)"
>
<span class="thumb"
><img v-if="thumbOf(x)" :src="thumbOf(x)" alt="" loading="lazy"
/></span>
<span
><b>{{ titleOf(x) }}</b
><span class="c-meta">{{ windowText(x) }}</span></span
>
</button>
</div>
</div>
</div>
</aside>
</template>
+53
View File
@@ -0,0 +1,53 @@
<script setup>
import { computed } from 'vue';
import { t } from '../../../i18n/index.js';
import { useStoriesStore } from '../../stores/stories.js';
/**
* The right rail over the story map (prototype `.ov-rail`): Open in GEV (it
* opens the scene in GEV's Scenes panel) and Share.
*/
const store = useStoriesStore();
// A scene saved on this device only: a link to it opens nothing elsewhere.
const localOnly = computed(() => !!store.byId(store.storyId)?.mine);
async function share() {
const url = store.controller.shareLink();
try {
await navigator.clipboard.writeText(url);
store.flashHint(t('Story link copied'), 1800);
} catch {
store.flashHint(url, 2600);
}
}
</script>
<template>
<div id="ovRail" class="ov ov-rail">
<!-- The scene opens in GEV's Scenes panel. -->
<button
id="railGev"
class="rail-btn rail-gev"
type="button"
:aria-label="t('Open this moment in GEV')"
@click="store.controller.openInGev()"
>
<span class="ic"
><svg class="eye" viewBox="0 0 775 520" aria-hidden="true">
<use href="#gevLogo" /></svg></span
>{{ t('Open') }}
</button>
<button
v-if="!localOnly"
id="railShare"
class="rail-btn"
type="button"
:aria-label="t('Share this story')"
@click="share"
>
<span class="ic"
><span class="share-icon" aria-hidden="true">&#x1F517;</span></span
>{{ t('Share') }}
</button>
</div>
</template>
+631
View File
@@ -0,0 +1,631 @@
<script setup>
import {
computed,
nextTick,
onBeforeUnmount,
onMounted,
ref,
watch,
} from 'vue';
import { storeToRefs } from 'pinia';
import { formatNumber, t } from '../../../i18n/index.js';
import { useStoriesStore } from '../../stores/stories.js';
import { chapterAt } from '../../../stories/format.js';
import {
chapterTitle,
clamp,
clockText,
layersFor,
nowFacts,
storyText,
} from '../../../stories/storyMeta.js';
import StoriesHeader from './StoriesHeader.vue';
import StoryTimeline from './StoryTimeline.vue';
import StoryContext from './StoryContext.vue';
import StoryRail from './StoryRail.vue';
/**
* One story (prototype `.scr-story`): a GEV scene playing on GEV's Cesium
* globe, which shows through the map area.
*/
const props = defineProps({ story: { type: Object, required: true } });
const emit = defineEmits(['back']);
const store = useStoriesStore();
const {
playback,
expanded,
ctxOpen,
sheet,
contextWidth,
camera,
hint,
bigPlay,
} = storeToRefs(store);
const titleOf = (s) => storyText(s.title);
const title = computed(() => titleOf(props.story));
const k = computed(() => chapterAt(props.story, playback.value.wallMs));
const chapter = computed(() => props.story.chapters[k.value]);
const chTitle = (c) => chapterTitle(props.story, c);
const clock = computed(() =>
clockText(
props.story,
playback.value.wallMs,
playback.value.worldMs,
k.value,
),
);
const layers = computed(() => layersFor(props.story));
const facts = computed(() =>
nowFacts(props.story, playback.value.worldMs, playback.value.wallMs),
);
const posText = computed(() => {
const { lat, lon, altKm } = camera.value;
return {
pos: `${Math.abs(lat).toFixed(2)}°${lat >= 0 ? 'N' : 'S'} ${Math.abs(lon).toFixed(2)}°${lon >= 0 ? 'E' : 'W'}`,
// ALT and KM are HUD codes, as in GEV's own readout; the number follows
// the page's language.
alt: ` · ALT ${formatNumber(altKm)} KM`,
};
});
const legendStyle = (l) =>
l[0] === 'dash'
? { borderTop: `2px dashed ${l[1]}` }
: l[0] === 'line'
? { borderTopColor: l[1] }
: { background: l[1] };
const legendClass = (l) => (l[0] === 'dot' ? 'dot' : l[0] === 'sq' ? 'sq' : '');
// ── Navigation within the story ──
const timelineRef = ref(null);
function goChapter(i) {
store.controller.seek(props.story.chapters[i].wallMs + 1);
if (playback.value.exploring) store.controller.resume();
}
function goAnchor(ev) {
store.controller.focusEvent(ev);
if (innerWidth <= 700) sheet.value = 'half';
}
function bigPlayClick() {
bigPlay.value = false;
if (playback.value.exploring) store.controller.resume();
else store.controller.play();
}
// ── Story card: Chapter · On the map · Right now ──
const page = ref(0);
const cardMin = ref(false);
const cardDragging = ref(false);
const trackEl = ref(null);
const cardEl = ref(null);
const pgEls = ref([]);
const trackHeight = ref(null);
const dragOffset = ref(null);
function sizeCard() {
const pg = pgEls.value[page.value];
if (pg) trackHeight.value = pg.offsetHeight;
}
function setPage(p) {
page.value = clamp(p, 0, 2);
dragOffset.value = null;
requestAnimationFrame(sizeCard);
}
const trackStyle = computed(() => ({
transform:
dragOffset.value != null
? `translateX(${dragOffset.value}px)`
: `translateX(${-page.value * 100}%)`,
height: trackHeight.value ? `${trackHeight.value}px` : null,
}));
let pd = null;
function onCardDown(e) {
if (e.target.closest('#pgDots, .pg-min, .pg-mini') || cardMin.value) return;
e.stopPropagation();
pd = {
x: e.clientX,
y: e.clientY,
w: cardEl.value.offsetWidth,
t: performance.now(),
moved: false,
};
try {
cardEl.value.setPointerCapture(e.pointerId);
} catch {
/* nothing to capture */
}
}
function onCardMove(e) {
if (!pd) return;
const dx = e.clientX - pd.x;
if (
!pd.moved &&
Math.abs(dx) > 6 &&
Math.abs(dx) > Math.abs(e.clientY - pd.y)
) {
pd.moved = true;
cardDragging.value = true;
}
if (!pd.moved) return;
// Rubber band at the ends.
const ends = (page.value === 0 && dx > 0) || (page.value === 2 && dx < 0);
dragOffset.value = -page.value * pd.w + (ends ? dx * 0.3 : dx);
}
function onCardUp(e) {
if (!pd) return;
if (pd.moved) {
const dx = e.clientX - pd.x;
const fast = Math.abs(dx) / Math.max(1, performance.now() - pd.t) > 0.4;
cardDragging.value = false;
setPage(
page.value + (Math.abs(dx) > pd.w * 0.25 || fast ? (dx < 0 ? 1 : -1) : 0),
);
}
pd = null;
}
function onCardKey(e) {
if (e.key === 'ArrowRight') setPage(page.value + 1);
else if (e.key === 'ArrowLeft') setPage(page.value - 1);
}
const minBtn = ref(null);
const miniBtn = ref(null);
function setCardMin(on) {
cardMin.value = on;
if (!on) requestAnimationFrame(sizeCard);
}
// The card shows for a few seconds at each chapter (new info), then folds
// to its pill so the map has room (prototype, on every screen size here).
let cardTimer = 0;
function cardPeek() {
clearTimeout(cardTimer);
setCardMin(false);
cardTimer = setTimeout(() => {
if (!cardHover) setCardMin(true);
}, 5000);
}
// The card stays open while the pointer is on it, then folds a moment later.
let cardHover = false;
function onCardEnter() {
cardHover = true;
clearTimeout(cardTimer);
}
function onCardLeave() {
cardHover = false;
if (!cardMin.value) cardTimer = setTimeout(() => setCardMin(true), 2500);
}
watch(k, () => cardPeek());
let cardObserver = null;
// ── Phone: controls fade in expanded full screen while playing ──
const controlsHidden = ref(false);
let pokeTimer = 0;
function pokeControls() {
controlsHidden.value = false;
clearTimeout(pokeTimer);
if (
expanded.value &&
playback.value.playing &&
!playback.value.exploring &&
innerWidth <= 700
)
pokeTimer = setTimeout(() => (controlsHidden.value = true), 3000);
}
watch([expanded, () => playback.value.playing], pokeControls);
function onSectionMove(e) {
if (e.pointerType !== 'mouse' || controlsHidden.value) pokeControls();
}
// ── Phone: the first play shows that the context can be pulled up ──
const sheetHint = ref(false);
const nudge = ref(false);
let hintTimers = [];
watch(
() => playback.value.playing,
(on) => {
if (!on || store.sheetHintSeen) return;
hintTimers.push(
setTimeout(() => {
if (store.sheetHintSeen || innerWidth > 700 || sheet.value !== 'peek')
return;
store.sheetHintSeen = true;
sheetHint.value = true;
nudge.value = true;
hintTimers.push(setTimeout(() => (nudge.value = false), 2400));
hintTimers.push(setTimeout(() => (sheetHint.value = false), 5200));
}, 1500),
);
},
);
watch(sheet, () => (sheetHint.value = false));
// ── Desktop: drag the context panel's left edge to resize ──
const resizing = ref(false);
const limits = () => [260, Math.max(280, Math.min(640, innerWidth - 420))];
function setCtxW(px) {
const [a, b] = limits();
contextWidth.value = Math.round(clamp(px, a, b));
try {
localStorage.setItem('gevCtxW', contextWidth.value);
} catch {
/* storage off: the width lasts this visit */
}
}
let rd = null;
function onResizeDown(e) {
try {
e.currentTarget.setPointerCapture(e.pointerId);
} catch {
/* nothing to capture */
}
rd = {
x: e.clientX,
w: document.getElementById('stCtx')?.offsetWidth ?? 340,
};
resizing.value = true;
e.preventDefault();
}
function onResizeMove(e) {
if (rd) setCtxW(rd.w + (rd.x - e.clientX));
}
function onResizeUp() {
if (!rd) return;
rd = null;
resizing.value = false;
store.controller.reframe();
}
function onResizeReset() {
contextWidth.value = 0;
try {
localStorage.removeItem('gevCtxW');
} catch {
/* storage off */
}
store.controller.reframe();
}
function onResizeKey(e) {
const d = { ArrowLeft: 24, ArrowRight: -24 }[e.key];
if (!d) return;
e.preventDefault();
setCtxW((document.getElementById('stCtx')?.offsetWidth ?? 340) + d);
store.controller.reframe();
}
const sectionStyle = computed(() =>
contextWidth.value && !expanded.value
? { '--ctxw': `${contextWidth.value}px` }
: null,
);
onMounted(() => {
try {
const v = +localStorage.getItem('gevCtxW');
if (v) contextWidth.value = v;
} catch {
/* storage off */
}
if (globalThis.ResizeObserver && cardEl.value) {
cardObserver = new ResizeObserver(sizeCard);
cardObserver.observe(cardEl.value);
}
nextTick(sizeCard);
cardPeek();
});
onBeforeUnmount(() => {
clearTimeout(cardTimer);
clearTimeout(pokeTimer);
hintTimers.forEach(clearTimeout);
cardObserver?.disconnect();
});
watch(
() => props.story.id,
() => {
page.value = 0;
cardMin.value = false;
nextTick(sizeCard);
},
);
watch([k, page], () => nextTick(sizeCard));
</script>
<template>
<section
id="scrStory"
class="scr scr-story"
:class="{
exploring: playback.exploring,
expanded,
'ctx-open': ctxOpen,
'ctx-sized': !!contextWidth,
'controls-hidden': controlsHidden,
'sheet-hinting': sheetHint,
'ctx-resizing': resizing,
}"
:aria-label="t('GEV Story')"
:data-sheet="sheet"
data-chapters="timeline"
:style="sectionStyle"
@pointerdown="pokeControls"
@pointermove="onSectionMove"
@keydown="pokeControls"
>
<StoriesHeader
screen="story"
:title="title"
@back="emit('back')"
@crumb="emit('back')"
@home="store.controller.close()"
/>
<div class="st-body">
<aside class="st-chapters" :aria-label="t('Chapters')">
<div class="ch-credit">
<span class="label"
><span class="chip">{{
story.live ? t('LIVE') : story.draft ? t('DRAFT') : t('STORY')
}}</span></span
>
<div class="t">{{ title }}</div>
<div class="c-meta">{{
t('by {creator}', { creator: story.creator })
}}</div>
</div>
<ol class="ch-list">
<li v-for="(c, i) in story.chapters" :key="c.id">
<button
class="ch-item"
:class="{ done: i < k }"
type="button"
:aria-current="i === k ? 'step' : undefined"
@click="goChapter(i)"
>
<span class="n">{{ i + 1 }}</span
><span
><b>{{ chTitle(c) }}</b></span
>
</button>
</li>
</ol>
</aside>
<div class="st-main">
<div id="stMap" class="st-map">
<div class="map-slot"></div>
<div
id="ovChapter"
ref="cardEl"
class="ov ov-chapter glass"
:class="{ min: cardMin, dragging: cardDragging }"
role="region"
aria-roledescription="carousel"
:aria-label="t('Story card')"
tabindex="0"
@pointerdown="onCardDown"
@pointermove="onCardMove"
@pointerup="onCardUp"
@pointercancel="onCardUp"
@keydown="onCardKey"
@focusin="!cardMin && cardPeek()"
@mouseenter="onCardEnter"
@mouseleave="onCardLeave"
>
<div
id="pgTrack"
ref="trackEl"
class="pg-track"
:style="trackStyle"
>
<section
:ref="(el) => (pgEls[0] = el)"
class="pg"
aria-roledescription="slide"
:aria-label="t('Chapter')"
:aria-hidden="page !== 0"
aria-live="polite"
>
<div class="k">{{
t('CHAPTER {n} / {total}', {
n: k + 1,
total: story.chapters.length,
})
}}</div>
<div class="t">{{ chTitle(chapter) }}</div>
<div v-if="chapter.caption" class="c">{{
storyText(chapter.caption)
}}</div>
</section>
<section
:ref="(el) => (pgEls[1] = el)"
class="pg"
aria-roledescription="slide"
:aria-label="t('On the map')"
:aria-hidden="page !== 1"
>
<div class="k">{{ t('ON THE MAP') }}</div>
<div class="pg-legend">
<span v-for="l in layers" :key="l[2]"
><i :class="legendClass(l)" :style="legendStyle(l)"></i
>{{ storyText(l[2]) }}</span
>
</div>
</section>
<section
:ref="(el) => (pgEls[2] = el)"
class="pg"
aria-roledescription="slide"
:aria-label="t('Right now')"
:aria-hidden="page !== 2"
>
<div class="k">{{ t('RIGHT NOW') }} · {{ clock.big }}</div>
<div class="pg-facts">
<div v-for="f in facts" :key="f[1]"
><b :class="{ warn: f[2] }">{{ f[0] }}</b
><span>{{ t(f[1]) }}</span></div
>
</div>
</section>
</div>
<button
id="pgMin"
ref="minBtn"
class="pg-min"
type="button"
:aria-label="t('Minimise card')"
:aria-expanded="!cardMin"
@click.stop="
setCardMin(true);
nextTick(() => miniBtn?.focus());
"
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2.2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M6 15l6-6 6 6" />
</svg>
</button>
<button
id="pgMini"
ref="miniBtn"
class="pg-mini"
type="button"
:aria-label="t('Expand card')"
@click.stop="
setCardMin(false);
cardPeek();
nextTick(() => minBtn?.focus());
"
>
<b>{{ k + 1 }}/{{ story.chapters.length }}</b
><span>{{ chTitle(chapter) }}</span>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2.2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M6 9l6 6 6-6" />
</svg>
</button>
<div
id="pgDots"
class="pg-dots"
role="group"
:aria-label="t('Card pages')"
>
<button
v-for="(lbl, i) in [
t('Chapter'),
t('On the map'),
t('Right now'),
]"
:key="i"
type="button"
:aria-label="lbl"
:aria-current="String(i === page)"
@click="setPage(i)"
></button>
</div>
</div>
<div id="ovClock" class="ov ov-clock">
<b>{{ clock.big }}</b
><span>{{ t(clock.small) }}</span>
<span class="pos"
>{{ posText.pos }}<i>{{ posText.alt }}</i></span
>
</div>
<div id="ovLegend" class="ov ov-legend">
<span v-for="l in layers" :key="l[2]" class="glass"
><i :class="legendClass(l)" :style="legendStyle(l)"></i
>{{ storyText(l[2]) }}</span
>
</div>
<div
v-if="bigPlay && !playback.playing"
id="ovPlay"
class="ov ov-play"
>
<button
id="btnBigPlay"
type="button"
:aria-label="t('Play story')"
@click="bigPlayClick"
>
<svg viewBox="0 0 24 24" fill="currentColor">
<path
d="M8 5.7v12.6c0 .9 1 1.4 1.7.9l9.7-6.3a1.1 1.1 0 0 0 0-1.8L9.7 4.8C9 4.3 8 4.8 8 5.7Z"
/>
</svg>
</button>
</div>
<button
id="btnCtx"
class="ov ov-ctxbtn tbtn"
type="button"
:aria-pressed="ctxOpen"
@click="ctxOpen = !ctxOpen"
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.8"
>
<rect x="4" y="4" width="16" height="16" rx="3" />
<path d="M14 4v16" />
</svg>
<span>{{ t('Context') }}</span>
</button>
<div v-if="hint" id="ovHint" class="ov ov-hint glass">{{ hint }}</div>
<StoryRail />
</div>
<StoryTimeline ref="timelineRef" :story="story" @anchor="goAnchor" />
</div>
<div
id="ctxResize"
class="ctx-resize"
role="separator"
aria-orientation="vertical"
:aria-label="t('Resize context panel')"
:aria-valuenow="contextWidth || undefined"
tabindex="0"
@pointerdown="onResizeDown"
@pointermove="onResizeMove"
@pointerup="onResizeUp"
@pointercancel="onResizeUp"
@dblclick="onResizeReset"
@keydown="onResizeKey"
></div>
<StoryContext
:story="story"
:nudge="nudge"
@chapter="goChapter"
@anchor="goAnchor"
@open="(id) => store.controller.openStory(id, { autoplay: true })"
@hide="ctxOpen = false"
/>
<div
v-if="sheetHint"
id="sheetHint"
class="sheet-hint"
aria-hidden="true"
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2.4"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M12 19V5M6 11l6-6 6 6" />
</svg>
{{ t('Swipe up for context') }}
</div>
</div>
</section>
</template>
+560
View File
@@ -0,0 +1,560 @@
<script setup>
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { storeToRefs } from 'pinia';
import { t } from '../../../i18n/index.js';
import { useStoriesStore } from '../../stores/stories.js';
import { chapterAt } from '../../../stories/format.js';
import {
chapterTitle,
clamp,
clockText,
fmtDur,
storyText,
} from '../../../stories/storyMeta.js';
/**
* The story timeline (prototype `.timeline`): chapter segments with
* magnetic ticks, key-moment pips, a scrub bubble, sound and expand.
* Positions are wall milliseconds on the GEV scene's own clock.
*/
const props = defineProps({ story: { type: Object, required: true } });
const emit = defineEmits(['anchor']);
const store = useStoriesStore();
const { playback, muted, expanded } = storeToRefs(store);
const dur = computed(
() => playback.value.durationMs || props.story.durationMs || 1,
);
const tNow = computed(() => playback.value.wallMs);
const pct = computed(() => clamp((tNow.value / dur.value) * 100, 0, 100));
const k = computed(() => chapterAt(props.story, tNow.value));
const chapters = computed(() => props.story.chapters);
const chTitle = (c) => chapterTitle(props.story, c);
const events = computed(() => props.story.events ?? []);
const seek = (ms) => store.controller.seek(clamp(ms, 0, dur.value - 10));
// ── Play button: pause while playing, resume while exploring, otherwise play ──
const ICON = {
pause:
'<rect x="6.5" y="5" width="4" height="14" rx="1.4"/><rect x="13.5" y="5" width="4" height="14" rx="1.4"/>',
play: '<path d="M8 5.7v12.6c0 .9 1 1.4 1.7.9l9.7-6.3a1.1 1.1 0 0 0 0-1.8L9.7 4.8C9 4.3 8 4.8 8 5.7Z"/>',
resume:
'<path d="M4.5 12a7.5 7.5 0 1 0 2.2-5.3" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/><path d="M3.5 3.8v4.6h4.6" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/>',
};
const playMode = computed(() =>
playback.value.exploring && !playback.value.playing
? 'resume'
: playback.value.playing
? 'pause'
: 'play',
);
function togglePlay() {
if (playMode.value === 'resume') store.controller.resume();
else if (playback.value.playing) store.controller.pause();
else store.controller.play();
}
// ── Segments ──
const segs = computed(() =>
chapters.value.map((c, i) => {
const a = (c.wallMs / dur.value) * 100;
const next =
i + 1 < chapters.value.length ? chapters.value[i + 1].wallMs : dur.value;
const b = (next / dur.value) * 100;
const fill =
clamp((tNow.value - c.wallMs) / (next - c.wallMs || 1), 0, 1) * 100;
return {
i,
style: {
left: `calc(${a}% + ${i ? 2 : 0}px)`,
width: `calc(${b - a}% - ${i ? 2 : 0}px - ${i + 1 < chapters.value.length ? 2 : 0}px)`,
},
fill: `${fill}%`,
};
}),
);
// ── Readout ──
const clock = computed(() =>
clockText(props.story, tNow.value, playback.value.worldMs, k.value),
);
const stampAt = (ms) => fmtDur(ms);
const headTime = computed(() => `${fmtDur(tNow.value)} / ${fmtDur(dur.value)}`);
const atEdge = computed(
() => props.story.live && tNow.value >= dur.value - 600,
);
// ── Scrubbing: magnetic chapter ticks, momentum, haptic ticks ──
const track = ref(null);
const scrubbing = ref(false);
const snap = ref(-1);
const hovered = ref(-1);
const ghost = ref(0);
const bubbleAt = ref(null);
let sc = null;
let coastRaf = 0;
let pipSnap = -1;
const reduceMotion = () =>
globalThis.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
const haptic = () => {
try {
navigator.vibrate?.(3);
} catch {
/* no haptics here */
}
};
function trackAt(clientX) {
const r = track.value.getBoundingClientRect();
let u = clamp((clientX - r.left) / r.width, 0, 1);
let snapped = -1;
chapters.value.forEach((c, i) => {
if (i && Math.abs(u - c.wallMs / dur.value) * r.width < 9) {
u = c.wallMs / dur.value;
snapped = i;
}
});
return { t: u * dur.value, snapped };
}
function scrubTo(target) {
const w = track.value.getBoundingClientRect().width || 1;
let tt = clamp(target, 0, dur.value - 10);
let snapped = -1;
chapters.value.forEach((c, i) => {
if (i && (Math.abs(tt - c.wallMs) / dur.value) * w < 6) {
tt = c.wallMs;
snapped = i;
}
});
let pip = -1;
if (snapped < 0)
events.value.forEach((ev, i) => {
if ((Math.abs(tt - ev.wallMs) / dur.value) * w < 5) {
tt = ev.wallMs;
pip = i;
}
});
if (pip >= 0 && pip !== pipSnap) haptic();
pipSnap = pip;
if (pip >= 0) snapped = -2 - pip;
const ch = chapterAt(props.story, tt);
if (sc && ch !== sc.ch) {
haptic();
sc.ch = ch;
}
seek(tt);
snap.value = snapped;
bubbleAt.value = tt;
return snapped >= 0 || snapped <= -2 ? Math.max(0, snapped) : -1;
}
function onDown(e) {
if (e.target.closest('.tl-pip')) return;
try {
track.value.setPointerCapture(e.pointerId);
} catch {
/* nothing to capture */
}
cancelAnimationFrame(coastRaf);
scrubbing.value = true;
const r = trackAt(e.clientX);
sc = {
lastX: e.clientX,
lastT: performance.now(),
v: 0,
ch: chapterAt(props.story, r.t),
at: r.t,
};
seek(r.t);
snap.value = r.snapped;
bubbleAt.value = r.t;
}
function onMove(e) {
if (!scrubbing.value) {
if (e.target.closest('.tl-pip')) return;
const r = trackAt(e.clientX);
ghost.value = (r.t / dur.value) * 100;
hovered.value = chapterAt(props.story, r.t);
snap.value = r.snapped;
if (r.snapped < 0) {
const w = track.value.clientWidth || 1;
const i = events.value.findIndex(
(ev) => (Math.abs(ev.wallMs - r.t) / dur.value) * w < 5,
);
if (i >= 0) snap.value = -2 - i;
}
bubbleAt.value = r.t;
return;
}
// Slow drags are fine, fast drags coarse.
const now = performance.now();
const dx = e.clientX - sc.lastX;
const dtm = Math.max(1, now - sc.lastT);
const w = track.value.getBoundingClientRect().width || 1;
const gain = clamp(0.25 + (Math.abs(dx) / dtm) * 1.1, 0.25, 2.5);
const before = sc.at;
sc.at = clamp(sc.at + (dx / w) * dur.value * gain, 0, dur.value - 10);
scrubTo(sc.at);
sc.v = (sc.at - before) / dtm;
sc.lastX = e.clientX;
sc.lastT = now;
}
function onUp() {
scrubbing.value = false;
snap.value = -1;
pipSnap = -1;
if (
!sc ||
reduceMotion() ||
Math.abs(sc.v) < 2 ||
performance.now() - sc.lastT > 120
) {
sc = null;
return;
}
// A release coasts with momentum, stopping on a chapter tick.
let v = sc.v * 16;
let at = sc.at;
const coast = () => {
at += v;
const hit = scrubTo(at);
v *= 0.92;
if (hit >= 0 || Math.abs(v) < 20 || at <= 0 || at >= dur.value - 20) {
snap.value = -1;
sc = null;
return;
}
coastRaf = requestAnimationFrame(coast);
};
coastRaf = requestAnimationFrame(coast);
}
function onLeave() {
if (scrubbing.value) return;
ghost.value = 0;
hovered.value = -1;
snap.value = -1;
bubbleAt.value = null;
}
// The bubble follows the knob while playing and the pointer while hovering.
const bubbleT = computed(() => bubbleAt.value ?? tNow.value);
const bubbleK = computed(() => chapterAt(props.story, bubbleT.value));
const bubbleClock = computed(() =>
clockText(
props.story,
bubbleT.value,
bubbleAt.value == null ? playback.value.worldMs : null,
bubbleK.value,
),
);
const bubbleEm = computed(() => {
if (snap.value >= 0) return { text: t('Chapter start'), color: null };
if (snap.value <= -2) {
const ev = events.value[-2 - snap.value];
return ev ? { text: storyText(ev.label), color: ev.color } : null;
}
return null;
});
const bubbleEl = ref(null);
const bubbleStyle = computed(() => {
const w = track.value?.clientWidth || 1;
const half = (bubbleEl.value?.offsetWidth || 120) / 2;
const x = (bubbleT.value / dur.value) * w;
const bx = clamp(x, half, Math.max(half, w - half));
return {
left: `${bx}px`,
'--caret': `${clamp(x - bx + half, 8, half * 2 - 8)}px`,
};
});
// The bubble's picture: the story's card picture, when it has one.
const prevSrc = computed(() => store.thumbs?.[props.story.id] || '');
const prevCanvas = ref(null);
function drawPreview() {
const cv = prevCanvas.value;
const src = prevSrc.value;
if (!cv || !src) return;
const img = new Image();
img.onload = () =>
cv.getContext('2d')?.drawImage(img, 0, 0, cv.width, cv.height);
img.src = src;
}
watch(prevSrc, drawPreview, { flush: 'post' });
onMounted(drawPreview);
// ── Key moments ──
const tip = ref(null);
function tipFor(i) {
const ev = events.value[i];
if (!ev) return;
const w = track.value?.clientWidth || 1;
tip.value = {
ev,
left: clamp((ev.wallMs / dur.value) * w, 90, Math.max(90, w - 90)),
};
}
function pipClick(i) {
haptic();
emit('anchor', events.value[i]);
setTimeout(() => (tip.value = null), 900);
}
// ── Keyboard on the track ──
function goChapter(i) {
seek(chapters.value[i].wallMs + 1);
if (playback.value.exploring) store.controller.resume();
}
// Previous goes to the start of this chapter first, like a video player.
function stepChapter(d) {
const kk = k.value;
const list = chapters.value;
if (d > 0 && kk === list.length - 1) {
seek(dur.value);
return;
}
const to =
d > 0
? Math.min(list.length - 1, kk + 1)
: tNow.value - list[kk].wallMs > 1500
? kk
: Math.max(0, kk - 1);
goChapter(to);
}
function onKey(e) {
if (e.target !== track.value) return;
// A key the timeline handles is the timeline's alone.
const handled = () => {
e.preventDefault();
e.stopPropagation();
};
let tt = tNow.value;
if (e.shiftKey && (e.key === 'ArrowRight' || e.key === 'ArrowLeft')) {
stepChapter(e.key === 'ArrowRight' ? 1 : -1);
handled();
return;
}
if (e.key === 'PageUp') tt += dur.value / 10;
else if (e.key === 'PageDown') tt -= dur.value / 10;
else if (/^[0-9]$/.test(e.key)) tt = dur.value * (+e.key / 10);
else if (e.key === 'ArrowRight' || e.key === 'ArrowUp') tt += 2000;
else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') tt -= 2000;
else if (e.key === 'Home') tt = 0;
else if (e.key === 'End') tt = dur.value;
else if (e.key === ']') {
goChapter(Math.min(chapters.value.length - 1, k.value + 1));
handled();
return;
} else if (e.key === '[') {
goChapter(Math.max(0, k.value - 1));
handled();
return;
} else if (e.key === ' ' || e.key === 'Enter') {
togglePlay();
handled();
return;
} else return;
handled();
seek(tt);
}
// ── Sound, expand ──
const VOL = {
off: '<path d="M4 9.5h3.5L12 5.5v13l-4.5-4H4z" fill="currentColor" stroke="none"/><path d="M16 9.5l5 5M21 9.5l-5 5"/>',
on: '<path d="M4 9.5h3.5L12 5.5v13l-4.5-4H4z" fill="currentColor" stroke="none"/><path d="M15.5 9a4.5 4.5 0 0 1 0 6M18 6.5a8 8 0 0 1 0 11"/>',
};
function toggleExpand() {
store.expanded = !store.expanded;
store.ctxOpen = false;
setTimeout(() => store.controller.reframe(), 320);
}
function jumpLive() {
seek(dur.value);
if (playback.value.exploring) store.controller.resume();
}
onBeforeUnmount(() => cancelAnimationFrame(coastRaf));
defineExpose({ goChapter });
</script>
<template>
<div id="timeline" class="timeline" :data-kind="story.live ? 'live' : ''">
<button
id="tlPlay"
class="tl-play"
:class="{ resume: playMode === 'resume' }"
type="button"
:aria-label="
playMode === 'resume'
? t('Resume story')
: playMode === 'pause'
? t('Pause')
: t('Play')
"
@click="togglePlay"
>
<svg
id="tlIcon"
viewBox="0 0 24 24"
fill="currentColor"
v-html="ICON[playMode]"
></svg>
</button>
<div
id="tlTrack"
ref="track"
class="tl-track"
:class="{ dragging: scrubbing, 'on-pip': !!tip }"
role="slider"
tabindex="0"
:aria-label="t('Story time')"
aria-valuemin="0"
aria-valuemax="100"
:aria-valuenow="Math.round(pct)"
:aria-valuetext="`${clock.big}, ${t('chapter')} ${k + 1}: ${chTitle(chapters[k])}`"
@pointerdown="onDown"
@pointermove="onMove"
@pointerup="onUp"
@pointercancel="onUp"
@pointerleave="onLeave"
@keydown="onKey"
>
<div class="tl-rail">
<div id="tlFill" class="tl-fill" :style="{ width: `${pct}%` }"></div>
</div>
<div id="tlTicks">
<span
v-for="s in segs"
:key="s.i"
class="tl-seg"
:class="{ now: s.i === k, hov: s.i === hovered, snap: s.i === snap }"
:data-k="s.i"
:style="s.style"
><i :style="{ width: s.fill }"></i
></span>
</div>
<div
id="tlGhost"
class="tl-ghost"
:style="{ width: `${ghost}%` }"
aria-hidden="true"
></div>
<div id="tlHead" class="tl-head" aria-hidden="true">
<span id="tlHeadCh"
><b>{{ k + 1 }}</b
>/{{ chapters.length }} · {{ chTitle(chapters[k]) }}</span
>
<span id="tlHeadTime">{{ headTime }}</span>
</div>
<div id="tlPips" role="group" :aria-label="t('Key moments')">
<button
v-for="(ev, i) in events"
:key="i"
type="button"
class="tl-pip"
:class="{ snap: snap === -2 - i }"
:data-e="i"
:aria-label="t('Key moment: {label}', { label: storyText(ev.label) })"
:style="{ left: `${(ev.wallMs / dur) * 100}%`, color: ev.color }"
@pointerdown.stop
@pointerover="tipFor(i)"
@pointerout="tip = null"
@focus="tipFor(i)"
@blur="tip = null"
@click.stop="pipClick(i)"
@keydown.space.stop
@keydown.enter.stop
>
<i :style="{ background: ev.color }"></i>
</button>
</div>
<div
v-if="tip"
id="tlTip"
class="tl-tip"
role="tooltip"
:style="{ left: `${tip.left}px` }"
>
<i :style="{ background: tip.ev.color }"></i
><b>{{ storyText(tip.ev.label) }}</b
><span>{{ stampAt(tip.ev.wallMs) }}</span>
</div>
<div class="tl-knob" :style="{ left: `${pct}%` }"></div>
<div
id="tlBubble"
ref="bubbleEl"
class="tl-bubble"
:data-snap="snap >= 0 ? 'ch' : snap <= -2 ? 'pip' : ''"
:style="bubbleStyle"
>
<canvas
v-if="prevSrc"
id="tlPrev"
ref="prevCanvas"
width="320"
height="180"
aria-hidden="true"
></canvas>
<div id="tlBubbleTxt">
<b>{{ bubbleK + 1 }} · {{ chTitle(chapters[bubbleK]) }}</b>
<span class="tt">{{ bubbleClock.big }}</span>
<em
v-if="bubbleEm"
:style="bubbleEm.color ? { color: bubbleEm.color } : null"
>{{ bubbleEm.text }}</em
>
</div>
</div>
</div>
<span id="tlTime" class="tl-time" aria-hidden="true">
<b v-if="story.live">{{ clock.big }}</b>
<span v-else class="tt-c">{{ headTime }}</span>
</span>
<button
v-if="story.live"
id="tlLive"
class="tl-live"
:class="{ edge: atEdge }"
type="button"
:aria-label="t('Jump to live')"
@click="jumpLive"
>
<i></i>{{ t('LIVE') }}
</button>
<button
id="tlVol"
class="tl-vol"
type="button"
:aria-label="muted ? t('Unmute') : t('Mute')"
:aria-pressed="!muted"
@click="muted = !muted"
>
<svg
id="tlVolIcon"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.9"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
v-html="muted ? VOL.off : VOL.on"
></svg>
</button>
<button
id="stExpand"
class="tl-vol"
type="button"
:aria-label="expanded ? t('Exit expanded map') : t('Expand map')"
:aria-pressed="expanded"
@click="toggleExpand"
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.9"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5" />
</svg>
</button>
</div>
</template>