Rebuild the Context panel around the selected item and the view

Clicking anything a layer can identify opens one card in Context: a hero
tile (route globe and 3D model for a flight, the camera for CCTV, headline
figures otherwise), its facts, actions with Cockpit or the orbital view as
the primary one, and a standard set of nearby blocks (weather and local
time, flights, vessels, hazards, alerts) within one radius the user sets.
Aircraft show altitude as a graph. Things that move are followed when
picked, and a card closes when its layer is turned off.

With nothing selected the panel describes the view: the layers that are on
with a breakdown of what each holds, the camera's height, what is in view,
then time, weather and local news. From far out it shows worldwide counts
per layer. A search field in the header narrows whatever the panel shows.

Prototype. Context reads weather and hazard feeds while its panel is closed,
the two 3D previews on a flight card repaint continuously, Follow can show
pressed after tracking has ended elsewhere, and most new strings are fixed
English. Same-named sites are told apart by position, not by a stable id.
This commit is contained in:
Manjunath Paparaju authored and Sameh Khamis committed 2026-11-16 14:58:53 -08:00
1 parent f7f18c2823
commit cc83763452
21 files changed
+6595 -1

No files matched your search

+116
View File
@@ -0,0 +1,116 @@
<script setup>
import { computed, ref, watch } from 'vue';
import { t } from '../../../i18n/index.js';
// A height as a filled graph (an aircraft's altitude, the camera's height):
// each reading since it opened, left to right. The scale fits the readings (never less than about
// 2,000 ft tall), so a climb or descent shows as a slope, and the fill
// fades from the line down to the baseline.
const props = defineProps({
/** The current altitude in metres, or null when unknown. */
altitudeM: { type: Number, default: null },
/** Bumped on each card refresh; a reading is taken on every bump. */
tick: { type: Number, default: 0 },
/** The caption; 'Altitude' when not given. */
label: { type: String, default: '' },
/** 'feet' for aircraft; 'metric' reads in metres and kilometres. */
unit: { type: String, default: 'feet' },
/** Only the caption, the current figure and the line: no scale or change. */
compact: { type: Boolean, default: false },
});
const MAX_READINGS = 450;
const MIN_RANGE_M = 600;
const WIDTH = 100;
const HEIGHT = 36;
const readings = ref([]);
watch(
() => props.tick,
() => {
if (!Number.isFinite(props.altitudeM)) return;
const next = [...readings.value, { at: Date.now(), m: Math.max(0, props.altitudeM) }];
readings.value = next.length > MAX_READINGS ? next.slice(-MAX_READINGS) : next;
},
{ immediate: true },
);
const feet = (m) => Math.round((m * 3.28084) / 100) * 100;
const number = (value) => value.toLocaleString('en-US');
const metric = (m) =>
m >= 100_000 ? `${number(Math.round(m / 1000))} km` : m >= 1000 ? `${(m / 1000).toFixed(1)} km` : `${number(Math.round(m))} m`;
const shown = (m) => (props.unit === 'metric' ? metric(m) : `${number(feet(m))} ft`);
const graph = computed(() => {
const list = readings.value;
if (!list.length) return null;
const last = list[list.length - 1];
const first = list[0];
const span = Math.max(1, last.at - first.at);
// The camera ranges from metres to the whole globe, so its heights are
// drawn on a log scale: each zoom step is a similar rise or fall.
const log = props.unit === 'metric';
const scaled = (m) => (log ? Math.log10(Math.max(1, m)) : m);
const heights = list.map((item) => scaled(item.m));
const high = Math.max(...heights);
const low = Math.min(...heights);
// The least the scale spans: about 2,000 ft for aircraft, half a decade
// for the camera.
const least = log ? 0.5 : MIN_RANGE_M;
const pad = Math.max((least - (high - low)) / 2, (high - low) * 0.15);
const bottom = Math.max(0, low - pad);
const top = Math.max(high + pad, bottom + least);
const x = (at) => WIDTH - ((last.at - at) / span) * WIDTH;
const y = (m) => HEIGHT - ((scaled(m) - bottom) / (top - bottom)) * (HEIGHT - 2) - 1;
// The readings span the full width; a single reading (a card that has
// just opened) draws as a level line instead of a dot.
const points = list.length > 1 ? list.map((item) => [x(item.at), y(item.m)]) : [[0, y(first.m)], [WIDTH, y(first.m)]];
const line = points.map(([px, py], index) => `${index ? 'L' : 'M'}${px.toFixed(2)} ${py.toFixed(2)}`).join(' ');
const moved = last.m - first.m;
const change = props.unit === 'metric' ? (Math.abs(moved) >= Math.max(1, last.m * 0.005) ? moved : 0) : feet(last.m) - feet(first.m);
const changeText = props.unit === 'metric' ? metric(Math.abs(moved)) : `${number(Math.abs(change))} ft`;
const minutes = Math.floor((last.at - first.at) / 60_000);
return {
line,
area: `${line} L${WIDTH} ${HEIGHT} L0 ${HEIGHT} Z`,
headY: y(last.m),
now: shown(last.m),
top: shown(log ? 10 ** top : top),
bottom: shown(log ? 10 ** bottom : bottom),
trend: change > 0 ? 'up' : change < 0 ? 'down' : 'level',
change: change ? `${change > 0 ? '+' : '−'}${changeText}` : t('Level'),
since: minutes >= 1 ? t('Last {n} min', { n: minutes }) : props.unit === 'metric' ? t('Just now') : t('Since selected'),
};
});
</script>
<template>
<figure v-if="graph" class="altitude-graph" :class="{ 'altitude-graph--compact': compact }" :data-trend="graph.trend">
<figcaption class="altitude-graph__head">
<span class="altitude-graph__label">{{ label || t('Altitude') }}</span>
<strong class="altitude-graph__now">{{ graph.now }}</strong>
</figcaption>
<div class="altitude-graph__plot">
<svg :viewBox="`0 0 ${WIDTH} ${HEIGHT}`" preserveAspectRatio="none" role="img" :aria-label="`${label || t('Altitude')} ${graph.now}, ${graph.change}`">
<defs>
<linearGradient id="altitude-graph-fill" gradientUnits="userSpaceOnUse" x1="0" :y1="0" x2="0" :y2="HEIGHT">
<stop offset="0" class="altitude-graph__stop altitude-graph__stop--high" />
<stop offset="0.5" class="altitude-graph__stop altitude-graph__stop--mid" />
<stop offset="1" class="altitude-graph__stop altitude-graph__stop--low" />
</linearGradient>
</defs>
<path class="altitude-graph__area" :d="graph.area" fill="url(#altitude-graph-fill)" />
<path class="altitude-graph__line" :d="graph.line" />
</svg>
<span class="altitude-graph__head-dot" :style="{ top: `${(graph.headY / HEIGHT) * 100}%` }" aria-hidden="true"></span>
<template v-if="!compact">
<span class="altitude-graph__scale" aria-hidden="true">{{ graph.top }}</span>
<span class="altitude-graph__scale altitude-graph__scale--low" aria-hidden="true">{{ graph.bottom }}</span>
</template>
</div>
<p v-if="!compact" class="altitude-graph__foot">
<span>{{ graph.since }}</span>
<span class="altitude-graph__change">{{ graph.change }}</span>
</p>
</figure>
</template>