Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useSignalR } from '@/composables/useSignalR'
import { useGatewayStatus } from '@/composables/useGatewayStatus'
import { useSettledAvailability } from '@/composables/useSettledAvailability'
import { useFavicon } from '@/composables/useFavicon'
import { usePageTitle } from '@/composables/usePageTitle'
import { APP_NAME, usePageTitle } from '@/composables/usePageTitle'
import { useScreenWakeLock } from '@/composables/useScreenWakeLock'
import { usePhoneGpsRecorder } from '@/composables/usePhoneGpsRecorder'
import { useRelativeTime } from '@/composables/useRelativeTime'
Expand Down Expand Up @@ -257,10 +257,11 @@ watch(
>
<font-awesome-icon :icon="menuOpen ? 'xmark' : 'bars'" />
</button>
<RouterLink to="/" class="mobile-brand">
<RouterLink to="/" class="mobile-brand" :aria-label="APP_NAME" :title="APP_NAME">
<font-awesome-icon icon="car" />
GarageStack
</RouterLink>
<!-- The page's heading, which ViewHeader moves here on a phone. -->
<div id="mobile-topbar-title" class="mobile-topbar__title" />
<div class="mobile-topbar__actions">
<!-- Refresh and Settings, which AppFooter moves here on a phone. -->
<div id="mobile-topbar-actions" class="mobile-topbar__slot" />
Expand Down
20 changes: 20 additions & 0 deletions frontend/src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,26 @@ body,
padding-inline: 0.65rem;
}

/* The heading has gone up to the top bar, so the row keeps the caption, the info button and the
actions, all on one middle. */
.view-header {
align-items: center;
}

.view-header__caption {
margin: 0;
}

.view-header__info {
width: var(--touch-target);
height: var(--touch-target);
}

/* First in its row, its icon starts on the cards' left edge. */
.view-header__info:first-child {
margin-left: calc((1rem - var(--touch-target)) / 2);
}

.sidebar-meta .app-footer__meta {
flex-wrap: wrap;
gap: 0.5rem;
Expand Down
66 changes: 66 additions & 0 deletions frontend/src/assets/map.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,55 @@
margin-bottom: 0;
}

/* Only a wrapper to fold: the list's rows stay the sidebar's own flex items. */
.trip-sidebar__body {
display: contents;
}

/* Above the map the title folds the list away: drawn as the title itself across the header, with
a chevron at the end that points down while the list is open. */
.trip-sidebar__title:has(.trip-sidebar__toggle) {
flex: 1;
}

.trip-sidebar__toggle {
display: flex;
align-items: center;
gap: inherit;
width: 100%;
min-height: var(--touch-target);
margin-block: calc((1lh - var(--touch-target)) / 2);
padding: 0;
border: none;
background: none;
color: inherit;
font: inherit;
letter-spacing: inherit;
text-align: left;
text-transform: inherit;
cursor: pointer;
}

.trip-sidebar__chevron {
margin-left: auto;
transition: transform 0.2s ease;
}

.trip-sidebar__toggle[aria-expanded='false'] .trip-sidebar__chevron {
transform: rotate(-90deg);
}

/* Folded, the sidebar is its title row and the map takes the rest. */
.trip-sidebar--folded {
padding-bottom: 0;
overflow: hidden;
}

.trip-sidebar--folded .trip-sidebar__header {
border-bottom: none;
padding-bottom: 1rem;
}

.trip-list {
list-style: none;
display: flex;
Expand Down Expand Up @@ -388,6 +437,23 @@
color: var(--color-text);
}

.map-control-btn:disabled {
background: var(--color-surface) padding-box;
color: var(--color-text-muted);
cursor: not-allowed;
}

/* The map's own buttons on the right, level with the zoom control on the left: Find car. */
.map-controls-end {
position: absolute;
top: 10px;
right: 10px;
z-index: var(--z-map-overlay);
display: flex;
flex-direction: column;
gap: 6px;
}

/* Status overlays on the map canvas: POI loading, trip snapping. Stacked in one column so two
of them never land on top of each other. */
.map-pill-stack {
Expand Down
53 changes: 46 additions & 7 deletions frontend/src/assets/shell.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,39 @@
background: var(--color-surface-2);
}

/* The app's car, the way home. The page's heading beside it says where you are. */
.mobile-brand {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 1rem;
font-weight: 700;
justify-content: center;
width: var(--touch-target);
height: var(--touch-target);
flex-shrink: 0;
margin-left: calc(-1 * var(--topbar-icon-inset));
font-size: var(--topbar-icon-size);
color: var(--color-primary);
border-radius: 6px;
text-decoration: none;
}

.mobile-brand:hover {
background: var(--color-surface-2);
}

/* The page's heading (ViewHeader moves it here on a phone), on one line: a long one ends in an
ellipsis rather than pushing the buttons off the bar. */
.mobile-topbar__title {
flex: 1;
min-width: 0;
}

.mobile-topbar__title h1 {
margin: 0;
overflow: hidden;
font-size: 1.05rem;
font-weight: 700;
line-height: 1.3;
text-overflow: ellipsis;
white-space: nowrap;
}

Expand Down Expand Up @@ -201,10 +223,27 @@
margin: 0.15rem 0 0;
}

/* A line about the page, tucked under its title rather than spaced like a section of its own. */
.view-subtitle {
margin-top: -1rem;
margin-bottom: 1.5rem;
/* The button that opens the line about the page, close beside the heading and as tall as its
line, so the actions keep their place on the right. */
.view-header__info {
display: flex;
align-items: center;
justify-content: center;
width: var(--page-title-height);
height: var(--page-title-height);
margin-left: -0.5rem;
padding: 0;
border: none;
border-radius: 6px;
background: none;
color: var(--color-text-muted);
font-size: 1rem;
cursor: pointer;
}

.view-header__info:hover {
background: var(--color-surface-2);
color: var(--color-text);
}

/* ── App footer ───────────────────────────────────────────── */
Expand Down
43 changes: 36 additions & 7 deletions frontend/src/components/ViewHeader.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,56 @@
<script setup lang="ts">
// A page's title row: the heading, the page's actions on the right, an optional caption under the
// heading inside the row (the period Statistics shows), and an optional line about the page under
// the row. Under it all, the notice that the server cannot be reached, so every page says so.
// A page's title row: the heading, the page's actions on the right, and an optional caption under
// the heading inside the row (the period Statistics shows). A line about the page waits behind an
// info button beside the heading. Under it all, the notice that the server cannot be reached, so
// every page says so.
// A phone's top bar shows the heading in place of the app's name, which leaves the page's own row
// to the caption and the actions.
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
import DetailModal from '@/components/DetailModal.vue'
import OfflineNotice from '@/components/OfflineNotice.vue'
import { useMediaQuery } from '@/composables/useMediaQuery'
import { PHONE_MEDIA_QUERY } from '@/utils/viewport'

defineProps<{
title: string
caption?: string
subtitle?: string
}>()

const { t } = useI18n()
const isPhone = useMediaQuery(PHONE_MEDIA_QUERY)
const aboutOpen = ref(false)
</script>

<template>
<div class="view-header">
<div v-if="caption">
<h1>{{ title }}</h1>
<div v-if="caption" class="view-header__heading">
<Teleport defer to="#mobile-topbar-title" :disabled="!isPhone">
<h1>{{ title }}</h1>
</Teleport>
<p class="text-muted text-sm view-header__caption">{{ caption }}</p>
</div>
<h1 v-else>{{ title }}</h1>
<Teleport v-else defer to="#mobile-topbar-title" :disabled="!isPhone">
<h1>{{ title }}</h1>
</Teleport>
<button
v-if="subtitle"
type="button"
class="view-header__info"
aria-haspopup="dialog"
:aria-label="t('common.aboutPage')"
:title="t('common.aboutPage')"
@click="aboutOpen = true"
>
<font-awesome-icon icon="circle-info" />
</button>
<div v-if="$slots.actions" class="view-header__actions">
<slot name="actions" />
</div>
</div>
<p v-if="subtitle" class="text-muted view-subtitle">{{ subtitle }}</p>
<DetailModal v-if="subtitle" :open="aboutOpen" :title="title" @close="aboutOpen = false">
<p class="card-info-desc">{{ subtitle }}</p>
</DetailModal>
<OfflineNotice />
</template>
69 changes: 69 additions & 0 deletions frontend/src/components/__tests__/ViewHeader.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import { flushPromises, mount } from '@vue/test-utils'
import { createI18n } from 'vue-i18n'
import ViewHeader from '../ViewHeader.vue'
import en from '@/locales/en.json'
import { PHONE_MEDIA_QUERY } from '@/utils/viewport'

vi.mock('@/components/OfflineNotice.vue', () => ({ default: { template: '<div />' } }))

const i18n = createI18n({ legacy: false, locale: 'en', messages: { en } })

function mountHeader(props: { title: string; caption?: string; subtitle?: string }) {
return mount(ViewHeader, {
props,
attachTo: document.body,
global: { plugins: [i18n], stubs: { FontAwesomeIcon: true } },
})
}

describe('ViewHeader', () => {
afterEach(() => {
vi.unstubAllGlobals()
document.body.innerHTML = ''
})

it('shows the heading and caption in its own row off a phone', () => {
const wrapper = mountHeader({ title: 'Map', caption: '27 Aug - 25 Nov 2026' })

expect(wrapper.get('.view-header h1').text()).toBe('Map')
expect(wrapper.get('.view-header__caption').text()).toBe('27 Aug - 25 Nov 2026')
})

it('offers no info button for a page without a line about it', () => {
const wrapper = mountHeader({ title: 'Map' })

expect(wrapper.find('.view-header__info').exists()).toBe(false)
})

it('opens the line about the page from its info button', async () => {
const wrapper = mountHeader({ title: 'Trip log', subtitle: 'Every trip, for the taxman.' })
const info = wrapper.get('.view-header__info')
expect(info.attributes('aria-label')).toBe(en.common.aboutPage)
expect(document.body.textContent).not.toContain('Every trip, for the taxman.')

await info.trigger('click')

const dialog = document.querySelector('[role="dialog"]')
expect(dialog?.getAttribute('aria-label')).toBe('Trip log')
expect(dialog?.textContent).toContain('Every trip, for the taxman.')
})

it('puts the heading in the top bar on a phone, leaving the caption in the row', async () => {
vi.stubGlobal('matchMedia', (query: string) => ({
matches: query === PHONE_MEDIA_QUERY,
media: query,
addEventListener: () => {},
removeEventListener: () => {},
}))
const topbar = document.body.appendChild(document.createElement('div'))
topbar.id = 'mobile-topbar-title'

const wrapper = mountHeader({ title: 'Map', caption: '27 Aug - 25 Nov 2026' })
await flushPromises()

expect(topbar.querySelector('h1')?.textContent).toBe('Map')
expect(wrapper.find('.view-header h1').exists()).toBe(false)
expect(wrapper.get('.view-header__caption').text()).toBe('27 Aug - 25 Nov 2026')
})
})
Loading
Loading