Compare commits

...
Author SHA1 Message Date
Sameh Khamis 43c1b112aa Satellite class pills show their colour and count (#1918)
* Satellite class pills carry their colour and count

Each satellite class chip in the Satellites row now shows the colour its
satellites draw in, its name and how many are loaded, in one pill. The
separate list of coloured counts under the chips is gone. A class that is
off shows only its name, as a plain chip.

The class chips gain two optional fields, `swatch` and `count`, which
RailChips draws; the layer panel shortens the count as it does a row's
(10.7K). A class that is on with nothing loaded yet shows its colour
without a count.

* Satellite class pills use readable body-size text

The class pills' text was the chips' 8px dim mono. It is now the row's
body text: the layer name's 13px size and full-contrast colour, on or off.
The accent border and fill still mark a class that is on, and the swatch
grows to match. Measured in the panel, the pill text is 12.7:1 to 15.3:1
against its background, from about 2.9:1 before.

Each class chip is marked `keyed`, so it keeps that text while off, when it
carries no swatch or count.

* Changelog entry for the satellite class pills

* Revert "Satellite class pills use readable body-size text"

This reverts commit b4ffc49ef8.

* Satellite class pills keep the chips' own type

The class pills keep the chip's font, size, weight, letter-spacing and
colour; the count takes them too instead of a dimmer style of its own, so
several pills fit on a line as before. The changelog entry drops the text
size change.
2026-11-23 19:54:37 -08:00
Sameh Khamis fca2c81d86 Icons keep their glyph under a page-wide .ui-icon rule (#1917)
* Icons keep their glyph under a page-wide .ui-icon rule

* Changelog fragment for #1917
2026-11-23 16:02:16 -08:00
12 changed files with 224 additions and 68 deletions

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
- Icons keep their glyph when a stylesheet brings jQuery UI's `.ui-icon`
rule into the page, as some browser extensions do on every site: it pushed
each icon out of its box, leaving empty buttons (Sameh Khamis, @samehkhamis, #1917).
@@ -0,0 +1,4 @@
- Merge the Satellites row's class chips and its list of counts into one pill
per class. A class that is on shows its point colour, its name and how many
are loaded; a class that is off shows only its name (Sameh Khamis,
@samehkhamis, #1918).
+5 -5
View File
@@ -7817,13 +7817,13 @@ silently demoting every later lookup for the session.
- **World-space headings at every angle** (`src/data/screenRotation.js`; the scene-reading helpers in `src/render/cesium/iconOrientation.js`): aircraft/vessel icon rotation uses the camera right/up basis per tick (alignedAxis always ZERO), which is exact at screen center and for orthographic/nadir views and remains stable through >180° tracked orbits. Perspective rays vary across the viewport, so off-center contacts at oblique pitch can diverge from an exact finite-difference window projection; a regression test pins that known regime, and field evidence decides whether to adopt exact projection with the basis method as fallback. Fleet rotations refresh on camera-pose change; tracked entities per frame. Billboards are horizon-culled via a shared EllipsoidalOccluder.
- **Military/OpenSky reconciliation** (`src/data/militaryRegistry.js`): known-military ICAOs render amber in the flights layer (60s self-poll of the cached mil endpoint when the military layer is off) and are suppressed there while the military layer renders them.
- **Satellites**: core catalog from CelesTrak's stations, visual, GPS, GLONASS, Galileo, GEO, resource, weather, planet, SAR and science groups, tracking lands ~726km out via `viewFrom` (tracked entity owns a point graphic so the tracking camera engages), rings realign via primitive modelMatrix (no per-second rebuild flicker), optional `setParams({catalog:'dense'})` Starlink mode.
- **Satellite classes** (`src/layers/satellites/classes.js`): every satellite is filed under one of six classes, each with its own point colour, legend swatch and toggle: STATIONS (warm white), IMAGING (cyan), TELECOM (violet; communications and navigation, so GPS, GLONASS, Galileo and BeiDou read as one family), STARLINK (dim slate), PROBES (muted blue-gray) and DEBRIS (receding brown-gray). That module is the single source of truth for class, label and colour, so the dot, the card and the legend swatch cannot disagree. Two deliberate palette rules: no class may sit in the 40–48° amber band, which is the app-wide known-military convention; and STARLINK stays far below PROBES in Rec.601 luminance so the dense shell stays separable when NVG/FLIR collapse the scene to one channel. The ISS keeps its long-standing red hero dot rather than the STATIONS colour — it carries a permanent name label and its card still reads `STATIONS · ISS`; it is a station whichever group ingested it, so a stations-feed outage cannot refile it. `src/data/satelliteClass.js` keeps the group-based labels beneath the classes: the constellation subtype and a group's own label for a satellite with no class. The tracked satellite's dot keeps that colour too: tracking draws it larger (14 px), white-outlined and over everything, never in another colour (`_addTrackedEntity`, `src/layers/satellites/rendering.js`).
- **Satellite classes** (`src/layers/satellites/classes.js`): every satellite is filed under one of six classes, each with its own point colour and toggle chip (the chip shows the colour while the class is on): STATIONS (warm white), IMAGING (cyan), TELECOM (violet; communications and navigation, so GPS, GLONASS, Galileo and BeiDou read as one family), STARLINK (dim slate), PROBES (muted blue-gray) and DEBRIS (receding brown-gray). That module is the single source of truth for class, label and colour, so the dot, the card and the chip's swatch cannot disagree. Two deliberate palette rules: no class may sit in the 40–48° amber band, which is the app-wide known-military convention; and STARLINK stays far below PROBES in Rec.601 luminance so the dense shell stays separable when NVG/FLIR collapse the scene to one channel. The ISS keeps its long-standing red hero dot rather than the STATIONS colour — it carries a permanent name label and its card still reads `STATIONS · ISS`; it is a station whichever group ingested it, so a stations-feed outage cannot refile it. `src/data/satelliteClass.js` keeps the group-based labels beneath the classes: the constellation subtype and a group's own label for a satellite with no class. The tracked satellite's dot keeps that colour too: tracking draws it larger (14 px), white-outlined and over everything, never in another colour (`_addTrackedEntity`, `src/layers/satellites/rendering.js`).
- Class is also a **text field**, not just a color: `TELECOM · GPS` / `STARLINK` / `STATIONS · ISS` leads the tracked card's detail block and replaces the raw CelesTrak tag on the detection-overlay label. Because that canvas composites above the post-FX chain, the class stays readable in NVG/FLIR after the in-scene dot colors are flattened.
- The satellites row in DATA LAYERS carries per-layer sub-controls (`DataLayerManager._syncRowControls`, the first consumer of the optional `getRowControls()` layer hook): one chip per class (the STARLINK chip exposes the existing `catalog` param), a swatch legend with live per-class counts, and an info line while SATCAT is stale or unavailable (`Classes may lag: SATCAT is a cached copy` / `Classes may lag: SATCAT unavailable`). Default is the sparse core catalog. The chips are stateless — each declares the params to apply and the manager owns the write — so the Space Missions capture/restore path over the same param stays authoritative. Controls stay hidden while the layer is off. An explicit CORE or DENSE choice participates in versioned local and share-link state; temporary Space Missions overrides do not.
- **Class toggles** (`src/layers/satellites/classes.js`): the layer row carries one chip per class — STATIONS, IMAGING, TELECOM (communications and navigation), PROBES (science, technology development and demonstration, unknown purpose) and DEBRIS (rocket bodies, fragments, unknown objects launched before last year and dead payloads) on by default, so the layer shows what it did before classes; STARLINK off, as DENSE was. Points of a hidden class stay built and are only hidden, so a toggle needs no reload; hidden classes are left out of the detection overlay, the voice/framing position lists and analyst answers (the tracked satellite still answers), and the legend keys only the classes on screen. The class comes, strongest evidence first, from CelesTrak SATCAT (object type and operational status, fetched per group through `/api/celestrak-satcat/<group>`, cached a day by the proxy; the layer keeps a current read six hours rather than asking on every five-minute update), the bundled UCS Satellite Database pack (UCS-Satellite-Database 5-1-2023: operator, owner country and purpose; `src/data/local_data/ucs_satellites/`), name patterns for satellites launched after May 2023, and finally the CelesTrak groups the TLE came in (a mission group such as `weather` before the orbit group `geo`; a UCS purpose of "Unknown" counts as none). Only crewed stations and the craft that visit them, by name, are STATIONS: the CubeSats CelesTrak's stations group also carries after their deployment from the ISS are classed like any other satellite. A payload whose SATCAT record gives no status, with no UCS record and no recognisable name, that launched 20 or more years ago (SATCAT's launch date, else the TLE designator's year) is presumed dead and filed as debris; without a SATCAT record (a failed read) nothing is presumed. To cover imaging launched after the UCS snapshot the core catalog also reads CelesTrak's `resource`, `weather`, `planet`, `sar` and `science` groups. Debris can be tracked but is never ridden: the orbital entry gate (`orbitEntryAllowed`) refuses it, so no ORBIT entry is offered and double-click does nothing for it. Retired stations and the shuttles have re-entered and have no orbit to show. An explicit class choice is kept in local and share-link state as the `classes` option, one letter per class shown (`sitpd`: stations, imaging, telecom, probes, debris; `0`: none; `src/data/satelliteClassMask.js`), and the layer takes those letters back through `setParams({classes})`; STARLINK maps to the existing `catalog: 'dense'` param instead.
- The satellites row in DATA LAYERS carries per-layer sub-controls (`DataLayerManager._syncRowControls`, the first consumer of the optional `getRowControls()` layer hook): one chip per class (the STARLINK chip exposes the existing `catalog` param); a class that is on shows its point colour, its name and its live count in its chip (`swatch` and `count`, drawn by `src/ui/rail/RailChips.vue`), and a class that is off shows only its name; and an info line while SATCAT is stale or unavailable (`Classes may lag: SATCAT is a cached copy` / `Classes may lag: SATCAT unavailable`). Default is the sparse core catalog. The chips are stateless — each declares the params to apply and the manager owns the write — so the Space Missions capture/restore path over the same param stays authoritative. Controls stay hidden while the layer is off. An explicit CORE or DENSE choice participates in versioned local and share-link state; temporary Space Missions overrides do not.
- **Class toggles** (`src/layers/satellites/classes.js`): the layer row carries one chip per class — STATIONS, IMAGING, TELECOM (communications and navigation), PROBES (science, technology development and demonstration, unknown purpose) and DEBRIS (rocket bodies, fragments, unknown objects launched before last year and dead payloads) on by default, so the layer shows what it did before classes; STARLINK off, as DENSE was. Points of a hidden class stay built and are only hidden, so a toggle needs no reload; hidden classes are left out of the detection overlay, the voice/framing position lists and analyst answers (the tracked satellite still answers), and only the chips of classes on screen carry a colour and a count; an on class with nothing loaded shows its colour without a count. The class comes, strongest evidence first, from CelesTrak SATCAT (object type and operational status, fetched per group through `/api/celestrak-satcat/<group>`, cached a day by the proxy; the layer keeps a current read six hours rather than asking on every five-minute update), the bundled UCS Satellite Database pack (UCS-Satellite-Database 5-1-2023: operator, owner country and purpose; `src/data/local_data/ucs_satellites/`), name patterns for satellites launched after May 2023, and finally the CelesTrak groups the TLE came in (a mission group such as `weather` before the orbit group `geo`; a UCS purpose of "Unknown" counts as none). Only crewed stations and the craft that visit them, by name, are STATIONS: the CubeSats CelesTrak's stations group also carries after their deployment from the ISS are classed like any other satellite. A payload whose SATCAT record gives no status, with no UCS record and no recognisable name, that launched 20 or more years ago (SATCAT's launch date, else the TLE designator's year) is presumed dead and filed as debris; without a SATCAT record (a failed read) nothing is presumed. To cover imaging launched after the UCS snapshot the core catalog also reads CelesTrak's `resource`, `weather`, `planet`, `sar` and `science` groups. Debris can be tracked but is never ridden: the orbital entry gate (`orbitEntryAllowed`) refuses it, so no ORBIT entry is offered and double-click does nothing for it. Retired stations and the shuttles have re-entered and have no orbit to show. An explicit class choice is kept in local and share-link state as the `classes` option, one letter per class shown (`sitpd`: stations, imaging, telecom, probes, debris; `0`: none; `src/data/satelliteClassMask.js`), and the layer takes those letters back through `setParams({classes})`; STARLINK maps to the existing `catalog: 'dense'` param instead.
- The satellite Cockpit subject (`getCockpitSubject()`) also carries `satelliteClass`, `cosparId` (from SATCAT, else TLE line 1), `tle` (`{line1, line2, epochMs}`), `owner` (`{countryCode, label}`: ISO 3166-1 alpha-2 for a single country, `null` code for organisations such as ESA, EUMETSAT or Intelsat and for joint owners) and `operator` (UCS; SpaceX for Starlink). UCS names the operator's country and wins over the SATCAT owner code; CelesTrak's CIS (former USSR) is filed under Russia.
- **The STARLINK chip (formerly DENSE) reports the dense LOAD, not the catalog param.** The param flips synchronously while the Starlink shell takes seconds to arrive over a chunked load, and CelesTrak 502s that feed regularly. So the chip reads `STARLINK ···` (busy, disabled) while loading, ACTIVE only once dense points are actually on screen, and `STARLINK ✕` with the reason on hover when the load fails — a failure also reverts `catalog` to `core`, drops any partial chunk, and leaves the chip clickable to retry. A load is judged by points added, not by HTTP status: a 200 carrying an empty body, a passed-through HTML error page, or only TLEs the core catalog already owns fails with the same revert semantics as a 502. Any explicit request for `core` clears a latched error even when the mode does not change, so a Space Missions restore of an already-core snapshot never leaves the user with a failure they did not cause. Because the load settles asynchronously, the layer pushes a re-render through the optional `setRowControlsListener()` hook; nothing else would repaint that row before the 5-minute catalog refresh, so the count and legend would otherwise sit stale.
- **A dependency owner takes the row with it.** Space Missions borrows this layer for TLE lookup with `showPoints:false`; while points are hidden the layer returns empty row controls, so the legend never describes an empty sky and the chip cannot accept a write that the owner's restore would silently revert.
- **The STARLINK chip (formerly DENSE) reports the dense LOAD, not the catalog param.** The param flips synchronously while the Starlink shell takes seconds to arrive over a chunked load, and CelesTrak 502s that feed regularly. So the chip reads `STARLINK ···` (busy, disabled) while loading, ACTIVE only once dense points are actually on screen, and `STARLINK ✕` with the reason on hover when the load fails — a failure also reverts `catalog` to `core`, drops any partial chunk, and leaves the chip clickable to retry. A load is judged by points added, not by HTTP status: a 200 carrying an empty body, a passed-through HTML error page, or only TLEs the core catalog already owns fails with the same revert semantics as a 502. Any explicit request for `core` clears a latched error even when the mode does not change, so a Space Missions restore of an already-core snapshot never leaves the user with a failure they did not cause. Because the load settles asynchronously, the layer pushes a re-render through the optional `setRowControlsListener()` hook; nothing else would repaint that row before the 5-minute catalog refresh, so the counts would otherwise sit stale.
- **A dependency owner takes the row with it.** Space Missions borrows this layer for TLE lookup with `showPoints:false`; while points are hidden the layer returns empty row controls, so no count describes an empty sky and the chip cannot accept a write that the owner's restore would silently revert.
- The detection-overlay record cache (`_detectionObjects`) is cleared with the catalog on every rebuild: it stamps id/class at creation only, and a rebuild can re-tag a satellite when a partial CelesTrak outage changes which group wins dedupe.
- **Catalog numbers above 99999** can be written in a TLE as Alpha-5: a letter A–Z, skipping I and O, for the first two digits, so `A0000` is 100000 and `Z9999` is 339999. CelesTrak's TLE feed carries no satellite above 99999 (that needs the OMM feed, #1191), so this is compatibility with Alpha-5 TLEs. `src/sources/tle.js` decodes the field through one shared helper: `noradIdFromSatnum()` for the satellites layer, which keys and deduplicates its catalog by that number, and `tleCatalogNumber()` for the satellite tools. Plain digits read as before (`noradIdFromSatnum()` accepts any length, as an OMM satrec carries the number unpadded); a malformed field — a sign, decimal point, hex, exponent, embedded space, stray or lowercase letter, or blank — is rejected rather than partly read, as `NaN` in the layer and `null` in the tools.
- **CCTV estimated bearings:** a camera whose pack marks `headingConfidence: 'low'` (the id-hash
+34 -20
View File
@@ -14,6 +14,7 @@ import satellitesLayer, {
_setDenseCatalogStateForTest,
} from './satellites.js';
import { CATALOG_GROUPS } from '../layers/satellites/policy.js';
import { SATELLITE_CLASS_DISPLAY } from '../layers/satellites/classes.js';
/**
* A real, parseable TLE under an arbitrary 5-digit catalog number, so the dense
@@ -201,11 +202,12 @@ test('STARLINK reports loading, then ACTIVE only once the points exist', async (
assert.equal(settled.label, 'STARLINK');
assert.deepEqual(settled.params, { catalog: 'core' }, 'a settled chip toggles back off');
// The completion pushed a refresh, and the legend gained STARLINK with it —
// without that push the row would keep the pre-load counts for 5 minutes.
// The completion pushed a refresh, and the STARLINK chip gained its swatch
// and count with it — without that push the row would keep the pre-load
// counts for 5 minutes.
assert.ok(refreshes.length >= 2, 'load start and load completion each pushed a refresh');
const legend = satellitesLayer.getRowControls().legend;
assert.equal(legend.some((row) => row.klass === 'starlink'), true);
assert.equal(settled.swatch, SATELLITE_CLASS_DISPLAY.starlink.color);
assert.equal(settled.count, 1);
} finally {
globalThis.fetch = originalFetch;
_clearDenseCatalogStateForTest();
@@ -231,11 +233,8 @@ test('a failed STARLINK load reverts the mode rather than leaving an active chip
assert.match(settled.title, /502/, 'the chip explains why');
assert.equal(satellitesLayer.getParams().catalog, 'core', 'the mode reverts to reality');
assert.deepEqual(settled.params, { catalog: 'dense' }, 'clicking retries');
assert.equal(
satellitesLayer.getRowControls().legend.some((row) => row.klass === 'starlink'),
false,
'no STARLINK class is advertised when nothing loaded',
);
assert.equal(settled.swatch, undefined, 'no STARLINK swatch when nothing loaded');
assert.equal(settled.count, undefined, 'and no STARLINK count');
assert.ok(pushes >= 2, 'the failure pushed its own refresh');
// Retrying against a healthy feed clears the error — it does not latch.
@@ -318,10 +317,10 @@ test('an explicit return to core clears a failure the user never caused', async
}
});
test('a real stations-feed outage keeps the ISS under STATIONS in the legend', async () => {
test('a real stations-feed outage keeps the ISS counted under STATIONS', async () => {
// End-to-end version of the tally rule: drive a real rebuild in which only
// the `visual` group answers, so the ISS is genuinely ingested as `visual`.
// The legend must still file it under STATION or it disagrees with the card.
// The STATIONS chip must still count it or it disagrees with the card.
const originalFetch = globalThis.fetch;
const log = console.log;
const warn = console.warn;
@@ -339,13 +338,14 @@ test('a real stations-feed outage keeps the ISS under STATIONS in the legend', a
assert.equal(_catalogGroupForTest(25544), 'visual',
'the outage really did ingest the ISS from the visual group');
const legend = satellitesLayer.getRowControls().legend;
assert.equal(legend.find((row) => row.klass === 'stations')?.count, 1,
'STATIONS survives the outage because the ISS is counted there');
assert.equal(legend.length, 1, 'and it is not also counted under another class');
const counted = satellitesLayer
.getRowControls()
.chips.filter((entry) => entry.count !== undefined);
assert.deepEqual(counted.map((entry) => [entry.id, entry.count]), [['class-stations', 1]],
'STATIONS survives the outage because the ISS is counted there, and only there');
const [iss] = satellitesLayer.getAnalystRecords();
assert.equal(iss?.satelliteClass, 'STATIONS · ISS',
'the card says the same thing the legend does');
'the card says the same thing the chip does');
} finally {
console.log = log;
console.warn = warn;
@@ -405,7 +405,7 @@ test('a dependency owner hiding the points surrenders the whole row', async () =
satellitesLayer.setParams({ showPoints: false });
const owned = satellitesLayer.getRowControls();
assert.deepEqual(owned.chips, [], 'no chip to click while the owner holds the params');
assert.deepEqual(owned.legend, [], 'no legend describing an empty sky');
assert.equal(owned.legend, undefined, 'no counts describing an empty sky');
satellitesLayer.setParams({ showPoints: true });
assert.equal(satellitesLayer.getRowControls().chips.length, 6, 'released on restore');
@@ -448,16 +448,30 @@ test('every class but Starlink shows by default; each class chip turns its class
false,
);
assert.deepEqual(chip('telecom').params, { classes: { telecom: false } });
// One pill per class carries what the legend did: an on class shows its
// point colour and its count beside its name, an off one only its name.
const controls = satellitesLayer.getRowControls();
assert.equal(controls.legend, undefined, 'no separate list of counts');
assert.deepEqual(
satellitesLayer.getRowControls().legend.map((row) => row.klass),
['stations', 'imaging', 'telecom', 'debris'],
'the legend keys only what is on screen',
controls.chips.map((entry) => [entry.id, entry.swatch, entry.count]),
[
['class-stations', SATELLITE_CLASS_DISPLAY.stations.color, 1],
['class-imaging', SATELLITE_CLASS_DISPLAY.imaging.color, 1],
['class-telecom', SATELLITE_CLASS_DISPLAY.telecom.color, 1],
['catalog', undefined, undefined],
// On, but nothing of the class is loaded: the colour shows, no count.
['class-probes', SATELLITE_CLASS_DISPLAY.probes.color, undefined],
['class-debris', SATELLITE_CLASS_DISPLAY.debris.color, 1],
],
);
satellitesLayer.setParams(chip('telecom').params);
satellitesLayer.setParams(chip('debris').params);
assert.deepEqual(shown(), [25544, 90002], 'telecom and debris off');
assert.equal(chip('debris').active, false);
assert.equal(chip('debris').swatch, undefined, 'an off pill drops its colour');
assert.equal(chip('debris').count, undefined, 'and its count');
assert.equal(chip('debris').label, 'DEBRIS', 'and keeps its name');
assert.deepEqual(satellitesLayer.getParams().classes, {
stations: true,
imaging: true,
+30 -36
View File
@@ -105,7 +105,7 @@ export function createControls({ state: layerState, services, parts, source }) {
};
}
/** Tell the manager to re-render this layer's row (chip state / legend counts). */
/** Tell the manager to re-render this layer's row (chip state and counts). */
function _notifyRowControls() {
try {
@@ -116,7 +116,7 @@ export function createControls({ state: layerState, services, parts, source }) {
}
/**
* Per-class tally for the row legend, cached against the catalog revision.
* Per-class tally for the row's class chips, cached against the catalog revision.
* Without the cache this scans ~10.7k entries in dense mode on every panel
* refresh, and any layer polling on the 1s stats timer refreshes the panel.
* @returns {Record<string, number>} Class key → count.
@@ -712,8 +712,10 @@ export function createControls({ state: layerState, services, parts, source }) {
/**
* Layer-row sub-controls (DataLayerManager row-controls contract): one
* toggle chip per satellite class (src/layers/satellites/classes.js), and a legend
* of the classes on screen so the point colours are learnable.
* toggle chip per satellite class (src/layers/satellites/classes.js). A
* class that is on carries its point colour (`swatch`) and, once any of
* it is loaded, its count, so the point colours are learnable; a class
* that is off carries only its name.
*
* Chips are stateless — each declares the params to apply and the manager
* owns the write, so the Space Missions snapshot/restore path (which drives
@@ -723,49 +725,41 @@ export function createControls({ state: layerState, services, parts, source }) {
* STARLINK is the dense catalog (chip id `catalog`) and reports the dense
* LOAD state, not the param: the param flips synchronously while the shell
* takes seconds to arrive and frequently 502s, so ACTIVE means "Starlink
* points are on screen" and nothing less. The legend tally is cached
* points are on screen" and nothing less. The class tally is cached
* against the catalog revision. While SATCAT is stale or unavailable the
* info line says the classes may lag (see `classEvidenceNotice`).
* @returns {{ chips: Array<object>, legend: Array<object>, info: string,
* infoTitle: string }} Row controls.
* @returns {{ chips: Array<object>, info: string, infoTitle: string }}
* Row controls.
*/
getRowControls() {
// A dependency owner (Space Missions) borrows this layer for TLE lookup
// with showPoints:false. Nothing is rendered, so a legend would describe an
// with showPoints:false. Nothing is rendered, so a count would describe an
// empty sky and a chip write would be silently reverted by that owner's
// restore. Surrender the row rather than lie about it.
if (!layerState._params.showPoints) return { chips: [], legend: [] };
if (!layerState._params.showPoints) return { chips: [] };
const classes = _classes();
const chips = SATELLITE_CLASS_IDS.map((id) =>
id === 'starlink'
? _starlinkChip()
: {
id: `class-${id}`,
label: t(SATELLITE_CLASS_DISPLAY[id].label),
active: classes[id] === true,
state: classes[id] === true ? 'active' : 'idle',
title: t(SATELLITE_CLASS_DISPLAY[id].blurb),
params: { classes: { [id]: classes[id] !== true } },
},
);
const counts = _classTally();
const legend = [];
for (const id of SATELLITE_CLASS_IDS) {
const shown =
const chips = SATELLITE_CLASS_IDS.map((id) => {
const chip =
id === 'starlink'
? layerState._params.catalog === 'dense'
: classes[id] === true;
if (!shown || !(counts[id] > 0)) continue;
legend.push({
klass: id,
label: t(SATELLITE_CLASS_DISPLAY[id].label),
color: SATELLITE_CLASS_DISPLAY[id].color,
blurb: t(SATELLITE_CLASS_DISPLAY[id].blurb),
count: counts[id],
});
}
return { chips, legend, ...classEvidenceNotice() };
? _starlinkChip()
: {
id: `class-${id}`,
label: t(SATELLITE_CLASS_DISPLAY[id].label),
active: classes[id] === true,
state: classes[id] === true ? 'active' : 'idle',
title: t(SATELLITE_CLASS_DISPLAY[id].blurb),
params: { classes: { [id]: classes[id] !== true } },
};
// The colour key and count ride on a class that is on; an off
// class is its name alone.
if (!chip.active) return chip;
chip.swatch = SATELLITE_CLASS_DISPLAY[id].color;
if (counts[id] > 0) chip.count = counts[id];
return chip;
});
return { chips, ...classEvidenceNotice() };
},
/**
+6 -1
View File
@@ -525,7 +525,12 @@ export class LayerPanel {
row.controls = false;
return null;
}
const chips = controls?.chips || [];
// A chip's count is shortened as the row's is.
const chips = (controls?.chips || []).map((chip) =>
Number.isFinite(chip.count)
? { ...chip, countText: formatCount(chip.count) }
: chip,
);
const legend = (controls?.legend || []).map((item) => ({
color: item.color,
blurb: item.blurb,
+22
View File
@@ -509,3 +509,25 @@ test('a layer with no feed in view says why instead of "never"', async () => {
setLocale('en');
}
});
test('a chip count is shortened like the row count', async () => {
const { LayerPanel } = await import('./layerPanel.js');
const panel = Object.create(LayerPanel.prototype);
panel._rowControlsFor = () => ({
chips: [
{ id: 'a', label: 'A', active: true, swatch: '#fff', count: 10700 },
{ id: 'b', label: 'B', active: true, swatch: '#fff', count: 42 },
{ id: 'c', label: 'C', active: false },
],
});
const { chips, hidden } = panel._presentControls(
{},
{ id: 'x', enabled: true },
);
assert.equal(hidden, false);
assert.deepEqual(
chips.map((chip) => chip.countText),
['10.7K', '42', undefined],
);
assert.equal(chips[0].swatch, '#fff', 'the rest of the chip passes through');
});
+58
View File
@@ -272,3 +272,61 @@ test('a core row carries no library entry attribute', () => {
assert.equal(element.hasAttribute('data-library-entry'), false);
render(null, container);
});
const classRow = (chips) => ({
...row(false),
key: 'satellites',
id: 'satellites',
controls: { hidden: false, chips, legend: [], list: null },
});
test('a keyed chip carries its swatch and count while on, only its name while off', () => {
document.body.replaceChildren();
const container = document.body.appendChild(document.createElement('div'));
const picks = [];
const on = {
id: 'class-imaging',
label: 'IMAGING',
active: true,
swatch: '#4fd8ff',
countText: '1.2K',
};
render(
h(LayerRows, {
items: [classRow([on])],
onChip: (id, chipId) => picks.push([id, chipId]),
}),
container,
);
const button = container.querySelector('[data-chip-id="class-imaging"]');
assert.equal(button.getAttribute('aria-pressed'), 'true');
const [swatch, name, count] = button.children;
assert.ok(swatch.classList.contains('data-toggle-chip-swatch'));
assert.equal(swatch.style.background, '#4fd8ff');
assert.equal(swatch.getAttribute('aria-hidden'), 'true');
assert.equal(name.textContent, 'IMAGING');
assert.ok(count.classList.contains('data-toggle-chip-count'));
assert.equal(count.textContent, '1.2K');
assert.ok(button.classList.contains('chip-keyed'));
assert.equal(button.textContent, 'IMAGING 1.2K', 'name and count read apart');
button.click();
assert.deepEqual(picks, [['satellites', 'class-imaging']]);
// Off: the same pill, its name alone.
render(
h(LayerRows, {
items: [
classRow([{ id: 'class-imaging', label: 'IMAGING', active: false }]),
],
}),
container,
);
const off = container.querySelector('[data-chip-id="class-imaging"]');
assert.equal(off.getAttribute('aria-pressed'), 'false');
assert.equal(off.textContent, 'IMAGING');
assert.equal(off.querySelector('.data-toggle-chip-swatch'), null);
assert.equal(off.querySelector('.data-toggle-chip-count'), null);
assert.equal(off.classList.contains('chip-keyed'), false);
assert.equal(container.querySelector('.data-toggle-legend-item'), null);
render(null, container);
});
+18 -5
View File
@@ -5,14 +5,16 @@ import UiIcon from '../kit/UiIcon.vue';
// Keyed chips shared by rail cards; the owner decides what a click does.
// An `icon` chip shows a Material Symbol (named in index.html's `icon_names`
// subset) with its label as the accessible name and tip; an `action` chip
// (Zoom, Remove) is a plain button, not an on/off toggle.
// (Zoom, Remove) is a plain button, not an on/off toggle. A `swatch` chip
// (a CSS colour) keys what it turns on: the colour before its label and, with
// `countText`, how many after it; the owner leaves both off a chip that is off.
defineProps({
chips: { type: Array, default: () => [] },
onSelect: { type: Function, default: () => {} },
});
const chipClass = (chip) =>
`data-toggle-chip chip-${chip.state || (chip.active ? 'active' : 'idle')}${chip.icon ? ' chip-icon' : ''}`;
`data-toggle-chip chip-${chip.state || (chip.active ? 'active' : 'idle')}${chip.icon ? ' chip-icon' : ''}${chip.swatch && !chip.icon ? ' chip-keyed' : ''}`;
</script>
<template>
@@ -31,8 +33,19 @@ const chipClass = (chip) =>
:aria-busy="String(Boolean(chip.busy))"
@click="onSelect(chip)"
><UiIcon v-if="chip.icon" :name="chip.icon" :size="null" /><template
v-else
>{{ chip.label }}</template
></UiButton
v-else-if="chip.swatch"
><span
class="data-toggle-chip-swatch"
aria-hidden="true"
:style="{ background: chip.swatch }"
></span
><span>{{ chip.label }}</span
><template v-if="chip.countText"
>{{ ' '
}}<span class="data-toggle-chip-count">{{
chip.countText
}}</span></template
></template
><template v-else>{{ chip.label }}</template></UiButton
>
</template>
+21
View File
@@ -0,0 +1,21 @@
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import test from 'node:test';
const kit = readFileSync(new URL('./kit.css', import.meta.url), 'utf8').replace(
/\/\*[\s\S]*?\*\//g,
'',
);
test("an icon's glyph stays in its box under a page-wide jQuery UI .ui-icon rule", () => {
const rule = kit.match(/\.ui-icon\.ui-icon\s*\{([^}]*)\}/);
assert.ok(rule, 'a doubled class outranks a single-class .ui-icon rule');
for (const declaration of [
/text-indent:\s*0/,
/overflow:\s*visible/,
/background-image:\s*none/,
/width:\s*auto/,
/height:\s*auto/,
])
assert.match(rule[1], declaration);
});
+12
View File
@@ -40,6 +40,18 @@
user-select: none;
}
/* The icon is a font ligature; `ui-icon` is also jQuery UI's sprite-icon class, and a stylesheet
that brings jQuery UI's rule into the page (some browser extensions inject it everywhere) pushes
the glyph out of its box (`text-indent: -99999px`, `overflow: hidden`, a 16 px box). The doubled
class outranks that rule and sets only what the kit never sets elsewhere. */
.ui-icon.ui-icon {
text-indent: 0;
overflow: visible;
background-image: none;
width: auto;
height: auto;
}
.ui-tooltip {
position: relative;
display: inline-flex;
+11 -1
View File
@@ -942,6 +942,15 @@ html:not([lang='en'])
background: var(--accent-dim);
}
/* A keyed chip (RailChips.vue `swatch`): the colour of what it turns on before
its label and the count after it, while it is on, in the chip's own type.
Off, it is a plain chip. */
.data-toggle-chip.chip-keyed {
display: inline-flex;
align-items: center;
gap: 4px;
}
/* Async sub-controls: a chip must never read ACTIVE before the data it turns
on actually exists, so loading and failure are their own visible states. */
.data-toggle-chip:disabled {
@@ -971,7 +980,8 @@ html:not([lang='en'])
cursor: default;
}
.data-toggle-legend-swatch {
.data-toggle-legend-swatch,
.data-toggle-chip-swatch {
width: 6px;
height: 6px;
border-radius: 50%;