mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Take the timeline commits back out before merging their reviewed versions from main
5150279cc,97bd61711,900c76425and4f23ad330went to main, reviewed and changed, as #1745. They are taken out here so main brings them in as merged, rather than as two copies of the same changes in conflict.
This commit is contained in:
1 parent
4f23ad330c
commit
961e6321a5
45 files changed
+1316
-1078
No files matched your search
@@ -0,0 +1,178 @@
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, shallowRef, watch } from 'vue';
|
||||
import { formatUtcDayMonth, t } from '../../i18n/index.js';
|
||||
import { utcClock } from './utcClock.js';
|
||||
import UiSlider from '../kit/UiSlider.js';
|
||||
|
||||
// Stable native transport with local preview and a coalesced 150 ms drag
|
||||
// commit. While the handle is dragged the slider keeps the ticks it was
|
||||
// dragged over; the owner's updates apply once the drag ends.
|
||||
const props = defineProps({
|
||||
state: { type: Object, required: true },
|
||||
sliderClassName: { type: String, default: '' },
|
||||
heading: { type: Boolean, default: true },
|
||||
onCommit: { type: Function, default: () => {} },
|
||||
onPreview: { type: Function, default: () => {} },
|
||||
onStep: { type: Function, default: () => {} },
|
||||
onLatest: { type: Function, default: () => {} },
|
||||
onPlay: { type: Function, default: () => {} },
|
||||
});
|
||||
|
||||
const utc = (tick) =>
|
||||
Number.isFinite(Date.parse(tick))
|
||||
? `${formatUtcDayMonth(tick)} ${utcClock(tick)}`
|
||||
: '';
|
||||
|
||||
// What the slider shows: the owner's ticks, index and readout, frozen while
|
||||
// dragging.
|
||||
const shown = shallowRef({ ticks: [], index: 0, readout: '' });
|
||||
let dragging = false;
|
||||
let timer = null;
|
||||
let pending = null;
|
||||
let live = true;
|
||||
|
||||
const cancel = () => {
|
||||
if (timer !== null) clearTimeout(timer);
|
||||
timer = null;
|
||||
};
|
||||
const sync = () => {
|
||||
if (dragging) return;
|
||||
const ticks = [...props.state.ticks];
|
||||
shown.value = {
|
||||
ticks,
|
||||
index: Math.max(0, Math.min(props.state.index, ticks.length - 1)),
|
||||
readout: props.state.readout || '',
|
||||
};
|
||||
};
|
||||
watch(
|
||||
() => props.state,
|
||||
(state) => {
|
||||
if (state.disabled) {
|
||||
cancel();
|
||||
pending = null;
|
||||
dragging = false;
|
||||
}
|
||||
sync();
|
||||
},
|
||||
{ immediate: true, flush: 'sync' },
|
||||
);
|
||||
onBeforeUnmount(() => {
|
||||
live = false;
|
||||
cancel();
|
||||
});
|
||||
|
||||
const disabled = computed(() => Boolean(props.state.disabled));
|
||||
const latestActive = computed(() => props.state.mode === 'latest');
|
||||
const playing = computed(() => Boolean(props.state.playing));
|
||||
|
||||
function commit() {
|
||||
cancel();
|
||||
const value = pending;
|
||||
pending = null;
|
||||
if (live && value && !props.state.disabled)
|
||||
props.onCommit(value.tick, value.index);
|
||||
}
|
||||
function preview(event) {
|
||||
if (props.state.disabled) return;
|
||||
dragging = true;
|
||||
const index = Number(event.target.value);
|
||||
const tick = shown.value.ticks[index];
|
||||
if (!tick) return;
|
||||
pending = { tick, index };
|
||||
// Shown before the owner hears of it: an update from inside onPreview
|
||||
// must not move the handle back.
|
||||
shown.value = { ...shown.value, index };
|
||||
const readout = props.onPreview(tick, index);
|
||||
// The owner may have ended the drag (disabled) from inside onPreview.
|
||||
if (!dragging) return;
|
||||
if (typeof readout === 'string') shown.value = { ...shown.value, readout };
|
||||
if (timer === null) timer = setTimeout(commit, 150);
|
||||
}
|
||||
// The handle shows the shown index again. A drag that ends where it began
|
||||
// (an input and a cancel, or a refused commit, before the next render)
|
||||
// leaves the slider's model unchanged, so it would not render.
|
||||
const place = (input) => {
|
||||
const index = String(shown.value.index);
|
||||
if (input && input.value !== index) input.value = index;
|
||||
};
|
||||
function change(event) {
|
||||
if (props.state.disabled) return;
|
||||
const index = Number(event.target.value);
|
||||
pending = { tick: shown.value.ticks[index], index };
|
||||
dragging = false;
|
||||
commit();
|
||||
sync();
|
||||
place(event.target);
|
||||
}
|
||||
function reset(event) {
|
||||
cancel();
|
||||
pending = null;
|
||||
dragging = false;
|
||||
sync();
|
||||
place(event?.target);
|
||||
}
|
||||
function blur(event) {
|
||||
if (dragging) change(event);
|
||||
}
|
||||
const act = (fn) => {
|
||||
reset();
|
||||
if (live && !props.state.disabled) fn();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="rail-timeline"
|
||||
><div v-if="heading" class="panel-title">{{ t('Observed history') }}</div
|
||||
><div class="rail-timeline-track"
|
||||
><button
|
||||
type="button"
|
||||
class="data-toggle-chip"
|
||||
:title="t('Earlier observation')"
|
||||
:disabled="disabled || state.index <= 0"
|
||||
@click="act(() => onStep(-1))"
|
||||
>‹</button
|
||||
><UiSlider
|
||||
:class="sliderClassName || undefined"
|
||||
min="0"
|
||||
:max="String(Math.max(0, shown.ticks.length - 1))"
|
||||
step="1"
|
||||
:model-value="String(shown.index)"
|
||||
:disabled="disabled"
|
||||
:aria-label="t('Observed history')"
|
||||
:aria-valuetext="utc(shown.ticks[shown.index])"
|
||||
@input="preview"
|
||||
@change="change"
|
||||
@pointercancel="reset"
|
||||
@blur="blur"
|
||||
/><button
|
||||
type="button"
|
||||
class="data-toggle-chip"
|
||||
:title="t('Later observation')"
|
||||
:disabled="disabled || state.index >= state.ticks.length - 1"
|
||||
@click="act(() => onStep(1))"
|
||||
>›</button
|
||||
><div class="rail-timeline-endpoints"
|
||||
><span>{{ utcClock(shown.ticks[0]) }}</span
|
||||
><span>{{ utcClock(shown.ticks.at(-1)) }}</span></div
|
||||
></div
|
||||
><div class="rail-timeline-controls"
|
||||
><button
|
||||
type="button"
|
||||
:class="`data-toggle-chip${latestActive ? ' active' : ''}`"
|
||||
:title="t('Newest frame per product')"
|
||||
:disabled="disabled"
|
||||
:aria-pressed="String(latestActive)"
|
||||
@click="act(onLatest)"
|
||||
>{{ t('Latest') }}</button
|
||||
><button
|
||||
type="button"
|
||||
:class="`data-toggle-chip${playing ? ' active' : ''}`"
|
||||
:title="t('Replay observed history')"
|
||||
:disabled="disabled"
|
||||
:aria-pressed="String(playing)"
|
||||
@click="act(onPlay)"
|
||||
>{{ playing ? t('Pause') : t('Play') }}</button
|
||||
><span class="rail-timeline-readout">{{ shown.readout }}</span></div
|
||||
></section
|
||||
>
|
||||
</template>
|
||||
@@ -0,0 +1,56 @@
|
||||
import { h, render } from 'vue';
|
||||
import RailTimeline from './rail/RailTimeline.vue';
|
||||
|
||||
export { utcClock } from './rail/utcClock.js';
|
||||
|
||||
/**
|
||||
* Stable native transport with local preview and a coalesced 150 ms drag
|
||||
* commit. Renders the RailTimeline component into `container` and patches it
|
||||
* synchronously on every update.
|
||||
*/
|
||||
export function createRailTimeline({
|
||||
container,
|
||||
document = container?.ownerDocument,
|
||||
sliderClassName = '',
|
||||
heading = true,
|
||||
onCommit = () => {},
|
||||
onPreview = () => {},
|
||||
onStep = () => {},
|
||||
onLatest = () => {},
|
||||
onPlay = () => {},
|
||||
} = {}) {
|
||||
if (!document?.createElement || !container) return null;
|
||||
let destroyed = false;
|
||||
const paint = (state) =>
|
||||
render(
|
||||
h(RailTimeline, {
|
||||
state,
|
||||
sliderClassName,
|
||||
heading,
|
||||
onCommit,
|
||||
onPreview,
|
||||
onStep,
|
||||
onLatest,
|
||||
onPlay,
|
||||
}),
|
||||
container,
|
||||
);
|
||||
paint({
|
||||
ticks: [],
|
||||
index: 0,
|
||||
mode: 'latest',
|
||||
playing: false,
|
||||
readout: '',
|
||||
disabled: true,
|
||||
});
|
||||
return {
|
||||
update(state) {
|
||||
if (!destroyed) paint(state);
|
||||
},
|
||||
destroy() {
|
||||
if (destroyed) return;
|
||||
destroyed = true;
|
||||
render(null, container);
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { assertSameNode } from '../testSupport/domAssert.mjs';
|
||||
import { nextTick } from 'vue';
|
||||
import { createRailTimeline } from './railTimeline.js';
|
||||
import { railDocumentFixture as railFixture } from './railTestFixture.mjs';
|
||||
const ticks = [
|
||||
'2026-09-22T01:00:00Z',
|
||||
'2026-09-22T01:05:00Z',
|
||||
'2026-09-22T01:10:00Z',
|
||||
];
|
||||
const props = {
|
||||
ticks,
|
||||
index: 2,
|
||||
mode: 'latest',
|
||||
playing: false,
|
||||
readout: 'Latest',
|
||||
disabled: false,
|
||||
};
|
||||
test('preview is immediate, commits are coalesced and the drag DOM and tick mapping stay stable', async (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
const f = railFixture();
|
||||
const previews = [];
|
||||
const commits = [];
|
||||
const view = createRailTimeline({
|
||||
...f,
|
||||
onPreview: (tick) => {
|
||||
previews.push(tick);
|
||||
return tick;
|
||||
},
|
||||
onCommit: (tick) => commits.push(tick),
|
||||
});
|
||||
view.update(props);
|
||||
const slider = f.find((n) => n.tagName === 'INPUT');
|
||||
const row = slider.parentElement;
|
||||
assert.equal(slider.getAttribute('aria-label'), 'Observed history');
|
||||
slider.value = '0';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
assert.deepEqual(commits, []);
|
||||
assert.deepEqual(previews, [ticks[0]]);
|
||||
await nextTick();
|
||||
assert.equal(slider.getAttribute('aria-valuetext'), '09-22 01:00 UTC');
|
||||
view.update({
|
||||
...props,
|
||||
ticks: ticks.slice(1),
|
||||
index: 1,
|
||||
readout: 'Refresh',
|
||||
});
|
||||
assertSameNode(slider.parentElement, row);
|
||||
assertSameNode(row.children[1], slider);
|
||||
assert.equal(slider.value, '0');
|
||||
assert.equal(slider.max, '2');
|
||||
assert.equal(
|
||||
f.find((n) => n.className === 'rail-timeline-readout').textContent,
|
||||
ticks[0],
|
||||
);
|
||||
t.mock.timers.tick(149);
|
||||
assert.equal(commits.length, 0);
|
||||
slider.value = '1';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
t.mock.timers.tick(1);
|
||||
assert.deepEqual(commits, [ticks[1]]);
|
||||
slider.value = '2';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
slider.dispatchEvent(new Event('change'));
|
||||
assert.deepEqual(commits, [ticks[1], ticks[2]]);
|
||||
t.mock.timers.tick(150);
|
||||
assert.equal(commits.length, 2);
|
||||
await nextTick();
|
||||
assert.equal(slider.max, '1', 'release applies the latest update');
|
||||
view.destroy();
|
||||
});
|
||||
test('identical updates write nothing; controls call actions and destruction cancels commits', (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
const f = railFixture();
|
||||
const calls = [];
|
||||
const view = createRailTimeline({
|
||||
...f,
|
||||
onCommit: () => calls.push('commit'),
|
||||
onStep: (n) => calls.push(n),
|
||||
onLatest: () => calls.push('latest'),
|
||||
onPlay: () => calls.push('play'),
|
||||
});
|
||||
view.update({ ...props, index: 1 });
|
||||
f.writes();
|
||||
view.update({ ...props, index: 1 });
|
||||
assert.equal(f.writes(), 0);
|
||||
for (const label of ['‹', '›', 'Latest', 'Play'])
|
||||
f.find((n) => n.textContent === label).click();
|
||||
assert.deepEqual(calls, [-1, 1, 'latest', 'play']);
|
||||
view.update({ ...props, playing: true });
|
||||
assert.ok(f.find((n) => n.textContent === 'Pause'));
|
||||
const slider = f.find((n) => n.tagName === 'INPUT');
|
||||
slider.value = '0';
|
||||
slider.dispatchEvent(new Event('change'));
|
||||
assert.equal(calls.at(-1), 'commit');
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
view.destroy();
|
||||
t.mock.timers.tick(150);
|
||||
assert.equal(calls.length, 5);
|
||||
assert.equal(f.container.children.length, 0);
|
||||
});
|
||||
|
||||
test('observed history label and endpoint times track the advertised tick range', () => {
|
||||
const f = railFixture();
|
||||
const view = createRailTimeline(f);
|
||||
view.update(props);
|
||||
assert.equal(
|
||||
f.find((n) => n.className === 'panel-title').textContent,
|
||||
'Observed history',
|
||||
);
|
||||
const endpoints = f.find((n) => n.className === 'rail-timeline-endpoints');
|
||||
assert.equal(endpoints.parentElement.className, 'rail-timeline-track');
|
||||
assert.deepEqual(
|
||||
[...endpoints.children].map((n) => n.textContent),
|
||||
['01:00 UTC', '01:10 UTC'],
|
||||
);
|
||||
view.update({ ...props, ticks: ticks.slice(1) });
|
||||
assert.equal(endpoints.children[0].textContent, '01:05 UTC');
|
||||
view.destroy();
|
||||
});
|
||||
|
||||
test('an update from inside the preview neither moves the handle back nor survives a disable', async () => {
|
||||
const f = railFixture();
|
||||
let view;
|
||||
let next = null;
|
||||
const commits = [];
|
||||
view = createRailTimeline({
|
||||
...f,
|
||||
onPreview: () => {
|
||||
if (next) view.update(next);
|
||||
return 'preview';
|
||||
},
|
||||
onCommit: (tick, index) => commits.push(index),
|
||||
});
|
||||
view.update(props);
|
||||
const slider = f.find((n) => n.tagName === 'INPUT');
|
||||
next = { ...props, readout: 'Refresh' };
|
||||
slider.value = '0';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
assert.equal(slider.value, '0');
|
||||
slider.dispatchEvent(new Event('change'));
|
||||
assert.deepEqual(commits, [0]);
|
||||
next = { ...props, disabled: true };
|
||||
slider.value = '1';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
await nextTick();
|
||||
assert.equal(slider.value, '2', 'the disabled owner keeps its position');
|
||||
assert.equal(slider.getAttribute('aria-valuetext'), '09-22 01:10 UTC');
|
||||
view.destroy();
|
||||
});
|
||||
test('a drag that ends where it began puts the handle back on the shown index', async (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
const f = railFixture();
|
||||
const commits = [];
|
||||
const view = createRailTimeline({
|
||||
...f,
|
||||
onCommit: (tick) => commits.push(tick),
|
||||
});
|
||||
view.update(props);
|
||||
await nextTick();
|
||||
const slider = f.find((n) => n.tagName === 'INPUT');
|
||||
slider.value = '0';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
slider.dispatchEvent(new Event('pointercancel'));
|
||||
await nextTick();
|
||||
assert.equal(slider.value, '2', 'a cancelled drag');
|
||||
assert.deepEqual(commits, []);
|
||||
// A refused commit: the owner keeps its index.
|
||||
slider.value = '1';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
slider.dispatchEvent(new Event('change'));
|
||||
await nextTick();
|
||||
assert.deepEqual(commits, [ticks[1]]);
|
||||
assert.equal(slider.value, '2', 'a refused commit');
|
||||
view.destroy();
|
||||
});
|
||||
@@ -27,8 +27,7 @@ export const WORLD_TIME_SPEEDS = Object.freeze({
|
||||
* buffering, timeMs, supported, span}`, where `supported` says a layer that moves with the clock
|
||||
* has time to show and `span` is the stretch the timeline runs over: the
|
||||
* time those layers cover, reaching to now and to the world time, with their
|
||||
* marks (`marks`, their times; `markDetails`, each `{time, label?, id?,
|
||||
* kind?}`, as the world clock's coverage gives them). It follows the page's world clock, which tells it of every move, and
|
||||
* marks. It follows the page's world clock, which tells it of every move, and
|
||||
* of the time a few times a second while it plays on its own. While a
|
||||
* timeline shows, it reads the clock each second itself, so live and the
|
||||
* track's end keep up with now.
|
||||
@@ -43,7 +42,6 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
start: Math.min(coverage.start, now),
|
||||
end: Math.max(coverage.end, now),
|
||||
marks: coverage.marks,
|
||||
markDetails: coverage.markDetails,
|
||||
};
|
||||
};
|
||||
const spanOf = (state) => {
|
||||
@@ -54,7 +52,6 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
start: Math.min(covered.start, state.timeMs),
|
||||
end: Math.max(covered.end, state.timeMs),
|
||||
marks: covered.marks,
|
||||
markDetails: covered.markDetails,
|
||||
});
|
||||
};
|
||||
const nearNow = (ms, length) =>
|
||||
@@ -128,8 +125,8 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
/**
|
||||
* Play runs the track at the speed chosen, from the start when it is at
|
||||
* its end (at live, say), as a video plays again from the top. It runs
|
||||
* the clock itself: weather follows the time frame by frame like every
|
||||
* other layer the track covers.
|
||||
* the clock itself, past weather's own replay: weather follows the time
|
||||
* frame by frame like every other layer the track covers.
|
||||
*/
|
||||
togglePlay() {
|
||||
const { playing, live, timeMs, span } = time.value;
|
||||
@@ -141,9 +138,9 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
},
|
||||
speed,
|
||||
/**
|
||||
* Choose how fast play runs; playing, it changes at once. A driver steps
|
||||
* at its own pace, so a speed chosen while one plays takes playback over
|
||||
* from where it is.
|
||||
* Choose how fast play runs; playing, it changes at once. Weather's own
|
||||
* replay steps at its own pace, so a speed chosen while it plays takes
|
||||
* playback over from where it is.
|
||||
*/
|
||||
setSpeed(next) {
|
||||
if (!Object.hasOwn(WORLD_TIME_SPEEDS, next)) return;
|
||||
|
||||
@@ -56,7 +56,8 @@
|
||||
}
|
||||
/* Card typography follows the layer rows and app tokens. */
|
||||
.weather-readout,
|
||||
.rail-card {
|
||||
.rail-card,
|
||||
.rail-timeline {
|
||||
min-width: 0;
|
||||
color: var(--text-dim);
|
||||
font: 9px/1.45 var(--font-mono);
|
||||
@@ -127,7 +128,7 @@
|
||||
text-align: right;
|
||||
}
|
||||
.rail-card-line,
|
||||
.weather-frame-time {
|
||||
.rail-timeline-readout {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.5px;
|
||||
@@ -187,13 +188,54 @@ html:not([lang='en']) .weather-card [data-line-id='status'] {
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
.rail-card [hidden],
|
||||
.weather-frame-time[hidden],
|
||||
.weather-timeline-block[hidden],
|
||||
.weather-observed-group[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
.weather-frame-time {
|
||||
.rail-timeline {
|
||||
padding: 5px;
|
||||
border-bottom: 1px solid var(--weather-card-border);
|
||||
}
|
||||
.rail-timeline-track {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 3px 8px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.rail-timeline-track input {
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
.rail-timeline-endpoints {
|
||||
display: flex;
|
||||
grid-column: 2;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 3px 8px;
|
||||
font: 8px/1.45 var(--font-mono);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.rail-timeline-endpoints span {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.rail-timeline-endpoints span:last-child {
|
||||
margin-left: auto;
|
||||
}
|
||||
.rail-timeline-controls .data-toggle-chip {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.rail-timeline-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.rail-timeline-readout {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: var(--text-secondary);
|
||||
|
||||
@@ -194,26 +194,6 @@ body.cockpit-mode #world-timeline {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* A tick's label, shown over the time's bubble while the pointer is on the
|
||||
tick (or the handle rests on its mark). It slides across itself as the
|
||||
bubble does, so it stays within the track. */
|
||||
#world-timeline .world-timeline-mark-label {
|
||||
position: absolute;
|
||||
bottom: calc(100% + 30px);
|
||||
left: calc(100% * var(--at));
|
||||
z-index: 1;
|
||||
padding: 2px 8px;
|
||||
border: 1px solid rgba(0, 212, 255, 0.4);
|
||||
border-radius: 6px;
|
||||
background: var(--glass-bg);
|
||||
color: var(--text-primary);
|
||||
font-size: 11px;
|
||||
line-height: 1.4;
|
||||
white-space: pre;
|
||||
transform: translateX(calc(var(--at) * -100%));
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Zoomed, the track drags along. */
|
||||
#world-timeline .world-timeline-track.is-zoomed {
|
||||
cursor: grab;
|
||||
|
||||
@@ -581,91 +581,3 @@ test('a pinch measures from where the fingers are, and a lifted finger ends it',
|
||||
assert.ok(Math.abs(length() - zoomedTo) < 1_000);
|
||||
on(input, 'pointercancel', 100, 1);
|
||||
});
|
||||
|
||||
test('a tick shows its label on hover, and a tap by it goes to its mark', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
const start = now - 10 * 86_400_000;
|
||||
// Ticks a fifth and seven tenths along a 1000 px track.
|
||||
const launch = start + (now - start) * 0.2;
|
||||
const quake = start + (now - start) * 0.7;
|
||||
const release = worldClock.hold('test-launches');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-launches',
|
||||
coverage: () => ({
|
||||
start,
|
||||
end: now,
|
||||
marks: [
|
||||
start,
|
||||
{ time: launch, label: 'GAUNTLET PAYLOAD', id: 'l1', kind: 'launch' },
|
||||
{ time: quake, label: 'M6.4 · Fiji', kind: 'earthquake' },
|
||||
],
|
||||
}),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
const track = bar().querySelector('.world-timeline-track');
|
||||
const input = bar().querySelector('input[type=range]');
|
||||
Object.defineProperty(track, 'clientWidth', { value: 1_000 });
|
||||
track.getBoundingClientRect = () => ({ left: 0, width: 1_000, top: 0, height: 24 });
|
||||
const press = (type, clientX, pointerId = 1) =>
|
||||
track.dispatchEvent(new PointerEvent(type, { bubbles: true, clientX, pointerId }));
|
||||
const tip = () => bar().querySelector('.world-timeline-mark-label');
|
||||
assert.equal(bar().querySelectorAll('.world-timeline-tick').length, 3, 'ticks stay ticks');
|
||||
assert.equal(tip(), null);
|
||||
|
||||
// Hovering within 6 px of a tick shows its label, in place of the track's hint.
|
||||
press('pointermove', 205);
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent, 'GAUNTLET PAYLOAD');
|
||||
assert.equal(track.hasAttribute('title'), false);
|
||||
press('pointermove', 698);
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent, 'M6.4 · Fiji');
|
||||
// Further off, or on a tick with no label, nothing shows.
|
||||
press('pointermove', 690);
|
||||
await nextTick();
|
||||
assert.equal(tip(), null);
|
||||
assert.equal(track.hasAttribute('title'), true);
|
||||
press('pointermove', 2);
|
||||
await nextTick();
|
||||
assert.equal(tip(), null, 'an unlabelled mark has no label');
|
||||
press('pointermove', 205);
|
||||
track.dispatchEvent(new PointerEvent('pointerleave', { clientX: 1_100, pointerId: 1 }));
|
||||
await nextTick();
|
||||
assert.equal(tip(), null, 'leaving the track hides it');
|
||||
|
||||
// A tap by a tick goes to its mark exactly; elsewhere, to the time there.
|
||||
press('pointerdown', 704);
|
||||
press('pointerup', 704);
|
||||
await nextTick();
|
||||
assert.equal(worldClock.now(), quake);
|
||||
assert.match(input.getAttribute('aria-valuetext'), / · M6\.4 · Fiji$/);
|
||||
press('pointerdown', 500);
|
||||
press('pointerup', 500);
|
||||
await nextTick();
|
||||
const middle = start + (now - start) / 2;
|
||||
assert.ok(Math.abs(worldClock.now() - middle) < 60_000, 'went to the middle');
|
||||
assert.notEqual(worldClock.now(), quake);
|
||||
assert.match(input.getAttribute('aria-valuetext'), /UTC$/, 'off a mark, the time alone');
|
||||
// A drag from a tick still scrubs.
|
||||
press('pointerdown', 200);
|
||||
press('pointermove', 300);
|
||||
press('pointerup', 300);
|
||||
await nextTick();
|
||||
assert.ok(Math.abs(worldClock.now() - (start + (now - start) * 0.3)) < 60_000);
|
||||
|
||||
// The arrows go to the marks and tell their labels; focused, the label shows.
|
||||
input.dispatchEvent(new Event('focus'));
|
||||
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowLeft' }));
|
||||
await nextTick();
|
||||
assert.equal(worldClock.now(), launch);
|
||||
assert.match(input.getAttribute('aria-valuetext'), / · GAUNTLET PAYLOAD$/);
|
||||
assert.equal(tip()?.textContent, 'GAUNTLET PAYLOAD');
|
||||
input.dispatchEvent(new Event('blur'));
|
||||
await nextTick();
|
||||
assert.equal(tip(), null);
|
||||
});
|
||||
@@ -8,12 +8,11 @@ import UiIcon from '../../kit/UiIcon.vue';
|
||||
import UiSelect from '../../kit/UiSelect.js';
|
||||
|
||||
// The world timeline: play and pause and the speed on the left, a track
|
||||
// across the stretch the layers on can show (each mark, a launch or a strong
|
||||
// earthquake, a tick, its label shown over it on hover) with a handle to
|
||||
// scrub and the time in a bubble over it, and the way back to live on the
|
||||
// right, lit while live. Scrolling or pinching the track zooms it around the
|
||||
// handle, dragging it moves along it, a tap on or by a tick goes to its
|
||||
// mark's time exactly, and a double-click shows it all again. It shows
|
||||
// across the stretch the layers on can show (each launch or frame a tick)
|
||||
// with a handle to scrub and the time in a bubble over it, and the way back
|
||||
// to live on the right, lit while live. Scrolling or pinching the track
|
||||
// zooms it around the handle, dragging it moves along it, and a double-click
|
||||
// shows it all again. It shows
|
||||
// while a layer with a time of its own (weather, satellites, launches,
|
||||
// or one a host follows) is on with time to show; with only live feeds such
|
||||
// as flights on, the bar stays hidden.
|
||||
@@ -54,8 +53,6 @@ const ZOOM_STEP = 1.5;
|
||||
const WHEEL_ZOOM = 0.0025;
|
||||
// Two presses this close are a double-click.
|
||||
const DOUBLE_PRESS_MS = 500;
|
||||
// A tap or a hover this near a tick, in pixels, is on its mark.
|
||||
const MARK_HIT_PX = 6;
|
||||
|
||||
const readout = computed(() =>
|
||||
Number.isFinite(time.value.timeMs)
|
||||
@@ -215,7 +212,6 @@ let movedTime = false;
|
||||
const onPointerDown = (event) => {
|
||||
// Only the main button: a right-click is for the menu.
|
||||
if (event.button > 0) return;
|
||||
hovered.value = null;
|
||||
const onHandle = event.target instanceof HTMLInputElement;
|
||||
pointers.set(event.pointerId, { x: event.clientX, onHandle });
|
||||
if (pointers.size === 1) {
|
||||
@@ -245,10 +241,6 @@ const onPointerDown = (event) => {
|
||||
gesture = { kind: 'press', x: event.clientX, end: view.value.end };
|
||||
};
|
||||
const onPointerMove = (event) => {
|
||||
// A pointer hovering, none pressed, shows the label of the tick under it.
|
||||
hovered.value = pointers.size
|
||||
? null
|
||||
: (markNear(event.clientX, event.currentTarget)?.time ?? null);
|
||||
const pointer = pointers.get(event.pointerId);
|
||||
if (!pointer) return;
|
||||
pointer.x = event.clientX;
|
||||
@@ -274,14 +266,8 @@ const onPointerMove = (event) => {
|
||||
};
|
||||
const onPointerUp = (event) => {
|
||||
if (!pointers.delete(event.pointerId)) return;
|
||||
// A tap on or by a tick goes to its mark exactly; elsewhere, to the time
|
||||
// under it.
|
||||
if (gesture?.kind === 'press' && event.type === 'pointerup')
|
||||
store.scrub(
|
||||
markNear(event.clientX, event.currentTarget)?.time ??
|
||||
timeAt(event.clientX, event.currentTarget),
|
||||
viewLength(),
|
||||
);
|
||||
store.scrub(timeAt(event.clientX, event.currentTarget), viewLength());
|
||||
// A finger lifted from a pinch ends it; the other one moves nothing.
|
||||
gesture = null;
|
||||
};
|
||||
@@ -290,66 +276,11 @@ const place = (ms) => {
|
||||
const { start, end } = view.value;
|
||||
return end > start ? ((ms - start) / (end - start)) * 100 : 100;
|
||||
};
|
||||
// The labels of the marks at each time marked; a time may have none.
|
||||
const markLabels = computed(() => {
|
||||
const labels = new Map();
|
||||
for (const mark of span.value?.markDetails ?? []) {
|
||||
if (!labels.has(mark.time)) labels.set(mark.time, []);
|
||||
if (mark.label) labels.get(mark.time).push(mark.label);
|
||||
}
|
||||
return labels;
|
||||
});
|
||||
// A tick for each time marked in view: where it sits, as a share of the
|
||||
// track, and its marks' labels.
|
||||
const ticks = computed(() => {
|
||||
const { start, end } = view.value;
|
||||
return span.value.marks
|
||||
.filter((mark) => mark >= start && mark <= end)
|
||||
.map((mark) => ({
|
||||
time: mark,
|
||||
share: place(mark) / 100,
|
||||
labels: markLabels.value.get(mark) ?? [],
|
||||
}));
|
||||
});
|
||||
// The tick nearest `clientX` within MARK_HIT_PX of it, or null.
|
||||
function markNear(clientX, track) {
|
||||
if (!view.value) return null;
|
||||
const { left, width } = track.getBoundingClientRect();
|
||||
if (!(width > 0)) return null;
|
||||
let near = null;
|
||||
let nearest = MARK_HIT_PX;
|
||||
for (const tick of ticks.value) {
|
||||
const off = Math.abs(left + tick.share * width - clientX);
|
||||
if (off <= nearest) {
|
||||
near = tick;
|
||||
nearest = off;
|
||||
}
|
||||
}
|
||||
return near;
|
||||
}
|
||||
// The time of the tick the pointer hovers, and whether the handle has focus.
|
||||
const hovered = shallowRef(null);
|
||||
const focused = shallowRef(false);
|
||||
// The labels shown over the track: the hovered tick's, or with the handle
|
||||
// focused and paused on a mark (an arrow key or a tap took it there), that
|
||||
// mark's. Nothing for a mark with no label.
|
||||
const markTip = computed(() => {
|
||||
if (!view.value) return null;
|
||||
const onMark = !time.value.live && focused.value ? time.value.timeMs : null;
|
||||
const over = ticks.value.find((each) => each.time === hovered.value);
|
||||
const tick = over ?? ticks.value.find((each) => each.time === onMark);
|
||||
return tick?.labels.length
|
||||
? { share: tick.share, text: tick.labels.join('\n'), hover: Boolean(over) }
|
||||
: null;
|
||||
});
|
||||
// The time as the handle tells it, with the labels of the mark it is on.
|
||||
const valueText = computed(() => {
|
||||
const labels = time.value.live
|
||||
? null
|
||||
: markLabels.value.get(time.value.timeMs);
|
||||
return labels?.length
|
||||
? `${readout.value} · ${labels.join('; ')}`
|
||||
: readout.value;
|
||||
.map((mark) => `${place(mark)}%`);
|
||||
});
|
||||
const shown = computed(() =>
|
||||
Math.min(view.value.end, Math.max(view.value.start, at.value)),
|
||||
@@ -363,11 +294,10 @@ const scrub = (event) => {
|
||||
}
|
||||
store.scrub(Number(event.target.value), viewLength());
|
||||
};
|
||||
// Arrows go to the previous or next mark (a launch, a strong earthquake),
|
||||
// whose label the handle then tells with the time, or a step along the track
|
||||
// as shown where there is none; Page keys take a tenth
|
||||
// of it; Home and End go to the ends of all of it. Plus and minus zoom, and
|
||||
// zero shows it all; with a modifier they are the browser's own zoom.
|
||||
// Arrows go to the previous or next mark (a launch, a frame), or a step along
|
||||
// the track as shown; Page keys take a tenth of it; Home and End go to the
|
||||
// ends of all of it. Plus and minus zoom, and zero shows it all; with a
|
||||
// modifier they are the browser's own zoom.
|
||||
const ZOOM_KEYS = ['+', '=', '-', '0'];
|
||||
const onKey = (event) => {
|
||||
if (ZOOM_KEYS.includes(event.key)) {
|
||||
@@ -401,18 +331,17 @@ const onKey = (event) => {
|
||||
><UiButton class="world-timeline-play" :label="time.playing ? t('Pause') : t('Play')" @click="store.togglePlay()"
|
||||
><UiIcon :name="time.playing ? 'pause' : 'play_arrow'" :size="20" /></UiButton
|
||||
><UiSelect class="gev-field gev-field--compact world-timeline-speed" :aria-label="t('Play speed')" :title="t('Play speed')" :options="speeds" :model-value="speed" @update:model-value="store.setSpeed($event)"
|
||||
/><div class="world-timeline-track" :class="{ 'is-zoomed': zoomed }" :title="markTip?.hover ? undefined : t('Scroll or pinch to zoom, drag to move along · double-click to see it all')" @wheel="onWheel" @dblclick="showAll" @pointerdown="onPointerDown" @pointermove="onPointerMove" @pointerup="onPointerUp" @pointercancel="onPointerUp" @pointerleave="hovered = null"
|
||||
/><div class="world-timeline-track" :class="{ 'is-zoomed': zoomed }" :title="t('Scroll or pinch to zoom, drag to move along · double-click to see it all')" @wheel="onWheel" @dblclick="showAll" @pointerdown="onPointerDown" @pointermove="onPointerMove" @pointerup="onPointerUp" @pointercancel="onPointerUp"
|
||||
><time class="world-timeline-time" :class="{ 'is-waiting': waiting }" :style="{ '--at': place(shown) / 100 }" :datetime="new Date(time.timeMs).toISOString()" aria-live="off"
|
||||
><span v-if="waiting" class="world-timeline-spinner" aria-hidden="true"></span>{{ bubble }}</time
|
||||
><span v-if="markTip" class="world-timeline-mark-label" :style="{ '--at': markTip.share }" aria-hidden="true">{{ markTip.text }}</span
|
||||
><span v-for="tick in ticks" :key="tick.time" class="world-timeline-tick" :style="{ left: `${tick.share * 100}%` }" aria-hidden="true"></span
|
||||
><span v-for="(left, index) in ticks" :key="index" class="world-timeline-tick" :style="{ left }" aria-hidden="true"></span
|
||||
><span class="world-timeline-fill" :style="{ width: `${place(shown)}%` }" aria-hidden="true"></span
|
||||
><input
|
||||
class="world-timeline-scrub"
|
||||
:class="{ 'is-off-view': handleOff }"
|
||||
type="range"
|
||||
:aria-label="t('World time')"
|
||||
:aria-valuetext="valueText"
|
||||
:aria-valuetext="readout"
|
||||
:min="view.start"
|
||||
:max="view.end"
|
||||
step="any"
|
||||
@@ -420,8 +349,6 @@ const onKey = (event) => {
|
||||
@input="scrub"
|
||||
aria-keyshortcuts="+ - 0"
|
||||
@keydown="onKey"
|
||||
@focus="focused = true"
|
||||
@blur="focused = false"
|
||||
/></div
|
||||
><UiButton class="world-timeline-live" :label="time.live ? t('Live') : t('Back to live')" :pressed="time.live" pressed-class="is-live" :disabled="time.live" @click="store.goLive()">{{ t('Live') }}</UiButton
|
||||
></div>
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
<script setup>
|
||||
import { t } from '../../i18n/index.js';
|
||||
import RailCards from '../rail/RailCards.vue';
|
||||
import RailTimeline from '../rail/RailTimeline.vue';
|
||||
|
||||
// Active weather: forecast and event cards, then the observed products with
|
||||
// the time of the frame they show. The world timeline moves time; the owner
|
||||
// computes every value shown.
|
||||
// their shared history timeline. The owner computes every value shown.
|
||||
defineProps({
|
||||
view: { type: Object, required: true },
|
||||
onParams: { type: Function, default: () => {} },
|
||||
onOpen: { type: Function, default: () => {} },
|
||||
transport: { type: Object, required: true },
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -30,9 +31,16 @@ defineProps({
|
||||
:aria-label="t('Observed history')"
|
||||
><h3 class="panel-title">{{ t('Observed history') }}</h3
|
||||
><div class="weather-observed-scope">{{ view.scope }}</div
|
||||
><div class="weather-frame-time" :hidden="!view.frameTime">{{
|
||||
view.frameTime
|
||||
}}</div
|
||||
><div class="weather-timeline-block" :hidden="!view.observed"
|
||||
><RailTimeline
|
||||
:state="view.timeline"
|
||||
slider-class-name="weather-timeline"
|
||||
:heading="false"
|
||||
:on-commit="transport.onCommit"
|
||||
:on-preview="transport.onPreview"
|
||||
:on-step="transport.onStep"
|
||||
:on-latest="transport.onLatest"
|
||||
:on-play="transport.onPlay" /></div
|
||||
><div class="weather-cards"
|
||||
><RailCards
|
||||
:cards="view.observedCards"
|
||||
|
||||
+38
-10
@@ -98,6 +98,13 @@ export function createWeatherPanel({
|
||||
openPanels.set(page, id);
|
||||
render();
|
||||
},
|
||||
transport: {
|
||||
onCommit: (tick) => clock?.setTarget(tick),
|
||||
onPreview: (time) => historyTime(time, clock?.getState()),
|
||||
onStep: (direction) => clock?.step(direction),
|
||||
onLatest: () => clock?.latest(),
|
||||
onPlay: () => clock?.togglePlay(),
|
||||
},
|
||||
};
|
||||
// The readout patches synchronously, so a newly opened card can be measured.
|
||||
const paint = (view) =>
|
||||
@@ -106,7 +113,14 @@ export function createWeatherPanel({
|
||||
hidden: true,
|
||||
observed: false,
|
||||
scope: '',
|
||||
frameTime: '',
|
||||
timeline: {
|
||||
ticks: [],
|
||||
index: 0,
|
||||
mode: 'latest',
|
||||
playing: false,
|
||||
readout: '',
|
||||
disabled: true,
|
||||
},
|
||||
cards: [],
|
||||
observedCards: [],
|
||||
});
|
||||
@@ -121,18 +135,32 @@ export function createWeatherPanel({
|
||||
.filter(({ summary }) => summary)
|
||||
.sort((a, b) => ORDER.indexOf(a.id) - ORDER.indexOf(b.id));
|
||||
const observed = active.filter(({ id }) => OBSERVED.has(id));
|
||||
const showObserved = observed.length > 0;
|
||||
const showTimeline = observed.length > 0;
|
||||
const names = {
|
||||
'weather-radar': t('Rain radar'),
|
||||
'weather-satellite': t('Satellite clouds'),
|
||||
'weather-lightning': t('Lightning density'),
|
||||
};
|
||||
// While live, the newest frame and its age; at a past time, the timeline
|
||||
// time alone. The world timeline moves the time.
|
||||
const shownTime =
|
||||
state.mode === 'latest' ? state.timeline.at(-1) : state.target;
|
||||
const frameTime =
|
||||
showObserved && shownTime ? historyTime(shownTime, state) : '';
|
||||
const index =
|
||||
state.mode === 'latest'
|
||||
? state.timeline.length - 1
|
||||
: Math.max(
|
||||
0,
|
||||
state.timeline.findLastIndex(
|
||||
(tick) => Date.parse(tick) <= Date.parse(state.target),
|
||||
),
|
||||
);
|
||||
const timeline = {
|
||||
ticks: state.timeline,
|
||||
index,
|
||||
mode: state.mode,
|
||||
playing: Boolean(state.playing),
|
||||
disabled: !showTimeline || state.timeline.length < 2,
|
||||
readout:
|
||||
state.mode === 'latest'
|
||||
? t('LATEST · newest per product')
|
||||
: historyTime(state.target, state),
|
||||
};
|
||||
const models = active.map((entry) => {
|
||||
const { id, icon, summary, legend = [], list } = entry;
|
||||
// Discrete classes (storm geometry, AQHI bands) list swatches, not a ramp.
|
||||
@@ -217,9 +245,9 @@ export function createWeatherPanel({
|
||||
const hidden = active.length === 0;
|
||||
paint({
|
||||
hidden,
|
||||
observed: showObserved,
|
||||
observed: showTimeline,
|
||||
scope: observed.map(({ id }) => names[id]).join(' · '),
|
||||
frameTime,
|
||||
timeline,
|
||||
cards: models.filter(({ id }) => !OBSERVED.has(id)),
|
||||
observedCards: models.filter(({ id }) => OBSERVED.has(id)),
|
||||
});
|
||||
|
||||
@@ -55,6 +55,10 @@ function fixture() {
|
||||
listeners.add(fn);
|
||||
return () => listeners.delete(fn);
|
||||
},
|
||||
setTarget: (tick) => calls.push(['target', tick]),
|
||||
latest: () => calls.push(['latest']),
|
||||
togglePlay: () => calls.push(['play']),
|
||||
step: (n) => calls.push(['step', n]),
|
||||
};
|
||||
return {
|
||||
...f,
|
||||
@@ -71,36 +75,39 @@ function fixture() {
|
||||
},
|
||||
};
|
||||
}
|
||||
const frameTime = (f) => f.find((n) => n.className === 'weather-frame-time');
|
||||
const timelineHost = (f) =>
|
||||
f.find((n) => n.className === 'weather-timeline-block');
|
||||
const card = (f, id) => f.find((n) => n.dataset.cardId === id);
|
||||
const line = (f, id, name) =>
|
||||
f.find((n) => n.dataset.lineId === name, card(f, id));
|
||||
test('the frame time shows with any observed product; the panel has no time controls of its own', (t) => {
|
||||
t.mock.timers.enable({
|
||||
apis: ['Date'],
|
||||
now: Date.parse('2026-09-22T01:17:00Z'),
|
||||
});
|
||||
test('timeline stays visible with any observed product; native preview and transport use the clock', (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
const f = fixture();
|
||||
const view = createWeatherPanel(f);
|
||||
view.update([wind]);
|
||||
assert.equal(frameTime(f).hidden, true);
|
||||
assert.equal(timelineHost(f).hidden, true);
|
||||
view.update([wind, radar]);
|
||||
assert.equal(frameTime(f).hidden, false);
|
||||
assert.equal(frameTime(f).textContent, '01:05 UTC · 12 min ago');
|
||||
assert.equal(timelineHost(f).hidden, false);
|
||||
f.state({ timeline: [ticks[0]] });
|
||||
assert.equal(frameTime(f).textContent, '01:00 UTC · 17 min ago');
|
||||
assert.equal(timelineHost(f).hidden, false);
|
||||
assert.equal(f.find((n) => n.tagName === 'INPUT').disabled, true);
|
||||
f.state({ timeline: [] });
|
||||
assert.equal(frameTime(f).hidden, true);
|
||||
f.state({ timeline: ticks, mode: 'history', target: ticks[0] });
|
||||
assert.equal(frameTime(f).textContent, '01:00 UTC');
|
||||
assert.equal(
|
||||
f.find((n) => n.tagName === 'INPUT'),
|
||||
null,
|
||||
);
|
||||
assert.equal(
|
||||
f.find((n) => ['Play', 'Latest'].includes(n.textContent)),
|
||||
null,
|
||||
);
|
||||
assert.equal(timelineHost(f).hidden, false);
|
||||
f.state({ timeline: ticks });
|
||||
assert.equal(timelineHost(f).hidden, false);
|
||||
const slider = f.find((n) => n.tagName === 'INPUT');
|
||||
slider.value = '0';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
assert.deepEqual(f.calls, []);
|
||||
slider.dispatchEvent(new Event('change'));
|
||||
assert.deepEqual(f.calls, [['target', ticks[0]]]);
|
||||
f.find((n) => n.textContent === 'Latest' && n.tagName === 'BUTTON').click();
|
||||
f.find((n) => n.textContent === 'Play').click();
|
||||
assert.deepEqual(f.calls.slice(1), [['latest'], ['play']]);
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
view.update([wind]);
|
||||
t.mock.timers.tick(150);
|
||||
assert.equal(f.calls.length, 3, 'hiding cancels pending drag');
|
||||
view.destroy();
|
||||
assert.equal(f.listeners.size, 0);
|
||||
});
|
||||
@@ -173,7 +180,7 @@ test('cyclone readout retains advisory, position, intensity, geometry, coverage,
|
||||
],
|
||||
};
|
||||
view.update([cyclone]);
|
||||
assert.equal(frameTime(f).hidden, true);
|
||||
assert.equal(timelineHost(f).hidden, true);
|
||||
assert.match(
|
||||
line(f, cyclone.id, 'time').textContent,
|
||||
/JULIO.*Hurricane.*Advisory 10.*UTC/,
|
||||
@@ -404,7 +411,7 @@ test('cyclones lead, and observed history owns one bordered group with only acti
|
||||
group.children[1].textContent,
|
||||
'Rain radar · Satellite clouds · Lightning density',
|
||||
);
|
||||
assertSameNode(group.children[2], frameTime(f));
|
||||
assertSameNode(group.children[2], timelineHost(f));
|
||||
assert.deepEqual(
|
||||
[...group.children[3].children].map((n) => n.dataset.cardId),
|
||||
['weather-radar', 'weather-satellite', 'weather-lightning'],
|
||||
@@ -667,8 +674,13 @@ test('history time keeps the hour whatever the length of the localized date', ()
|
||||
const f = fixture();
|
||||
const view = createWeatherPanel(f);
|
||||
view.update([wind, radar]);
|
||||
const ends = f.find((n) => n.className === 'rail-timeline-endpoints');
|
||||
assert.deepEqual(
|
||||
[...ends.children].map((n) => n.textContent),
|
||||
['01:00 UTC', '01:05 UTC'],
|
||||
locale,
|
||||
);
|
||||
f.state({ mode: 'history', target: ticks[1] });
|
||||
assert.equal(frameTime(f).textContent, '01:05 UTC', locale);
|
||||
assert.match(
|
||||
line(f, radar.id, 'time').textContent,
|
||||
/(^|[^\d:])01:05 UTC/,
|
||||
@@ -796,7 +808,7 @@ test('at a past time, frame ages and the timeline readout count from the timelin
|
||||
);
|
||||
const readout = f.find((n) => n.textContent === '01:20 UTC');
|
||||
assert.ok(readout, 'the readout names the timeline time');
|
||||
assert.doesNotMatch(frameTime(f).textContent, /min ago/);
|
||||
assert.doesNotMatch(timelineHost(f).textContent, /min ago/);
|
||||
view.destroy();
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user