mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Place the credits line where Cesium's is, and draw a logo in place of its text
- Every placement of Cesium's credit display (above the command dock, the Minimal HUD's corner, clean view and recording, the phone tab bar and an open sheet) has the same rule for the application's line; a test keeps each stylesheet's pairs together. - A credit's logo is drawn in place of its text, which names it (the image's alt), as Cesium shows logo credits; the contract's Credit says so. Links open with noopener and noreferrer; a list that empties while focus is in it hands focus back to the line. - A stack that stays after any failed switch (a tileset or imagery that fails to load, or a photoreal base that fails to come back) still falls back on its tile failures: the controller binds its listener again for that switch where it handles the failure.
This commit is contained in:
1 parent
241c8dde64
commit
6a6967d1ad
8 files changed
+137
-24
No files matched your search
+11
-20
@@ -244,11 +244,18 @@ export class MapSourceController {
|
||||
this._lastError = message;
|
||||
this._onError?.(message, stack);
|
||||
const recovery = this.getStack(this._registry.recoveryId);
|
||||
if (
|
||||
const recovers =
|
||||
recovery &&
|
||||
recovery.id !== stack.id &&
|
||||
this.isStackAvailable(recovery.id)
|
||||
) {
|
||||
this.isStackAvailable(recovery.id);
|
||||
// A stack that stays after the failed switch still falls back on its
|
||||
// tile failures, heard for this switch.
|
||||
if (!recovers && this._imageryLayer && this._activeResolution) {
|
||||
this._removeImageryErrorListener?.();
|
||||
this._removeImageryErrorListener = null;
|
||||
this._watchProvider(this._activeResolution, gen);
|
||||
}
|
||||
if (recovers) {
|
||||
// Whatever settles now is the controller's choice, not the caller's.
|
||||
this._switchOrigin = 'automatic';
|
||||
try {
|
||||
@@ -302,23 +309,7 @@ export class MapSourceController {
|
||||
if (this._engine.tilesetReady) {
|
||||
this._showTileset(tileset);
|
||||
const ready = this._engine.tilesetReady(tileset);
|
||||
if (ready)
|
||||
try {
|
||||
await ready;
|
||||
} catch (error) {
|
||||
// The stack before it stays: its tile failures still fall back,
|
||||
// heard for this switch.
|
||||
if (
|
||||
gen === this._switchGen &&
|
||||
this._imageryLayer &&
|
||||
this._activeResolution
|
||||
) {
|
||||
this._removeImageryErrorListener?.();
|
||||
this._removeImageryErrorListener = null;
|
||||
this._watchProvider(this._activeResolution, gen);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
if (ready) await ready;
|
||||
if (gen !== this._switchGen) return;
|
||||
}
|
||||
this._removeImageryLayer();
|
||||
|
||||
Vendored
+1
-1
@@ -11,7 +11,7 @@ export interface Credit {
|
||||
text: string;
|
||||
/** Where the credit links to. */
|
||||
href?: string;
|
||||
/** A logo drawn before the text. */
|
||||
/** A logo, drawn in place of the text; the text names it. */
|
||||
logoUrl?: string;
|
||||
/** Shown on the map itself, rather than in the expanded list. */
|
||||
inline?: boolean;
|
||||
|
||||
+10
-3
@@ -25,7 +25,7 @@ function distinct(list) {
|
||||
});
|
||||
}
|
||||
|
||||
/** One credit as DOM: its logo, then its text, linked when it has a link. */
|
||||
/** One credit as DOM: its logo or its text, linked when it has a link. */
|
||||
function creditElement(doc, credit) {
|
||||
const href = credit.href ? safeUrl(credit.href, LINK_SCHEMES) : null;
|
||||
const element = doc.createElement(href ? 'a' : 'span');
|
||||
@@ -33,8 +33,9 @@ function creditElement(doc, credit) {
|
||||
if (href) {
|
||||
element.href = href;
|
||||
element.target = '_blank';
|
||||
element.rel = 'noopener';
|
||||
element.rel = 'noopener noreferrer';
|
||||
}
|
||||
// A logo is drawn in place of the text, which names it (its alt text).
|
||||
const logo = credit.logoUrl ? safeUrl(credit.logoUrl, LOGO_SCHEMES) : null;
|
||||
if (logo) {
|
||||
const image = doc.createElement('img');
|
||||
@@ -121,11 +122,17 @@ export function mountCreditsView(viewer, { root = document.body } = {}) {
|
||||
}),
|
||||
);
|
||||
expand.hidden = listed.length === 0;
|
||||
if (expand.hidden && !panel.hidden) setOpen(false);
|
||||
if (expand.hidden && !panel.hidden) {
|
||||
// Focus in the list goes back to the line, not to the page.
|
||||
const focused = panel.contains(doc.activeElement);
|
||||
setOpen(false);
|
||||
if (focused) line.querySelector('a')?.focus();
|
||||
}
|
||||
};
|
||||
|
||||
const onExpand = () => setOpen(panel.hidden);
|
||||
const onClose = () => setOpen(false, { focus: true });
|
||||
// Escape in the open list closes it (it takes focus as it opens).
|
||||
const onKey = (event) => {
|
||||
if (event.key !== 'Escape' || panel.hidden) return;
|
||||
event.preventDefault();
|
||||
|
||||
@@ -58,9 +58,52 @@ test("the renderer's credits show on the line, and the rest in the list it opens
|
||||
assert.equal(document.getElementById('gev-credits-panel'), null);
|
||||
});
|
||||
|
||||
test('a credit with a logo is drawn as the logo, named by its text', () => {
|
||||
const { viewer, renderer } = scene();
|
||||
renderer.credits.addStatic({
|
||||
text: 'Google',
|
||||
logoUrl: 'https://example.com/logo.png',
|
||||
inline: true,
|
||||
});
|
||||
const off = mountCreditsView(viewer);
|
||||
const credit = document.querySelector('#gev-credits .gev-credit');
|
||||
const logo = credit.querySelector('img');
|
||||
assert.equal(logo.src, 'https://example.com/logo.png');
|
||||
assert.equal(logo.alt, 'Google', 'screen readers and copies keep the name');
|
||||
assert.equal(credit.textContent, '', 'the logo stands in place of the text');
|
||||
off();
|
||||
});
|
||||
|
||||
test('a viewer with no renderer shows no credits line', () => {
|
||||
document.body.replaceChildren();
|
||||
const off = mountCreditsView({});
|
||||
assert.equal(document.getElementById('gev-credits'), null);
|
||||
off();
|
||||
});
|
||||
|
||||
test('the credits line is placed wherever the renderer’s own display is', async () => {
|
||||
const { readFileSync, readdirSync } = await import('node:fs');
|
||||
const dir = new URL('./styles/', import.meta.url);
|
||||
const missing = [];
|
||||
for (const name of readdirSync(dir).filter((f) => f.endsWith('.css'))) {
|
||||
const css = readFileSync(new URL(name, dir), 'utf8').replace(
|
||||
/\/\*[\s\S]*?\*\//g,
|
||||
'',
|
||||
);
|
||||
const parts = [...css.matchAll(/([^{};]+)\{/g)]
|
||||
.map((match) => match[1].replace(/\s+/g, ' ').trim())
|
||||
.filter((selector) => !selector.startsWith('@'))
|
||||
.flatMap((selector) =>
|
||||
selector.split(/,(?![^(]*\))/).map((part) => part.trim()),
|
||||
);
|
||||
// The display's own selectors, without its inner parts, each with the
|
||||
// line's counterpart in the same stylesheet.
|
||||
for (const part of parts)
|
||||
if (
|
||||
/#cesium-credits$/.test(part) &&
|
||||
!parts.includes(part.replace('#cesium-credits', '#gev-credits'))
|
||||
)
|
||||
missing.push(`${name}: ${part}`);
|
||||
}
|
||||
assert.deepEqual(missing, []);
|
||||
});
|
||||
@@ -380,6 +380,10 @@ body:not(.ui-clean-view):not(.recording-mode) #cesium-credits {
|
||||
bottom: calc(2vh + 4.7rem + var(--world-timeline-lift, 0px));
|
||||
}
|
||||
|
||||
body:not(.ui-clean-view):not(.recording-mode) #gev-credits {
|
||||
bottom: calc(2vh + 4.7rem + var(--world-timeline-lift, 0px));
|
||||
}
|
||||
|
||||
#intel-hud[data-variant='minimal'] .hud-bottom-left {
|
||||
bottom: calc(2vh + 5.4rem + var(--world-timeline-lift, 0px));
|
||||
}
|
||||
|
||||
@@ -462,6 +462,19 @@ body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
body:not(.ui-clean-view):not(.recording-mode) #gev-credits,
|
||||
body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
#intel-hud[data-variant='minimal'].active
|
||||
)
|
||||
#gev-credits {
|
||||
right: auto;
|
||||
bottom: calc(2vh + 5rem + var(--world-timeline-lift, 0px));
|
||||
left: 1.5rem;
|
||||
width: auto !important;
|
||||
max-width: calc(100vw - 3rem);
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#intel-hud[data-variant='tactical'] .hud-bottom-left,
|
||||
#intel-hud[data-variant='tactical'] .hud-bottom-right {
|
||||
bottom: calc(2vh + 6.5rem + var(--world-timeline-lift, 0px));
|
||||
@@ -492,6 +505,16 @@ body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
max-width: calc(100vw - 1.5rem);
|
||||
}
|
||||
|
||||
body:not(.ui-clean-view):not(.recording-mode) #gev-credits,
|
||||
body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
#intel-hud[data-variant='minimal'].active
|
||||
)
|
||||
#gev-credits {
|
||||
bottom: calc(2vh + 5rem + var(--world-timeline-lift, 0px));
|
||||
left: 0.75rem;
|
||||
max-width: calc(100vw - 1.5rem);
|
||||
}
|
||||
|
||||
#command-dock .gev-voice-error-tray {
|
||||
width: min(24rem, calc(100vw - 1.5rem));
|
||||
}
|
||||
|
||||
@@ -220,6 +220,10 @@ body:not(.ui-clean-view):not(.recording-mode) #cesium-credits {
|
||||
bottom: calc(2vh + 7rem + var(--world-timeline-lift, 0px));
|
||||
}
|
||||
|
||||
body:not(.ui-clean-view):not(.recording-mode) #gev-credits {
|
||||
bottom: calc(2vh + 7rem + var(--world-timeline-lift, 0px));
|
||||
}
|
||||
|
||||
body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
#intel-hud[data-variant='minimal'].active
|
||||
)
|
||||
@@ -230,6 +234,16 @@ body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
#intel-hud[data-variant='minimal'].active
|
||||
)
|
||||
#gev-credits {
|
||||
right: 36px;
|
||||
left: auto;
|
||||
width: min(340px, calc(100vw - 72px)) !important;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
body.ui-clean-view #command-dock,
|
||||
body.recording-mode #command-dock {
|
||||
opacity: 0 !important;
|
||||
@@ -244,6 +258,13 @@ body.recording-mode #cesium-credits {
|
||||
left: 36px;
|
||||
}
|
||||
|
||||
body.ui-clean-view #gev-credits,
|
||||
body.recording-mode #gev-credits {
|
||||
right: auto;
|
||||
bottom: 36px;
|
||||
left: 36px;
|
||||
}
|
||||
|
||||
#intel-hud[data-variant='minimal'] .hud-bottom-left {
|
||||
bottom: calc(2vh + 7.5rem + var(--world-timeline-lift, 0px));
|
||||
}
|
||||
@@ -279,6 +300,10 @@ body.recording-mode #cesium-credits {
|
||||
bottom: calc(2vh + 9.5rem + var(--world-timeline-lift, 0px));
|
||||
}
|
||||
|
||||
body:not(.ui-clean-view):not(.recording-mode) #gev-credits {
|
||||
bottom: calc(2vh + 9.5rem + var(--world-timeline-lift, 0px));
|
||||
}
|
||||
|
||||
#intel-hud[data-variant='minimal'] .hud-bottom-left {
|
||||
bottom: calc(2vh + 12rem + var(--world-timeline-lift, 0px));
|
||||
}
|
||||
|
||||
@@ -395,6 +395,18 @@ body.mobile-shell:not(.recording-mode):not(.cockpit-mode):not(.ui-clean-view)
|
||||
scale: 0.8;
|
||||
}
|
||||
|
||||
body.mobile-shell:not(.recording-mode):not(.cockpit-mode):not(.ui-clean-view)
|
||||
#gev-credits {
|
||||
right: auto;
|
||||
bottom: calc(var(--mobile-tab-space) + 106px + var(--world-timeline-lift, 0px)) !important;
|
||||
left: 10px;
|
||||
width: calc((100vw - 20px) / 0.8) !important;
|
||||
max-width: none !important;
|
||||
white-space: normal;
|
||||
transform-origin: left bottom;
|
||||
scale: 0.8;
|
||||
}
|
||||
|
||||
/* An open sheet lifts the required attribution above everything it covers. */
|
||||
body.mobile-shell[data-mobile-sheet]:not(.recording-mode):not(
|
||||
.cockpit-mode
|
||||
@@ -404,6 +416,14 @@ body.mobile-shell[data-mobile-sheet]:not(.recording-mode):not(
|
||||
z-index: 166;
|
||||
}
|
||||
|
||||
body.mobile-shell[data-mobile-sheet]:not(.recording-mode):not(
|
||||
.cockpit-mode
|
||||
):not(.ui-clean-view)
|
||||
#gev-credits {
|
||||
bottom: calc(var(--mobile-sheet-cover, 0px) + 6px) !important;
|
||||
z-index: 166;
|
||||
}
|
||||
|
||||
/* The view switcher clears the tab bar and the voice bar, opposite the credit. */
|
||||
body.mobile-shell:not(.cockpit-mode) #view-switcher {
|
||||
right: 12px;
|
||||
|
||||
Reference in new issue
Block a user