Address Stories review feedback

This commit is contained in:
Manjunath committed 2026-11-16 22:35:07 +05:30
1 parent 2edcd5bc69
commit fec84dbf78
48 files changed
+783 -232

No files matched your search

+13
View File
@@ -1,4 +1,5 @@
<script setup>
import { computed } from 'vue';
import { storeToRefs } from 'pinia';
import { t } from '../../i18n/index.js';
import UiButton from '../kit/UiButton.vue';
@@ -24,6 +25,7 @@ const { toolbar, dialog } = storeToRefs(useSceneSharingStore());
// answers the buttons through the store.
const scenes = useSceneStore();
const { panel: scene, currentScene } = storeToRefs(scenes);
const emptyScenes = computed(() => scenes.scenes.filter(({ shots }) => !shots.length));
const off = (name) => scene.value?.disabled[name] ?? false;
// The current scene's Stories tags; a chip not yet on is off at the limit.
const tagOn = (tag) => currentScene.value?.storyTags?.includes(tag) ?? false;
@@ -75,6 +77,17 @@ async function importChosen(event) {
<p class="scene-step-heading">{{ t('SCENE') }}</p>
<div class="scene-controls">
<p id="scene-name" :class="{ 'scene-name-empty': !currentScene }">{{ currentScene?.title ?? t('No scene yet') }}</p>
<select
v-if="emptyScenes.length"
id="empty-scene-select"
:aria-label="t('Empty drafts')"
:disabled="off('new')"
:value="currentScene?.shots.length === 0 ? currentScene.id : ''"
@change="scenes.act('selectScene', $event.target.value)"
>
<option value="" disabled>{{ t('Empty drafts') }}</option>
<option v-for="draft in emptyScenes" :key="draft.id" :value="draft.id">{{ draft.title }}</option>
</select>
<UiButton id="scene-new-btn" type="button" :disabled="off('new')" @click="scenes.act('create')" class="gev-action-button scene-btn" :title="t('Start a new, empty scene')">{{ t('NEW SCENE') }}</UiButton>
<UiButton tone="alert" id="scene-delete-btn" type="button" :disabled="off('delete')" @click="scenes.act('deleteScene')" class="gev-action-button gev-action-button--danger scene-btn scene-btn-danger" :title="t('Delete this scene and all of its shots')">{{ t('DELETE') }}</UiButton>
</div>
+17 -3
View File
@@ -284,9 +284,23 @@ onBeforeUnmount(() => {
removeEventListener('keydown', onKey, true);
unguardKeys?.();
});
watch(mode, (m) => {
if (m === 'closed') requestAnimationFrame(placeEntry);
else popOpen.value = false;
let returnFocus = null;
watch(mode, (m, previous) => {
if (m === 'closed') {
requestAnimationFrame(placeEntry);
nextTick(() => {
if (mode.value !== 'closed') return;
const entry = rootEl.value?.querySelector('#hStories');
const target = returnFocus?.isConnected && returnFocus !== document.body
? returnFocus
: entry;
target?.focus({ preventScroll: true });
returnFocus = null;
});
} else {
if (previous === 'closed') returnFocus = document.activeElement;
popOpen.value = false;
}
});
// Each screen (and each story, keyed) mounts its own map slot.
watch([mode, storyId], () => nextTick(watchCredit));
+6 -16
View File
@@ -172,7 +172,7 @@ function headerSearch() {
const feedEl = ref(null);
function pick(id) {
if (picked.value === id) return;
if (innerWidth <= 700 && feedSnap.value === 'list') setFeed('split');
if (innerWidth <= 720 && feedSnap.value === 'list') setFeed('split');
store.controller.pick(id);
nextTick(() =>
feedEl.value
@@ -209,20 +209,13 @@ 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);
// ── Pins: projected into the map area ──
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%)`,
transform: `translate(${p.x}px, ${p.y}px) translate(-50%, -100%)`,
},
})),
);
@@ -240,7 +233,7 @@ function setFeed(snap) {
}
let fd = null;
function onHeadDown(e) {
if (innerWidth > 700 || e.target.closest('.fh-tools')) return;
if (innerWidth > 720 || e.target.closest('.fh-tools')) return;
try {
e.currentTarget.setPointerCapture(e.pointerId);
} catch {
@@ -358,7 +351,7 @@ function onResizeReset() {
}
const bodyStyle = computed(() => ({
'--feed-h': `${(feedH.value ?? FEED[feedSnap.value]) * 100}%`,
...(innerWidth > 700
...(innerWidth > 720
? {
'--feedw': `${feedW.value}px`,
gridTemplateColumns: `${feedW.value}px minmax(0, 1fr)`,
@@ -370,13 +363,10 @@ 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({
@@ -680,7 +670,7 @@ defineExpose({
</aside>
<div class="ex-map">
<div class="map-slot"></div>
<div id="pins" ref="pinsEl" class="pins">
<div id="pins" class="pins">
<button
v-for="p in placedPins"
:key="p.id"
+8 -1
View File
@@ -39,6 +39,8 @@ async function share() {
}
// Long titles scroll gently so the whole name can be read.
const mtitle = ref(null);
const back = ref(null);
const trail = ref(null);
let observer = null;
function fitTitle() {
const el = mtitle.value;
@@ -50,6 +52,10 @@ function fitTitle() {
el.style.setProperty('--mq-dur', `${Math.max(5, (over + 22) / 22)}s`);
}
onMounted(() => {
const target = back.value?.getClientRects().length
? back.value
: trail.value?.querySelector('button');
target?.focus({ preventScroll: true });
if (globalThis.ResizeObserver && mtitle.value) {
observer = new ResizeObserver(fitTitle);
observer.observe(mtitle.value);
@@ -66,6 +72,7 @@ onBeforeUnmount(() => observer?.disconnect());
<template>
<header class="h-top s-head">
<button
ref="back"
class="s-back glass"
type="button"
:aria-label="
@@ -98,7 +105,7 @@ onBeforeUnmount(() => observer?.disconnect());
</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')">
<nav ref="trail" 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>
+1 -1
View File
@@ -131,7 +131,7 @@ function setSheet(s) {
setTimeout(() => store.controller.reframe(), 320);
}
function onHandleDown(e) {
if (innerWidth > 700) return;
if (innerWidth > 720) return;
try {
e.currentTarget.setPointerCapture(e.pointerId);
} catch {
+3 -3
View File
@@ -84,7 +84,7 @@ function goChapter(i) {
}
function goAnchor(ev) {
store.controller.focusEvent(ev);
if (innerWidth <= 700) sheet.value = 'half';
if (innerWidth <= 720) sheet.value = 'half';
}
function bigPlayClick() {
bigPlay.value = false;
@@ -205,7 +205,7 @@ function pokeControls() {
expanded.value &&
playback.value.playing &&
!playback.value.exploring &&
innerWidth <= 700
innerWidth <= 720
)
pokeTimer = setTimeout(() => (controlsHidden.value = true), 3000);
}
@@ -224,7 +224,7 @@ watch(
if (!on || store.sheetHintSeen) return;
hintTimers.push(
setTimeout(() => {
if (store.sheetHintSeen || innerWidth > 700 || sheet.value !== 'peek')
if (store.sheetHintSeen || innerWidth > 720 || sheet.value !== 'peek')
return;
store.sheetHintSeen = true;
sheetHint.value = true;
+29 -50
View File
@@ -1,5 +1,5 @@
<script setup>
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { computed, onMounted, ref, watch } from 'vue';
import { storeToRefs } from 'pinia';
import { t } from '../../../i18n/index.js';
import { useStoriesStore } from '../../stores/stories.js';
@@ -25,7 +25,8 @@ const { playback, muted, expanded } = storeToRefs(store);
const dur = computed(
() => playback.value.durationMs || props.story.durationMs || 1,
);
const tNow = computed(() => playback.value.wallMs);
const previewMs = ref(null);
const tNow = computed(() => previewMs.value ?? 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);
@@ -76,7 +77,12 @@ const segs = computed(() =>
// ── Readout ──
const clock = computed(() =>
clockText(props.story, tNow.value, playback.value.worldMs, k.value),
clockText(
props.story,
tNow.value,
previewMs.value == null ? playback.value.worldMs : null,
k.value,
),
);
const stampAt = (ms) => fmtDur(ms);
const headTime = computed(() => `${fmtDur(tNow.value)} / ${fmtDur(dur.value)}`);
@@ -84,18 +90,15 @@ const atEdge = computed(
() => props.story.live && tNow.value >= dur.value - 600,
);
// ── Scrubbing: magnetic chapter ticks, momentum, haptic ticks ──
// ── Scrubbing: preview locally, seek the globe once on release ──
const track = ref(null);
const scrubbing = ref(false);
const scrubbing = computed(() => previewMs.value !== null);
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);
@@ -105,10 +108,11 @@ const haptic = () => {
};
function trackAt(clientX) {
const r = track.value.getBoundingClientRect();
let u = clamp((clientX - r.left) / r.width, 0, 1);
const width = r.width || 1;
let u = clamp((clientX - r.left) / width, 0, 1);
let snapped = -1;
chapters.value.forEach((c, i) => {
if (i && Math.abs(u - c.wallMs / dur.value) * r.width < 9) {
if (i && Math.abs(u - c.wallMs / dur.value) * width < 9) {
u = c.wallMs / dur.value;
snapped = i;
}
@@ -141,31 +145,26 @@ function scrubTo(target) {
haptic();
sc.ch = ch;
}
seek(tt);
previewMs.value = 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;
if (sc || e.button !== 0 || 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 = {
pointerId: e.pointerId,
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;
scrubTo(r.t);
}
function onMove(e) {
if (!scrubbing.value) {
@@ -184,47 +183,27 @@ function onMove(e) {
bubbleAt.value = r.t;
return;
}
if (sc.pointerId !== e.pointerId) 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;
function finishScrub(e) {
if (sc?.pointerId !== e.pointerId) return;
const at = previewMs.value;
sc = null;
previewMs.value = null;
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);
if (e.type === 'pointerup') seek(at);
else bubbleAt.value = null;
}
function onLeave() {
if (scrubbing.value) return;
@@ -369,7 +348,6 @@ function jumpLive() {
if (playback.value.exploring) store.controller.resume();
}
onBeforeUnmount(() => cancelAnimationFrame(coastRaf));
defineExpose({ goChapter });
</script>
@@ -410,8 +388,9 @@ defineExpose({ goChapter });
:aria-valuetext="`${clock.big}, ${t('chapter')} ${k + 1}: ${chTitle(chapters[k])}`"
@pointerdown="onDown"
@pointermove="onMove"
@pointerup="onUp"
@pointercancel="onUp"
@pointerup="finishScrub"
@pointercancel="finishScrub"
@lostpointercapture="finishScrub"
@pointerleave="onLeave"
@keydown="onKey"
>