feat: introduce the compact vehicle HUD
This commit is contained in:
@@ -21,3 +21,12 @@ The complete license text is distributed in `node_modules/@fontsource-variable/g
|
||||
- License: SIL Open Font License 1.1
|
||||
|
||||
The complete license text is distributed in `node_modules/@fontsource-variable/geist-mono/LICENSE` during development and dependency review.
|
||||
|
||||
## Phosphor Icons for Vue
|
||||
|
||||
- Package: `@phosphor-icons/vue` version 2.2.1
|
||||
- Copyright: Phosphor Icons contributors
|
||||
- Package source: https://github.com/phosphor-icons/vue
|
||||
- License: MIT
|
||||
|
||||
The complete license text is distributed in `node_modules/@phosphor-icons/vue/LICENSE` during development and dependency review.
|
||||
|
||||
13
package-lock.json
generated
13
package-lock.json
generated
@@ -11,6 +11,7 @@
|
||||
"dependencies": {
|
||||
"@fontsource-variable/geist": "5.3.0",
|
||||
"@fontsource-variable/geist-mono": "5.3.0",
|
||||
"@phosphor-icons/vue": "2.2.1",
|
||||
"canonicalize": "2.1.0",
|
||||
"three": "^0.185.1",
|
||||
"vue": "^3.5.42",
|
||||
@@ -1365,6 +1366,18 @@
|
||||
"third-party-web": "latest"
|
||||
}
|
||||
},
|
||||
"node_modules/@phosphor-icons/vue": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@phosphor-icons/vue/-/vue-2.2.1.tgz",
|
||||
"integrity": "sha512-3RNg1utc2Z5RwPKWFkW3eXI/0BfQAwXgtFxPUPeSzi55jGYUq16b+UqcgbKLazWFlwg5R92OCLKjDiJjeiJcnA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": ">=3.2.39"
|
||||
}
|
||||
},
|
||||
"node_modules/@pkgjs/parseargs": {
|
||||
"version": "0.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
"dependencies": {
|
||||
"@fontsource-variable/geist": "5.3.0",
|
||||
"@fontsource-variable/geist-mono": "5.3.0",
|
||||
"@phosphor-icons/vue": "2.2.1",
|
||||
"canonicalize": "2.1.0",
|
||||
"three": "^0.185.1",
|
||||
"vue": "^3.5.42",
|
||||
|
||||
@@ -18,7 +18,7 @@ import { useKeyboardNavigation } from '@/composables/useKeyboardNavigation';
|
||||
import { useMotionPreferences } from '@/composables/useMotionPreferences';
|
||||
import type { PortfolioContent, SectionId } from '@/content/types';
|
||||
import type { SceneHostState } from '@/composables/useSceneController';
|
||||
import type { MotionPolicy, QualityTier } from '@/journey/motion-policy';
|
||||
import type { MotionPolicy } from '@/journey/motion-policy';
|
||||
|
||||
declare const __PORTFOLIO_TEST_BUILD__: boolean;
|
||||
const TEST_BUILD = typeof __PORTFOLIO_TEST_BUILD__ !== 'undefined' && __PORTFOLIO_TEST_BUILD__;
|
||||
@@ -75,7 +75,6 @@ const serverDefaultPolicy: MotionPolicy = {
|
||||
reason: 'full',
|
||||
};
|
||||
const displayedPolicy = computed(() => controlsReady.value ? motion.policy.value : serverDefaultPolicy);
|
||||
const displayedQuality = computed<QualityTier>(() => controlsReady.value ? actualQuality.value : 'high');
|
||||
const displayedSceneState = computed(() => controlsReady.value ? sceneState.value : 'running');
|
||||
let removePageListeners = (): void => {};
|
||||
|
||||
@@ -173,7 +172,6 @@ onUnmounted(() => removePageListeners());
|
||||
<JourneyHud
|
||||
:journey="journey"
|
||||
:section-label="activeSectionLabel"
|
||||
:quality="displayedQuality"
|
||||
/>
|
||||
<header class="site-header">
|
||||
<h1>{{ content.identity.name }}</h1>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import IconGlyph, { type IconGlyphName } from './IconGlyph.vue';
|
||||
import type { AudioUiState } from '@/audio/types';
|
||||
import type { MotionPolicy, QualityTier } from '@/journey/motion-policy';
|
||||
|
||||
@@ -27,13 +28,31 @@ const emit = defineEmits<{
|
||||
audioVolumeChange: [volume: number];
|
||||
}>();
|
||||
|
||||
const controlRoot = ref<HTMLElement | null>(null);
|
||||
const settingsButton = ref<HTMLButtonElement | null>(null);
|
||||
const volumeButton = ref<HTMLButtonElement | null>(null);
|
||||
const settingsOpen = ref(false);
|
||||
const volumeOpen = ref(false);
|
||||
|
||||
const action = computed(() => {
|
||||
if (props.policy.reason === 'visitor-pause') return { label: 'Resume motion', event: 'resume' as const };
|
||||
if (props.policy.reason === 'saved-static') return { label: 'Enable motion', event: 'enable' as const };
|
||||
if (props.policy.reason === 'full') return { label: 'Pause motion', event: 'pause' as const };
|
||||
if (props.policy.reason === 'visitor-pause') {
|
||||
return { label: 'Resume motion', event: 'resume' as const, icon: 'play' as IconGlyphName };
|
||||
}
|
||||
if (props.policy.reason === 'saved-static') {
|
||||
return { label: 'Enable motion', event: 'enable' as const, icon: 'play' as IconGlyphName };
|
||||
}
|
||||
if (props.policy.reason === 'full') {
|
||||
return { label: 'Pause motion', event: 'pause' as const, icon: 'pause' as IconGlyphName };
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const isAudioActive = computed(() => (
|
||||
props.audioState.kind === 'running' || props.audioState.kind === 'suspended'
|
||||
));
|
||||
const muteLabel = computed(() => props.audioMuted ? 'Unmute sound' : 'Mute sound');
|
||||
const muteIcon = computed<IconGlyphName>(() => props.audioMuted ? 'sound-muted' : 'sound');
|
||||
|
||||
const statusText = computed(() => {
|
||||
if (props.policy.reason === 'system-reduce') return 'Motion: static — reduced motion requested';
|
||||
if (props.policy.reason === 'data-saver') return 'Motion: static — data saver is active';
|
||||
@@ -41,7 +60,7 @@ const statusText = computed(() => {
|
||||
if (props.policy.reason === 'saved-static') return 'Motion: static';
|
||||
if (props.sceneStatus === 'failed' || props.sceneStatus === 'static') return 'Visuals unavailable';
|
||||
if (props.sceneStatus === 'loading' || props.sceneStatus === 'idle') return 'Motion: preparing';
|
||||
return 'Motion: active';
|
||||
return null;
|
||||
});
|
||||
|
||||
const runAction = (): void => {
|
||||
@@ -61,35 +80,160 @@ const changeQuality = (event: Event): void => {
|
||||
const changeVolume = (event: Event): void => {
|
||||
emit('audioVolumeChange', Number((event.currentTarget as HTMLInputElement).value));
|
||||
};
|
||||
|
||||
const toggleSettings = (): void => {
|
||||
settingsOpen.value = !settingsOpen.value;
|
||||
volumeOpen.value = false;
|
||||
};
|
||||
|
||||
const toggleVolume = (): void => {
|
||||
volumeOpen.value = !volumeOpen.value;
|
||||
settingsOpen.value = false;
|
||||
};
|
||||
|
||||
const closePanels = (restoreFocus = false): void => {
|
||||
const focusTarget = settingsOpen.value ? settingsButton.value : volumeButton.value;
|
||||
settingsOpen.value = false;
|
||||
volumeOpen.value = false;
|
||||
if (restoreFocus) void nextTick(() => focusTarget?.focus());
|
||||
};
|
||||
|
||||
const onDocumentPointerDown = (event: Event): void => {
|
||||
if (controlRoot.value?.contains(event.target as Node)) return;
|
||||
closePanels();
|
||||
};
|
||||
|
||||
const onDocumentKeyDown = (event: KeyboardEvent): void => {
|
||||
if (event.key !== 'Escape' || (!settingsOpen.value && !volumeOpen.value)) return;
|
||||
event.preventDefault();
|
||||
closePanels(true);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.audioState.kind,
|
||||
() => closePanels(),
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
document.addEventListener('pointerdown', onDocumentPointerDown);
|
||||
document.addEventListener('keydown', onDocumentKeyDown);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('pointerdown', onDocumentPointerDown);
|
||||
document.removeEventListener('keydown', onDocumentKeyDown);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="drive-controls">
|
||||
<button v-if="action" type="button" @click="runAction">{{ action.label }}</button>
|
||||
<div v-if="audioState.kind === 'idle'" class="drive-controls__audio-start">
|
||||
<button type="button" @click="emit('audioStart')">START THE DRIVE</button>
|
||||
<span>Enables the interactive soundtrack.</span>
|
||||
</div>
|
||||
<div v-else-if="audioState.kind === 'starting'" class="drive-controls__audio-start" aria-live="polite">
|
||||
<button type="button" disabled>Starting drive…</button>
|
||||
<span>Preparing the interactive soundtrack.</span>
|
||||
</div>
|
||||
<div
|
||||
ref="controlRoot"
|
||||
class="drive-controls"
|
||||
:data-drive-state="audioState.kind"
|
||||
>
|
||||
<button
|
||||
v-if="audioState.kind === 'idle'"
|
||||
class="drive-start"
|
||||
type="button"
|
||||
aria-label="Start the drive"
|
||||
@click="emit('audioStart')"
|
||||
>
|
||||
<IconGlyph name="play" />
|
||||
<span>START THE DRIVE</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
v-else-if="audioState.kind === 'starting'"
|
||||
class="drive-start"
|
||||
type="button"
|
||||
disabled
|
||||
aria-label="Starting drive"
|
||||
aria-live="polite"
|
||||
>
|
||||
<IconGlyph name="play" />
|
||||
<span>STARTING…</span>
|
||||
</button>
|
||||
|
||||
<p v-else-if="audioState.kind === 'failed'" class="drive-controls__audio-status" role="status">
|
||||
Audio unavailable. Continue without sound.
|
||||
</p>
|
||||
<div
|
||||
v-else-if="audioState.kind === 'running' || audioState.kind === 'suspended'"
|
||||
class="drive-controls__audio"
|
||||
>
|
||||
|
||||
<div v-else-if="isAudioActive" class="drive-controls__dock" role="group" aria-label="Drive controls">
|
||||
<button
|
||||
v-if="audioState.kind === 'suspended' && audioState.resumeRequiresGesture"
|
||||
class="drive-control-button"
|
||||
type="button"
|
||||
aria-label="Resume sound"
|
||||
title="Resume sound"
|
||||
data-tooltip="Resume sound"
|
||||
@click="emit('audioResume')"
|
||||
>Resume sound</button>
|
||||
<label>
|
||||
<span>Sound volume</span>
|
||||
<input
|
||||
>
|
||||
<IconGlyph name="play" />
|
||||
</button>
|
||||
<button
|
||||
class="drive-control-button"
|
||||
type="button"
|
||||
:aria-label="muteLabel"
|
||||
:title="muteLabel"
|
||||
:data-tooltip="muteLabel"
|
||||
@click="emit('audioMuteToggle')"
|
||||
>
|
||||
<IconGlyph :name="muteIcon" />
|
||||
</button>
|
||||
|
||||
<button
|
||||
ref="volumeButton"
|
||||
class="drive-control-button"
|
||||
type="button"
|
||||
aria-label="Sound volume"
|
||||
title="Sound volume"
|
||||
data-tooltip="Sound volume"
|
||||
aria-controls="drive-volume-panel"
|
||||
:aria-expanded="volumeOpen"
|
||||
@click="toggleVolume"
|
||||
>
|
||||
<IconGlyph name="volume" />
|
||||
</button>
|
||||
|
||||
<button
|
||||
v-if="action"
|
||||
class="drive-control-button"
|
||||
type="button"
|
||||
:aria-label="action.label"
|
||||
:title="action.label"
|
||||
:data-tooltip="action.label"
|
||||
@click="runAction"
|
||||
>
|
||||
<IconGlyph :name="action.icon" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-if="audioState.kind !== 'starting'"
|
||||
ref="settingsButton"
|
||||
class="drive-control-button drive-controls__settings-trigger"
|
||||
type="button"
|
||||
aria-label="Drive settings"
|
||||
title="Drive settings"
|
||||
data-tooltip="Drive settings"
|
||||
aria-controls="drive-settings-panel"
|
||||
:aria-expanded="settingsOpen"
|
||||
@click="toggleSettings"
|
||||
>
|
||||
<IconGlyph name="settings" />
|
||||
</button>
|
||||
|
||||
<div
|
||||
v-if="volumeOpen && isAudioActive"
|
||||
id="drive-volume-panel"
|
||||
class="drive-popover drive-popover--volume"
|
||||
role="dialog"
|
||||
aria-label="Sound volume"
|
||||
>
|
||||
<label for="drive-volume">SOUND</label>
|
||||
<input
|
||||
id="drive-volume"
|
||||
aria-label="Sound volume level"
|
||||
type="range"
|
||||
min="0"
|
||||
max="1"
|
||||
@@ -97,20 +241,25 @@ const changeVolume = (event: Event): void => {
|
||||
:value="audioVolume"
|
||||
@input="changeVolume"
|
||||
>
|
||||
</label>
|
||||
<button type="button" @click="emit('audioMuteToggle')">
|
||||
{{ audioMuted ? 'Unmute sound' : 'Mute sound' }}
|
||||
</button>
|
||||
<output for="drive-volume">{{ Math.round(audioVolume * 100) }}%</output>
|
||||
</div>
|
||||
<label>
|
||||
<span>Quality</span>
|
||||
<select :value="maximumQuality" aria-label="Quality control" @change="changeQuality">
|
||||
|
||||
<div
|
||||
v-if="settingsOpen"
|
||||
id="drive-settings-panel"
|
||||
class="drive-popover drive-popover--settings"
|
||||
role="dialog"
|
||||
aria-label="Drive settings"
|
||||
>
|
||||
<strong>DRIVE SETTINGS</strong>
|
||||
<label for="drive-quality">QUALITY</label>
|
||||
<select id="drive-quality" :value="maximumQuality" aria-label="Quality control" @change="changeQuality">
|
||||
<option value="high">High</option>
|
||||
<option value="medium">Medium</option>
|
||||
<option value="low">Low</option>
|
||||
<option value="static">Static</option>
|
||||
</select>
|
||||
</label>
|
||||
<p class="drive-controls__status" role="status">{{ statusText }}</p>
|
||||
<p v-if="statusText" class="drive-controls__status" role="status">{{ statusText }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
42
src/components/IconGlyph.vue
Normal file
42
src/components/IconGlyph.vue
Normal file
@@ -0,0 +1,42 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import {
|
||||
PhPause,
|
||||
PhPlay,
|
||||
PhSlidersHorizontal,
|
||||
PhSpeakerHigh,
|
||||
PhSpeakerX,
|
||||
PhWaveform,
|
||||
} from '@phosphor-icons/vue';
|
||||
|
||||
export type IconGlyphName = 'pause' | 'play' | 'settings' | 'sound' | 'sound-muted' | 'volume';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
name: IconGlyphName;
|
||||
size?: number;
|
||||
}>(), {
|
||||
size: 20,
|
||||
});
|
||||
|
||||
const icons = {
|
||||
pause: PhPause,
|
||||
play: PhPlay,
|
||||
settings: PhSlidersHorizontal,
|
||||
sound: PhSpeakerHigh,
|
||||
'sound-muted': PhSpeakerX,
|
||||
volume: PhWaveform,
|
||||
} as const;
|
||||
|
||||
const icon = computed(() => icons[props.name]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<component
|
||||
:is="icon"
|
||||
class="icon-glyph"
|
||||
:size="size"
|
||||
weight="regular"
|
||||
aria-hidden="true"
|
||||
focusable="false"
|
||||
/>
|
||||
</template>
|
||||
@@ -1,23 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import type { JourneySnapshot } from '@/journey/types';
|
||||
import type { QualityTier } from '@/journey/motion-policy';
|
||||
|
||||
const props = defineProps<{
|
||||
journey: JourneySnapshot;
|
||||
sectionLabel: string;
|
||||
quality: QualityTier;
|
||||
}>();
|
||||
|
||||
const routePercent = computed(() => `${Math.round(Math.min(1, Math.max(0, props.journey.routeProgress)) * 100)}%`);
|
||||
const qualityLabel = computed(() => props.quality.charAt(0).toUpperCase() + props.quality.slice(1));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<aside class="journey-hud" aria-hidden="true">
|
||||
<span class="journey-hud__route">ROUTE {{ routePercent }}</span>
|
||||
<span class="journey-hud__route"><span>ROUTE</span> <strong>{{ routePercent }}</strong></span>
|
||||
<span class="journey-hud__section">{{ sectionLabel }}</span>
|
||||
<span class="journey-hud__quality">{{ qualityLabel }}</span>
|
||||
<strong v-if="journey.arrived" class="journey-hud__arrival">ARRIVED</strong>
|
||||
</aside>
|
||||
</template>
|
||||
|
||||
@@ -133,187 +133,317 @@
|
||||
|
||||
.journey-hud {
|
||||
position: fixed;
|
||||
z-index: 4;
|
||||
inset: auto 1rem 1rem auto;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, auto);
|
||||
gap: 0.25rem 0.9rem;
|
||||
min-inline-size: 12rem;
|
||||
padding: 0.75rem 0.9rem;
|
||||
border: 1px solid rgb(128 217 230 / 38%);
|
||||
background: rgb(4 9 18 / 84%);
|
||||
z-index: var(--z-hud);
|
||||
inset: auto max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) auto;
|
||||
display: flex;
|
||||
min-block-size: 44px;
|
||||
align-items: center;
|
||||
gap: 0.72rem;
|
||||
padding: 0.48rem 0.72rem;
|
||||
border: 1px solid rgb(126 220 232 / 25%);
|
||||
border-radius: 2px;
|
||||
background: var(--surface-strong);
|
||||
box-shadow: 0 0.8rem 2.4rem rgb(0 5 14 / 28%);
|
||||
color: var(--text-muted);
|
||||
font: 600 var(--step--1)/1.2 var(--mono);
|
||||
letter-spacing: 0.06em;
|
||||
font: 560 0.72rem/1 var(--mono);
|
||||
letter-spacing: 0.08em;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.journey-hud__route {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.journey-hud__route span {
|
||||
color: rgb(170 185 194 / 70%);
|
||||
font-size: 0.61rem;
|
||||
}
|
||||
|
||||
.journey-hud__route strong {
|
||||
color: var(--text);
|
||||
font-size: 0.76rem;
|
||||
}
|
||||
|
||||
.journey-hud__section,
|
||||
.journey-hud__arrival {
|
||||
color: var(--cyan);
|
||||
}
|
||||
|
||||
.journey-hud__section::before {
|
||||
margin-inline-end: 0.72rem;
|
||||
color: rgb(126 220 232 / 35%);
|
||||
content: '/';
|
||||
}
|
||||
|
||||
.journey-hud__arrival {
|
||||
grid-column: 1 / -1;
|
||||
padding-inline-start: 0.12rem;
|
||||
color: var(--amber);
|
||||
}
|
||||
|
||||
.drive-controls {
|
||||
position: fixed;
|
||||
z-index: 5;
|
||||
inset: auto auto 1rem 1rem;
|
||||
z-index: var(--z-popover);
|
||||
inset: auto auto max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
max-inline-size: calc(100vw - 2rem);
|
||||
padding: 0.55rem;
|
||||
border: 1px solid rgb(128 217 230 / 32%);
|
||||
background: rgb(4 9 18 / 88%);
|
||||
gap: 0.38rem;
|
||||
max-inline-size: calc(100vw - 1.5rem);
|
||||
font-family: var(--mono);
|
||||
font-size: var(--step--1);
|
||||
font-size: 0.72rem;
|
||||
}
|
||||
|
||||
.drive-controls__audio-start,
|
||||
.drive-controls__audio {
|
||||
.drive-controls__dock {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
gap: 1px;
|
||||
padding: 3px;
|
||||
border: 1px solid rgb(126 220 232 / 24%);
|
||||
border-radius: 3px;
|
||||
background: var(--surface-strong);
|
||||
box-shadow: 0 0.8rem 2.4rem rgb(0 5 14 / 28%);
|
||||
}
|
||||
|
||||
.drive-controls__audio-start span,
|
||||
.drive-controls__audio-status {
|
||||
.drive-start,
|
||||
.drive-control-button {
|
||||
min-block-size: 44px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 2px;
|
||||
font-weight: 620;
|
||||
cursor: pointer;
|
||||
transition: opacity var(--transition), transform var(--transition);
|
||||
}
|
||||
|
||||
.drive-start {
|
||||
display: inline-flex;
|
||||
min-inline-size: 12.5rem;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding-inline: 1rem;
|
||||
border-color: rgb(120 216 229 / 72%);
|
||||
background: rgb(120 216 229 / 94%);
|
||||
box-shadow: 0 0 1.5rem rgb(77 201 220 / 17%);
|
||||
color: #041017;
|
||||
letter-spacing: 0.1em;
|
||||
}
|
||||
|
||||
.drive-start:hover:not(:disabled) {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.drive-start:disabled {
|
||||
cursor: wait;
|
||||
opacity: 0.64;
|
||||
}
|
||||
|
||||
.drive-control-button {
|
||||
position: relative;
|
||||
display: inline-grid;
|
||||
inline-size: 44px;
|
||||
place-items: center;
|
||||
padding: 0;
|
||||
background: rgb(8 17 29 / 92%);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.drive-controls button,
|
||||
.drive-controls select,
|
||||
.drive-controls input {
|
||||
min-block-size: 44px;
|
||||
border: 1px solid var(--line-strong);
|
||||
background: #101925;
|
||||
color: var(--text);
|
||||
.drive-control-button:hover {
|
||||
color: var(--cyan);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.drive-controls input[type="range"] {
|
||||
inline-size: 7rem;
|
||||
.drive-controls__settings-trigger {
|
||||
border-color: rgb(126 220 232 / 24%);
|
||||
background: var(--surface-strong);
|
||||
box-shadow: 0 0.8rem 2.4rem rgb(0 5 14 / 28%);
|
||||
}
|
||||
|
||||
.drive-start:focus-visible,
|
||||
.drive-start:focus,
|
||||
.drive-control-button:focus-visible,
|
||||
.drive-control-button:focus,
|
||||
.drive-popover input:focus-visible,
|
||||
.drive-popover select:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: inset 0 0 0 2px var(--focus), 0 0 0 1px rgb(3 8 17 / 90%);
|
||||
}
|
||||
|
||||
.drive-control-button::after {
|
||||
position: absolute;
|
||||
inset: auto auto calc(100% + 0.5rem) 50%;
|
||||
padding: 0.32rem 0.46rem;
|
||||
transform: translate(-50%, 4px);
|
||||
border: 1px solid rgb(126 220 232 / 18%);
|
||||
background: rgb(3 8 17 / 96%);
|
||||
color: var(--text);
|
||||
content: attr(data-tooltip);
|
||||
font: 520 0.65rem/1 var(--mono);
|
||||
letter-spacing: 0.02em;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity var(--transition), transform var(--transition);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.drive-control-button:hover::after,
|
||||
.drive-control-button:focus-visible::after {
|
||||
transform: translate(-50%, 0);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.drive-popover {
|
||||
position: absolute;
|
||||
inset: auto auto calc(100% + 0.7rem) 0;
|
||||
display: grid;
|
||||
transform-origin: left bottom;
|
||||
border: 1px solid rgb(126 220 232 / 27%);
|
||||
border-radius: 3px;
|
||||
background: var(--surface-strong);
|
||||
box-shadow: 0 1.4rem 3rem rgb(0 4 12 / 42%);
|
||||
color: var(--text);
|
||||
animation: drive-popover-in var(--transition) both;
|
||||
}
|
||||
|
||||
@keyframes drive-popover-in {
|
||||
from {
|
||||
transform: translateY(6px);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
to {
|
||||
transform: translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.drive-popover--volume {
|
||||
grid-template-columns: auto minmax(8rem, 1fr) auto;
|
||||
min-inline-size: 16.5rem;
|
||||
align-items: center;
|
||||
gap: 0.7rem;
|
||||
padding: 0.7rem;
|
||||
}
|
||||
|
||||
.drive-popover--settings {
|
||||
grid-template-columns: auto minmax(7rem, 1fr);
|
||||
min-inline-size: 15rem;
|
||||
gap: 0.55rem 1rem;
|
||||
padding: 0.85rem;
|
||||
}
|
||||
|
||||
.drive-popover strong,
|
||||
.drive-popover label {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.64rem;
|
||||
font-weight: 560;
|
||||
letter-spacing: 0.1em;
|
||||
}
|
||||
|
||||
.drive-popover strong {
|
||||
grid-column: 1 / -1;
|
||||
padding-block-end: 0.45rem;
|
||||
border-block-end: 1px solid rgb(126 220 232 / 14%);
|
||||
color: var(--cyan);
|
||||
}
|
||||
|
||||
.drive-popover input,
|
||||
.drive-popover select {
|
||||
min-block-size: 44px;
|
||||
}
|
||||
|
||||
.drive-popover input[type="range"] {
|
||||
inline-size: 100%;
|
||||
accent-color: var(--cyan);
|
||||
}
|
||||
|
||||
.drive-controls button {
|
||||
padding-inline: 0.8rem;
|
||||
.drive-popover select {
|
||||
border: 1px solid rgb(126 220 232 / 24%);
|
||||
border-radius: 2px;
|
||||
background: #08111d;
|
||||
color: var(--text);
|
||||
padding-inline: 0.65rem;
|
||||
}
|
||||
|
||||
.drive-controls label {
|
||||
.drive-popover output {
|
||||
color: var(--cyan);
|
||||
font-size: 0.68rem;
|
||||
}
|
||||
|
||||
.drive-controls__audio-status {
|
||||
display: inline-flex;
|
||||
min-block-size: 44px;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
}
|
||||
|
||||
.drive-controls select {
|
||||
padding-inline: 0.45rem;
|
||||
margin: 0;
|
||||
padding-inline: 0.85rem;
|
||||
border: 1px solid rgb(244 173 103 / 26%);
|
||||
border-radius: 2px;
|
||||
background: var(--surface-strong);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.drive-controls__status {
|
||||
grid-column: 1 / -1;
|
||||
margin: 0;
|
||||
padding-block-start: 0.4rem;
|
||||
border-block-start: 1px solid rgb(126 220 232 / 14%);
|
||||
color: var(--text-muted);
|
||||
font-size: 0.66rem;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
html {
|
||||
scroll-padding-block-end: 11rem;
|
||||
scroll-padding-block-end: 7rem;
|
||||
}
|
||||
|
||||
#contact {
|
||||
padding-block-end: 11rem;
|
||||
padding-block-end: 7rem;
|
||||
}
|
||||
|
||||
#contact a {
|
||||
scroll-margin-block-end: 11rem;
|
||||
}
|
||||
|
||||
.journey-hud__quality {
|
||||
display: none;
|
||||
scroll-margin-block-end: 7rem;
|
||||
}
|
||||
|
||||
.drive-controls {
|
||||
inset: auto 0.5rem 0.5rem;
|
||||
}
|
||||
|
||||
.drive-controls__status {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
|
||||
.drive-controls__audio-start span {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) and (min-height: 421px) {
|
||||
.site-header {
|
||||
padding-block-start: calc(
|
||||
var(--space-4) + var(--site-navigation-block-size) + 32px
|
||||
);
|
||||
inset-inline-start: max(0.5rem, env(safe-area-inset-left));
|
||||
inset-block-end: max(0.5rem, env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.journey-hud {
|
||||
inset: var(--site-navigation-block-size) 0 auto;
|
||||
display: flex;
|
||||
min-block-size: 32px;
|
||||
min-inline-size: 0;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.6rem;
|
||||
padding: 0.35rem 0.75rem;
|
||||
border-inline: 0;
|
||||
font-size: 0.7rem;
|
||||
inset-inline-end: max(0.5rem, env(safe-area-inset-right));
|
||||
inset-block-end: max(0.5rem, env(safe-area-inset-bottom));
|
||||
max-inline-size: 6.5rem;
|
||||
gap: 0.3rem;
|
||||
padding-inline: 0.55rem;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.journey-hud__arrival {
|
||||
grid-column: auto;
|
||||
}
|
||||
.journey-hud__route span,
|
||||
.journey-hud__section::before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 420px) and (min-height: 421px) {
|
||||
.drive-controls {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
inline-size: calc(100% - 1rem);
|
||||
gap: 0.35rem;
|
||||
font-size: 0.72rem;
|
||||
}
|
||||
|
||||
.drive-controls__audio-start,
|
||||
.drive-controls__audio {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.drive-controls > button,
|
||||
.drive-controls__audio-start button,
|
||||
.drive-controls__audio button {
|
||||
inline-size: 100%;
|
||||
padding-inline: 0.45rem;
|
||||
}
|
||||
|
||||
.drive-controls__audio-start span,
|
||||
.drive-controls__audio > label {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.drive-controls > label {
|
||||
min-inline-size: 0;
|
||||
gap: 0.25rem;
|
||||
.journey-hud__section {
|
||||
max-inline-size: 4.25rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.drive-controls > label select {
|
||||
inline-size: 4.6rem;
|
||||
min-inline-size: 0;
|
||||
.journey-hud__arrival {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.drive-controls__status {
|
||||
grid-column: 2;
|
||||
margin: 0;
|
||||
align-self: center;
|
||||
.drive-start {
|
||||
min-inline-size: 9rem;
|
||||
gap: 0.6rem;
|
||||
padding-inline: 0.62rem;
|
||||
font-size: 0.6rem;
|
||||
}
|
||||
|
||||
.drive-popover {
|
||||
position: fixed;
|
||||
inset: auto 0.5rem calc(max(0.5rem, env(safe-area-inset-bottom)) + 3.25rem);
|
||||
max-inline-size: calc(100vw - 1rem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,13 +455,19 @@
|
||||
.drive-controls {
|
||||
position: relative;
|
||||
inset: auto;
|
||||
max-inline-size: calc(100% - 1rem);
|
||||
margin: 0.5rem;
|
||||
inline-size: fit-content;
|
||||
max-inline-size: calc(100% - 1.5rem);
|
||||
margin: 0.75rem;
|
||||
}
|
||||
|
||||
#contact {
|
||||
padding-block-end: var(--space-3);
|
||||
}
|
||||
|
||||
.drive-popover {
|
||||
position: absolute;
|
||||
inset: auto auto calc(100% + 0.5rem) 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { expect, test } from '../helpers/serve-dist';
|
||||
import { expect, expectInsetFocusIndicator, test } from '../helpers/serve-dist';
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.addInitScript(() => {
|
||||
@@ -30,15 +30,17 @@ test('starts Web Audio synchronously from the visitor gesture and exposes access
|
||||
});
|
||||
});
|
||||
|
||||
await expect(page.getByRole('button', { name: 'START THE DRIVE' })).toBeVisible();
|
||||
await expect(page.getByText('Enables the interactive soundtrack.')).toBeVisible();
|
||||
await expect(page.getByLabel('Sound volume')).toHaveCount(0);
|
||||
await expect(page.getByRole('button', { name: 'Start the drive' })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'Mute sound' })).toHaveCount(0);
|
||||
await expect(page.getByRole('button', { name: 'Sound volume' })).toHaveCount(0);
|
||||
await expect.poll(() => page.evaluate(() => (window as unknown as { __audioConstructed: number }).__audioConstructed)).toBe(0);
|
||||
|
||||
await page.getByRole('button', { name: 'START THE DRIVE' }).click();
|
||||
await page.getByRole('button', { name: 'Start the drive' }).click();
|
||||
|
||||
await expect(page.getByRole('button', { name: 'Mute sound' })).toBeVisible();
|
||||
await expect(page.getByLabel('Sound volume')).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'Sound volume' })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'Pause motion' })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'Drive settings' })).toBeVisible();
|
||||
await expect.poll(() => page.evaluate(() => (window as unknown as { __constructedDuringGesture: number }).__constructedDuringGesture)).toBe(1);
|
||||
await expect.poll(() => page.evaluate(() => (window as unknown as { __audioConstructed: number }).__audioConstructed)).toBe(1);
|
||||
|
||||
@@ -46,24 +48,60 @@ test('starts Web Audio synchronously from the visitor gesture and exposes access
|
||||
await expect(page.getByRole('button', { name: 'Unmute sound' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('keeps the compact controls usable and dismisses the upward panels', async ({ page, distUrl }) => {
|
||||
await page.goto(distUrl, { waitUntil: 'domcontentloaded' });
|
||||
await page.getByRole('button', { name: 'Start the drive' }).click();
|
||||
|
||||
const controls = page.getByRole('group', { name: 'Drive controls' }).getByRole('button');
|
||||
const targets = await controls.evaluateAll((buttons) => buttons.map((button) => {
|
||||
const rect = button.getBoundingClientRect();
|
||||
return { width: rect.width, height: rect.height };
|
||||
}));
|
||||
expect(targets.every((target) => target.width >= 44 && target.height >= 44)).toBe(true);
|
||||
|
||||
const settings = page.getByRole('button', { name: 'Drive settings' });
|
||||
await settings.focus();
|
||||
await expectInsetFocusIndicator(page, 'button[aria-label="Drive settings"]');
|
||||
await settings.click();
|
||||
await expect(page.getByRole('dialog', { name: 'Drive settings' })).toBeVisible();
|
||||
const surfaces = await page.locator('.journey-hud, .drive-controls__dock, .drive-popover').evaluateAll((elements) =>
|
||||
elements.map((element) => {
|
||||
const style = getComputedStyle(element);
|
||||
const alpha = Number.parseFloat(style.backgroundColor.match(/[\d.]+(?=\))/u)?.[0] ?? '1');
|
||||
return { alpha, backdropFilter: style.backdropFilter };
|
||||
}));
|
||||
expect(surfaces.every((surface) => surface.alpha >= 0.95 && surface.backdropFilter === 'none')).toBe(true);
|
||||
await page.keyboard.press('Escape');
|
||||
await expect(page.getByRole('dialog', { name: 'Drive settings' })).toHaveCount(0);
|
||||
await expect(settings).toBeFocused();
|
||||
|
||||
await settings.click();
|
||||
await page.locator('main#portfolio-content').click({ position: { x: 8, y: 8 } });
|
||||
await expect(page.getByRole('dialog', { name: 'Drive settings' })).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('persists native volume and keeps sound independent from Static motion', async ({ page, distUrl }) => {
|
||||
await page.goto(distUrl, { waitUntil: 'domcontentloaded' });
|
||||
await page.getByRole('button', { name: 'START THE DRIVE' }).click();
|
||||
await page.getByRole('button', { name: 'Start the drive' }).click();
|
||||
|
||||
const volume = page.getByLabel('Sound volume');
|
||||
await page.getByRole('button', { name: 'Sound volume' }).click();
|
||||
const volume = page.getByLabel('Sound volume level');
|
||||
await volume.fill('0.65');
|
||||
await expect(volume).toHaveValue('0.65');
|
||||
await expect.poll(() => page.evaluate(() => localStorage.getItem('portfolio.audio.volume'))).toBe('0.65');
|
||||
|
||||
await page.getByRole('button', { name: 'Drive settings' }).click();
|
||||
await page.getByLabel('Quality control').selectOption('static');
|
||||
await expect(page.getByRole('button', { name: 'Unmute sound' })).toHaveCount(0);
|
||||
await expect(page.getByRole('button', { name: 'Mute sound' })).toBeVisible();
|
||||
await expect(volume).toHaveCount(0);
|
||||
await page.getByRole('button', { name: 'Sound volume' }).click();
|
||||
await expect(volume).toBeVisible();
|
||||
});
|
||||
|
||||
test('requires a direct visitor action after browser interruption without creating another graph', async ({ page, distUrl }) => {
|
||||
await page.goto(distUrl, { waitUntil: 'domcontentloaded' });
|
||||
await page.getByRole('button', { name: 'START THE DRIVE' }).click();
|
||||
await page.getByRole('button', { name: 'Start the drive' }).click();
|
||||
|
||||
await page.evaluate(() => {
|
||||
const context = (window as unknown as { __audioContexts: AudioContext[] }).__audioContexts[0];
|
||||
@@ -88,7 +126,7 @@ test('shows a concise non-blocking message when initial audio start is rejected'
|
||||
});
|
||||
await page.goto(distUrl, { waitUntil: 'domcontentloaded' });
|
||||
|
||||
await page.getByRole('button', { name: 'START THE DRIVE' }).click();
|
||||
await page.getByRole('button', { name: 'Start the drive' }).click();
|
||||
|
||||
await expect(page.getByText('Audio unavailable. Continue without sound.')).toBeVisible();
|
||||
await expect(page.locator('main#portfolio-content')).toBeVisible();
|
||||
|
||||
@@ -8,6 +8,7 @@ const stylesheetFiles = [
|
||||
'src/styles/base.css',
|
||||
'src/styles/layout.css',
|
||||
'src/styles/components.css',
|
||||
'src/styles/world.css',
|
||||
'src/styles/print.css',
|
||||
];
|
||||
|
||||
@@ -151,6 +152,51 @@ test('uses a stable tablet rhythm and a single readable mobile column with usabl
|
||||
await capture(page, testInfo, 'information-layer-mobile.png');
|
||||
});
|
||||
|
||||
test('keeps the compact HUD in one safe lower row without covering the road corridor', async ({ page }) => {
|
||||
for (const viewport of [
|
||||
{ width: 320, height: 800 },
|
||||
{ width: 1440, height: 900 },
|
||||
]) {
|
||||
await page.setViewportSize(viewport);
|
||||
await loadInformationLayer(page);
|
||||
const geometry = await page.evaluate(() => {
|
||||
const controls = document.querySelector<HTMLElement>('.drive-controls');
|
||||
const hud = document.querySelector<HTMLElement>('.journey-hud');
|
||||
if (!controls || !hud) throw new Error('Missing vehicle HUD');
|
||||
const controlRect = controls.getBoundingClientRect();
|
||||
const hudRect = hud.getBoundingClientRect();
|
||||
return {
|
||||
aligned: Math.abs(controlRect.bottom - hudRect.bottom) <= 1,
|
||||
separate: controlRect.right <= hudRect.left,
|
||||
controlsTargetSize: [...controls.querySelectorAll<HTMLElement>('button')]
|
||||
.every((button) => button.getBoundingClientRect().height >= 44),
|
||||
centerClear: controlRect.right < window.innerWidth * 0.42 && hudRect.left > window.innerWidth * 0.58,
|
||||
};
|
||||
});
|
||||
expect(geometry.aligned).toBe(true);
|
||||
expect(geometry.separate).toBe(true);
|
||||
expect(geometry.controlsTargetSize).toBe(true);
|
||||
if (viewport.width >= 768) expect(geometry.centerClear).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
test('moves drive controls into document flow in short landscape', async ({ page }) => {
|
||||
await page.setViewportSize({ width: 800, height: 390 });
|
||||
await loadInformationLayer(page);
|
||||
const geometry = await page.evaluate(() => {
|
||||
const controls = document.querySelector<HTMLElement>('.drive-controls');
|
||||
const contact = document.querySelector<HTMLElement>('#contact');
|
||||
if (!controls || !contact) throw new Error('Missing short-landscape controls');
|
||||
const controlsRect = controls.getBoundingClientRect();
|
||||
const contactRect = contact.getBoundingClientRect();
|
||||
return {
|
||||
position: getComputedStyle(controls).position,
|
||||
afterContact: controlsRect.top >= contactRect.bottom,
|
||||
};
|
||||
});
|
||||
expect(geometry).toEqual({ position: 'relative', afterContact: true });
|
||||
});
|
||||
|
||||
test('keeps actual standalone project and contact destinations at least 44 by 44px on mobile', async ({ page }) => {
|
||||
await page.setViewportSize({ width: 320, height: 800 });
|
||||
await loadInformationLayer(page);
|
||||
|
||||
@@ -81,10 +81,13 @@ test('keeps a scrolled content panel in a geometry-safe paint layer above the wo
|
||||
test('provides native motion and quality controls with visible state', async ({ page, distUrl }) => {
|
||||
await page.goto(distUrl, { waitUntil: 'domcontentloaded' });
|
||||
|
||||
await page.getByRole('button', { name: 'Drive settings' }).click();
|
||||
const quality = page.getByLabel('Quality control');
|
||||
await expect(quality).toBeVisible();
|
||||
await expect(page.getByRole('status')).toHaveCount(0);
|
||||
await page.keyboard.press('Escape');
|
||||
await page.getByRole('button', { name: 'Start the drive' }).click();
|
||||
await expect(page.getByRole('button', { name: 'Pause motion' })).toBeVisible();
|
||||
await expect(page.getByRole('status')).toContainText('Motion:');
|
||||
const canvas = page.locator('.journey-canvas');
|
||||
const originalCanvas = await canvas.elementHandle();
|
||||
const originalGeneration = await page.locator('.journey-world').getAttribute('data-scene-generation');
|
||||
@@ -101,7 +104,8 @@ test('provides native motion and quality controls with visible state', async ({
|
||||
await expect(page.locator('.journey-world')).toHaveAttribute('data-scene-generation', originalGeneration ?? '');
|
||||
expect(await originalCanvas?.evaluate((element) => element.isConnected)).toBe(true);
|
||||
|
||||
await quality.selectOption('static');
|
||||
await page.getByRole('button', { name: 'Drive settings' }).click();
|
||||
await page.getByLabel('Quality control').selectOption('static');
|
||||
await expect(page.getByRole('button', { name: 'Enable motion' })).toBeVisible();
|
||||
await expect(page.locator('.journey-canvas')).toHaveCount(0);
|
||||
await expect(page.getByRole('status')).toContainText('Motion: static');
|
||||
@@ -112,6 +116,7 @@ test('never creates a canvas when the system requests reduced motion', async ({
|
||||
await page.goto(distUrl, { waitUntil: 'domcontentloaded' });
|
||||
|
||||
await expect(page.locator('.journey-canvas')).toHaveCount(0);
|
||||
await page.getByRole('button', { name: 'Drive settings' }).click();
|
||||
await expect(page.getByRole('status')).toContainText('reduced motion requested');
|
||||
await expect(page.getByLabel('Quality control')).toBeVisible();
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ import { nextTick } from 'vue';
|
||||
import SceneCanvas from '@/components/SceneCanvas.vue';
|
||||
import DriveControls from '@/components/DriveControls.vue';
|
||||
import JourneyHud from '@/components/JourneyHud.vue';
|
||||
import type { AudioUiState } from '@/audio/types';
|
||||
import type { MotionPolicy, QualityTier } from '@/journey/motion-policy';
|
||||
import type { JourneySnapshot } from '@/journey/types';
|
||||
|
||||
@@ -191,43 +192,85 @@ describe('SceneCanvas', () => {
|
||||
});
|
||||
|
||||
describe('DriveControls', () => {
|
||||
const mountControls = (motionPolicy: MotionPolicy, maximum: QualityTier = 'high') => mount(DriveControls, {
|
||||
props: { policy: motionPolicy, maximumQuality: maximum, sceneStatus: 'running' },
|
||||
const mountControls = (
|
||||
motionPolicy: MotionPolicy,
|
||||
maximum: QualityTier = 'high',
|
||||
audioState: AudioUiState = { kind: 'idle' },
|
||||
) => mount(DriveControls, {
|
||||
attachTo: document.body,
|
||||
props: { policy: motionPolicy, maximumQuality: maximum, sceneStatus: 'running', audioState },
|
||||
});
|
||||
|
||||
it('uses exact native control names and a visible non-color status', async () => {
|
||||
it('presents one explicit drive action before audio activation', async () => {
|
||||
const wrapper = mountControls(policy());
|
||||
|
||||
expect(wrapper.get('button').text()).toBe('Pause motion');
|
||||
expect(wrapper.get('select').attributes('aria-label')).toBe('Quality control');
|
||||
expect(wrapper.text()).toContain('Motion: active');
|
||||
await wrapper.get('button').trigger('click');
|
||||
expect(wrapper.emitted('pause')).toHaveLength(1);
|
||||
expect(wrapper.get('[data-drive-state="idle"]').text()).toContain('START THE DRIVE');
|
||||
expect(wrapper.find('[aria-label="Mute sound"]').exists()).toBe(false);
|
||||
await wrapper.get('[aria-label="Start the drive"]').trigger('click');
|
||||
expect(wrapper.emitted('audioStart')).toHaveLength(1);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('collapses the running state to named vehicle controls and an upward settings panel', async () => {
|
||||
const wrapper = mountControls(policy(), 'high', { kind: 'running', muted: false, volume: 0.4 });
|
||||
|
||||
expect(wrapper.get('[aria-label="Mute sound"]')).toBeTruthy();
|
||||
expect(wrapper.get('[aria-label="Sound volume"]')).toBeTruthy();
|
||||
expect(wrapper.get('[aria-label="Pause motion"]')).toBeTruthy();
|
||||
const settings = wrapper.get('[aria-label="Drive settings"]');
|
||||
await settings.trigger('click');
|
||||
|
||||
const panel = wrapper.get('[role="dialog"][aria-label="Drive settings"]');
|
||||
expect(panel.text()).not.toContain('Motion: active');
|
||||
expect(panel.find('[role="status"]').exists()).toBe(false);
|
||||
expect(panel.get('select').attributes('aria-label')).toBe('Quality control');
|
||||
expect(settings.attributes('aria-expanded')).toBe('true');
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('dismisses settings with Escape and outside interaction', async () => {
|
||||
const wrapper = mountControls(policy(), 'high', { kind: 'running', muted: false, volume: 0.4 });
|
||||
const settings = wrapper.get('[aria-label="Drive settings"]');
|
||||
await settings.trigger('click');
|
||||
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
|
||||
await nextTick();
|
||||
expect(wrapper.find('[role="dialog"][aria-label="Drive settings"]').exists()).toBe(false);
|
||||
expect(document.activeElement).toBe(settings.element);
|
||||
|
||||
await settings.trigger('click');
|
||||
document.body.dispatchEvent(new MouseEvent('pointerdown', { bubbles: true }));
|
||||
await nextTick();
|
||||
expect(wrapper.find('[role="dialog"][aria-label="Drive settings"]').exists()).toBe(false);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it.each([
|
||||
['visitor-pause', 'Resume motion'],
|
||||
['saved-static', 'Enable motion'],
|
||||
] as const)('offers the correct recovery action for %s', (reason, label) => {
|
||||
const wrapper = mountControls(policy({ allowSceneRequest: false, maximumTier: 'static', reason }));
|
||||
expect(wrapper.get('button').text()).toBe(label);
|
||||
const wrapper = mountControls(
|
||||
policy({ allowSceneRequest: false, maximumTier: 'static', reason }),
|
||||
'static',
|
||||
{ kind: 'running', muted: false, volume: 0.4 },
|
||||
);
|
||||
expect(wrapper.get(`[aria-label="${label}"]`)).toBeTruthy();
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
describe('JourneyHud', () => {
|
||||
it('renders route percent, current section, quality and arrival from one snapshot', () => {
|
||||
it('renders only route percent, current section, and arrival from one snapshot', () => {
|
||||
const wrapper = mount(JourneyHud, {
|
||||
props: {
|
||||
journey: journey({ routeProgress: 1, activeSectionId: 'contact', arrived: true }),
|
||||
sectionLabel: 'Contact',
|
||||
quality: 'low',
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.text()).toContain('100%');
|
||||
expect(wrapper.text()).toContain('Contact');
|
||||
expect(wrapper.text()).toContain('Low');
|
||||
expect(wrapper.text()).toContain('ARRIVED');
|
||||
expect(wrapper.text()).not.toContain('Low');
|
||||
expect(wrapper.attributes('aria-hidden')).toBe('true');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user