mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
Display > HUD > Sonar now turns the sonar sweep on over Tactical or Minimal. It is off by default, ON reveals its five sliders, and it keeps its guards: an OFF control, the sweep only while the HUD is visible and outside Cockpit, no animation under reduced motion, and repaint timers re-armed only after a drawn frame that still shows contacts. The Cyber layout, its shell skin and its Cockpit lanes are removed. Share links, scenes, saved views and set_hud that name Cyber open Tactical with Sonar on; links and scene shots record Tactical with Sonar under the same code, and a restored state that names another layout turns Sonar off. set_cyber_sonar keeps its name and works under any layout. A newer Sonar toggle or voice setting wins over a share-link restore that lands later. From 1200px wide the command dock and World Timeline sit 74px above the bottom edge, as in the Omnibar layout, leaving the bottom row to the map attribution (left) and the Power Up corner row (right). The attribution moves to the bottom right when the page runs right to left, where the corner row sits at the bottom left, and a long credit line wraps upward before reaching the corner row. The Tactical bottom-right readout sits 8px above Power Up and the coordinates start level with it. The World Timeline is narrowed to sit between the corners. Toasts keep clear of the raised dock and the chat and voice panel height budgets subtract its rise. Below 1200px the layout is unchanged. The left rail treats the centered World Timeline and voice control as obstacles only where they reach a laid-out panel. On top of the Omnibar: sonar.css replaces cyber.css after the Omnibar imports, the Omnibar's HUD guide step now says Layout picks Tactical or Minimal, and the Omnibar's Tactical bottom-right readout keeps the same 8px above Power Up. Co-authored-by: Sameh Khamis <[email protected]>
228 lines
7.9 KiB
JavaScript
228 lines
7.9 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { readStylesheet } from '../testSupport/readStylesheet.mjs';
|
|
|
|
const css = readStylesheet(new URL('../../style.css', import.meta.url));
|
|
const clean = (selector) =>
|
|
selector
|
|
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
.replace(/\s+/g, ' ')
|
|
.trim();
|
|
const rules = [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)].map(
|
|
([, selector, body]) => ({
|
|
selector: clean(selector),
|
|
body: body.replace(/\/\*[\s\S]*?\*\//g, ''),
|
|
}),
|
|
);
|
|
const railRules = rules.filter(({ selector }) =>
|
|
selector.includes('#left-panel-stack, #right-context-rail'),
|
|
);
|
|
const hoverBlock =
|
|
css.match(
|
|
/@media \(hover: hover\) and \(pointer: fine\) \{((?:[^{}]*\{[^{}]*\})*)\s*\}/g,
|
|
) || [];
|
|
|
|
test('a side panel lights up on hover only where a pointer can hover', () => {
|
|
const lit = railRules.filter(({ selector }) => selector.includes(':hover'));
|
|
assert.ok(lit.length > 0, 'the rail hover rule is missing');
|
|
for (const { selector } of lit) {
|
|
assert.ok(
|
|
hoverBlock.some((block) => clean(block).includes(selector)),
|
|
`${selector} must sit inside @media (hover: hover) and (pointer: fine)`,
|
|
);
|
|
}
|
|
});
|
|
|
|
test('hover matches the dock tray hover, not its pinned look', () => {
|
|
const [hover] = railRules.filter(({ selector }) =>
|
|
selector.endsWith(':hover'),
|
|
);
|
|
assert.ok(hover, 'the rail surface hover rule is missing');
|
|
assert.match(hover.body, /border-color:\s*var\(--glass-border-hover\)/);
|
|
assert.doesNotMatch(hover.body, /box-shadow/);
|
|
assert.match(hover.body, /--rail-label-hover:\s*var\(--accent\)/);
|
|
// A low-specificity list: no ID or state selector inside it lifts the rule.
|
|
assert.match(hover.selector, /:where\(/);
|
|
});
|
|
|
|
test('hover recolours only the hovered panel header, never nested sections', () => {
|
|
for (const { selector } of railRules) {
|
|
assert.ok(
|
|
!/\.radio-panel-inner/.test(selector),
|
|
`Radio sits inside Context and must not light up as its own panel: ${selector}`,
|
|
);
|
|
assert.doesNotMatch(
|
|
selector,
|
|
/:hover\s+:is\(/,
|
|
'a descendant colour list would reach labels in the panel body',
|
|
);
|
|
}
|
|
const colour = railRules.find(
|
|
({ body }) => /--rail-label-hover/.test(body) && /color:/.test(body),
|
|
);
|
|
assert.ok(colour, 'the rail title colour rule is missing');
|
|
assert.match(colour.selector, /\.panel-header > \.panel-title/);
|
|
const radio = rules.find(({ selector }) => selector === '#radio-panel');
|
|
assert.match(radio?.body || '', /--rail-label-hover:\s*initial/);
|
|
});
|
|
|
|
test('no later rule dims the open Context title below its siblings', () => {
|
|
const dimmed = rules.filter(
|
|
({ selector, body }) =>
|
|
/#global-context-panel:not\(\.collapsed\) \.panel-title$/.test(
|
|
selector,
|
|
) && /color:/.test(body),
|
|
);
|
|
assert.deepEqual(dimmed, []);
|
|
});
|
|
|
|
test('collapsed launchers on both rails keep titles inside the card', () => {
|
|
const ellipsis = railRules.find(
|
|
({ selector, body }) =>
|
|
selector.endsWith(
|
|
':is(.panel-header > .panel-title, .pp-header-label)',
|
|
) && /text-overflow:\s*ellipsis/.test(body),
|
|
);
|
|
assert.ok(
|
|
ellipsis,
|
|
'rail titles must end in an ellipsis rather than overflow',
|
|
);
|
|
assert.match(ellipsis.body, /min-width:\s*0/);
|
|
|
|
const translated = rules.find(
|
|
({ selector }) =>
|
|
selector.startsWith("html:not([lang='en'])") &&
|
|
selector.includes('#left-panel-stack, #right-context-rail') &&
|
|
selector.includes('.panel-collapsible.collapsed'),
|
|
);
|
|
assert.ok(translated, 'translated collapsed titles must fit on both rails');
|
|
assert.match(translated.body, /font-size:\s*8px/);
|
|
// Chinese and Japanese titles fit at full size; 8px would put them under
|
|
// the 9px CJK floor in cjk.css.
|
|
assert.match(translated.selector, /:not\(:lang\(zh\)\):not\(:lang\(ja\)\)/);
|
|
// Only the rail's own launchers: Radio, nested in Context, keeps its type.
|
|
assert.match(
|
|
translated.selector,
|
|
/#right-context-rail\) > \.panel-collapsible\.collapsed > \[class\$='-panel-inner'\] > \.panel-header > \.panel-title$/,
|
|
);
|
|
});
|
|
|
|
test('a collapsed launcher drops its divider so English titles fit whole', () => {
|
|
const launcher = (tail) =>
|
|
railRules.filter(({ selector }) =>
|
|
selector
|
|
.split(/,(?![^(]*\))/)
|
|
.some((part) =>
|
|
part
|
|
.trim()
|
|
.endsWith(
|
|
`.collapsed > [class$='-panel-inner'] > .panel-header${tail}`,
|
|
),
|
|
),
|
|
);
|
|
const [header] = launcher('');
|
|
const [divider] = launcher(' > .panel-divider');
|
|
const [toggle] = launcher(' > .panel-collapse-btn');
|
|
assert.match(header?.body || '', /gap:\s*8px/, 'the launcher header gap');
|
|
assert.match(divider?.body || '', /display:\s*none/, 'the launcher divider');
|
|
assert.match(
|
|
toggle?.body || '',
|
|
/margin-left:\s*auto/,
|
|
'the launcher toggle',
|
|
);
|
|
const button = rules.find(
|
|
({ selector }) => selector === '.panel-collapse-btn',
|
|
);
|
|
assert.match(
|
|
button?.body || '',
|
|
/flex-shrink:\s*0/,
|
|
'a long title must not squeeze the toggle',
|
|
);
|
|
});
|
|
|
|
test('the default theme geometry change leaves the base gutters alone', () => {
|
|
for (const surface of [
|
|
'.data-panel-inner',
|
|
'.utilities-panel-inner',
|
|
'.global-context-panel-inner',
|
|
]) {
|
|
// A surface may share its rule with another (`.data-panel-inner,
|
|
// .utilities-panel-inner {`).
|
|
const base = rules.find(
|
|
({ selector, body }) =>
|
|
selector
|
|
.split(',')
|
|
.map((part) => part.trim())
|
|
.includes(surface) && /padding:/.test(body),
|
|
);
|
|
assert.match(base?.body || '', /padding:\s*14px 16px 12px/, surface);
|
|
}
|
|
const display = rules.find(
|
|
({ selector }) =>
|
|
selector === '#pp-toggles > .pp-header-row .pp-collapse-btn',
|
|
);
|
|
assert.match(display?.body || '', /font-size:\s*12px/);
|
|
});
|
|
|
|
test('rail titles and dock labels share one set of label tokens', () => {
|
|
// command-dock-trays.css sets the dock's label type; earlier dock rules
|
|
// for the same selector are overridden by it.
|
|
const dock = rules.find(
|
|
({ selector, body }) =>
|
|
selector ===
|
|
'#command-dock .panel-title, #command-dock .location-toolbar-label' &&
|
|
/--dock-label-/.test(body),
|
|
);
|
|
const rail = railRules.find(({ body }) =>
|
|
/--dock-label-font-size/.test(body),
|
|
);
|
|
assert.match(dock?.body || '', /font-size:\s*var\(--dock-label-font-size\)/);
|
|
assert.match(
|
|
dock?.body || '',
|
|
/letter-spacing:\s*var\(--dock-label-letter-spacing\)/,
|
|
);
|
|
// The dock's rem type, capped at its 16px-root size: a collapsed launcher
|
|
// is a fixed 176px, so a larger browser font must not cut titles short.
|
|
assert.match(
|
|
rail?.body || '',
|
|
/font-size:\s*min\(var\(--dock-label-font-size\),\s*9\.28px\)/,
|
|
);
|
|
assert.match(
|
|
rail?.body || '',
|
|
/letter-spacing:\s*min\(var\(--dock-label-letter-spacing\),\s*2\.08px\)/,
|
|
);
|
|
});
|
|
|
|
test('launcher compaction and header colour stay on the rail panels themselves', () => {
|
|
// The divider, gap and toggle rules; the translated type rule is checked
|
|
// above.
|
|
const compact = railRules.filter(
|
|
({ selector }) =>
|
|
/\.collapsed > \[class\$='-panel-inner'\] > \.panel-header/.test(
|
|
selector,
|
|
) && !selector.startsWith('html:'),
|
|
);
|
|
assert.equal(compact.length, 3);
|
|
for (const { selector } of compact) {
|
|
// Each launcher is a direct child of its rail: Radio, nested inside
|
|
// Context, is not a launcher. The header must not itself be required to
|
|
// be a rail child.
|
|
assert.match(
|
|
selector,
|
|
/#right-context-rail\) > \.panel-collapsible\.collapsed > \[class\$='-panel-inner'\] > \.panel-header/,
|
|
);
|
|
assert.match(
|
|
selector,
|
|
/#right-context-rail\) > #pp-toggles\.collapsed > \.pp-header-row/,
|
|
);
|
|
}
|
|
const colour = railRules.find(({ body }) =>
|
|
/--rail-label-hover, /.test(body),
|
|
);
|
|
assert.match(
|
|
colour.selector,
|
|
/:is\(\.panel-header, \.pp-header-row\) > \.panel-collapse-btn/,
|
|
);
|
|
assert.doesNotMatch(colour.selector, /, \.panel-collapse-btn\)/);
|
|
});
|