mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
feat(ui): render the Display panel's 3D aircraft group from the store
This commit is contained in:
1 parent
1139d364c7
commit
926253e8a3
9 files changed
+126
-40
No files matched your search
+37
-20
@@ -1,15 +1,28 @@
|
||||
import { syncSegmentedControl } from './segmentedControl.js';
|
||||
import { useDisplayStore } from './stores/display.js';
|
||||
import { applicationPinia } from './vueRuntime.js';
|
||||
|
||||
/** Own the shared aircraft display preference and its controls. */
|
||||
export class AircraftDisplay {
|
||||
constructor({ elements, readDataManager, layout }) {
|
||||
constructor({
|
||||
elements,
|
||||
readDataManager,
|
||||
layout,
|
||||
store = useDisplayStore(applicationPinia()),
|
||||
}) {
|
||||
Object.assign(this, elements, {
|
||||
readDataManager,
|
||||
store,
|
||||
_layoutRightPanels: layout,
|
||||
});
|
||||
// Both aircraft layers default to models enabled in proximity mode.
|
||||
this._models3dEnabled = true;
|
||||
this._models3dMode = 'proximity';
|
||||
// What the button, mode row and mode segments show; null until first
|
||||
// synced, so the initial markup stands. Enabling from the button leaves
|
||||
// the row to its own sync, so each is held apart.
|
||||
this._models3dPressedShown = null;
|
||||
this._models3dRowShown = null;
|
||||
this._models3dModeShown = null;
|
||||
this._models3dModeBtns = [
|
||||
document.getElementById('models3d-mode-proximity'),
|
||||
document.getElementById('models3d-mode-all'),
|
||||
@@ -28,20 +41,28 @@ export class AircraftDisplay {
|
||||
if (!options) return;
|
||||
this._models3dEnabled = options.models3d === true;
|
||||
this._models3dMode = options.models3dMode === 'all' ? 'all' : 'proximity';
|
||||
this._syncModels3dButtonState();
|
||||
this._models3dModeRow?.classList.toggle('visible', this._models3dEnabled);
|
||||
syncSegmentedControl(this._models3dModeBtns, this._models3dMode, {
|
||||
valueOf: (button) => button.dataset.mode,
|
||||
});
|
||||
this._models3dPressedShown = this._models3dEnabled;
|
||||
this._models3dRowShown = this._models3dEnabled;
|
||||
this._models3dModeShown = this._models3dMode;
|
||||
this._publishModels3d();
|
||||
this._layoutRightPanels();
|
||||
}
|
||||
|
||||
_syncModels3dModeRow() {
|
||||
if (this._models3dModeRow)
|
||||
this._models3dModeRow.classList.toggle('visible', this._models3dEnabled);
|
||||
this._models3dRowShown = this._models3dEnabled;
|
||||
this._publishModels3d();
|
||||
this._layoutRightPanels();
|
||||
}
|
||||
|
||||
/** Present the 3D aircraft group as its controls show it. */
|
||||
_publishModels3d() {
|
||||
this.store.publishModels3d({
|
||||
pressed: this._models3dPressedShown,
|
||||
rowVisible: this._models3dRowShown,
|
||||
mode: this._models3dModeShown,
|
||||
});
|
||||
}
|
||||
|
||||
_initModels3dToggle() {
|
||||
if (!this._models3dBtn) return;
|
||||
this._syncModels3dButtonState();
|
||||
@@ -58,21 +79,17 @@ export class AircraftDisplay {
|
||||
const normalized = mode === 'all' ? 'all' : 'proximity';
|
||||
this._models3dMode = normalized;
|
||||
this._setModels3dParams({ models3dMode: normalized });
|
||||
syncSegmentedControl(this._models3dModeBtns, normalized, {
|
||||
valueOf: (button) => button.dataset.mode,
|
||||
});
|
||||
this._models3dModeShown = normalized;
|
||||
this._syncModels3dButtonState();
|
||||
}
|
||||
|
||||
_syncModels3dButtonState() {
|
||||
this._models3dBtn?.classList.toggle('active', this._models3dEnabled);
|
||||
// The lit/dark state is a colour to a sighted operator and nothing at all to
|
||||
// a screen reader without this. It matters more now that the button ships
|
||||
// ACTIVE from markup (default-on, 2026-08-22): the very first thing assistive
|
||||
// tech reported was an unpressed-looking control over an armed layer.
|
||||
this._models3dBtn?.setAttribute(
|
||||
'aria-pressed',
|
||||
String(this._models3dEnabled),
|
||||
);
|
||||
// a screen reader without aria-pressed, which the view renders with it. It
|
||||
// matters more now that the button ships ACTIVE from markup (default-on,
|
||||
// 2026-08-22): the very first thing assistive tech reported was an
|
||||
// unpressed-looking control over an armed layer.
|
||||
this._models3dPressedShown = this._models3dEnabled;
|
||||
this._publishModels3d();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user