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
15 changes: 15 additions & 0 deletions frontend/src/assets/editMode.css
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,21 @@
}
}

/* On a touch phone the dashboard's title row can hold nothing that shows: the title is in the top
bar, a long press takes the place of Edit layout, and the top bar's refresh button spins for
the refresh. Such a row gives its height and gap back to the cards. A row with a caption or any
other action, such as the statistics' period and filters, stays. */
@media (width <= 767px) and (hover: none) and (pointer: coarse) {
.view-header:has(.edit-layout-btn):not(
:has(
.view-header__caption,
.view-header__actions > :not(.refresh-indicator, .edit-layout-btn--touch-hidden)
)
) {
display: none;
}
}

.edit-mode-bar-enter-active,
.edit-mode-bar-leave-active {
transition:
Expand Down
15 changes: 5 additions & 10 deletions frontend/src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,8 @@ 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. */
/* The heading and its info button have gone up to the top bar, so the row keeps the caption and
the actions, on one middle. */
.view-header {
align-items: center;
}
Expand All @@ -1029,14 +1029,9 @@ body,
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);
/* With no caption and no actions left, the row would be an empty band above the first card. */
.view-header:not(:has(.view-header__caption, .view-header__actions > *)) {
display: none;
}

.sidebar-meta .app-footer__meta {
Expand Down
35 changes: 34 additions & 1 deletion frontend/src/assets/shell.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@
white-space: nowrap;
}

/* Up here the info button is a small mark raised off the heading's top right, like a footnote
sign, so the heading keeps the bar's middle. Its hit area stays 28px, past the 24px minimum. */
.mobile-topbar__title .view-header__title {
gap: 0;
}

.mobile-topbar__title .view-header__info {
width: 28px;
height: 28px;
margin-left: -0.1rem;
font-size: 0.8rem;
transform: translateY(-0.55rem);
}

/* ── Backdrop ─────────────────────────────────────────────── */

.sidebar-backdrop {
Expand Down Expand Up @@ -220,18 +234,37 @@
/* A short line under the heading inside the title row (ViewHeader's caption), such as the period
Statistics shows. */
.view-header__caption {
display: flex;
align-items: center;
gap: 0.4rem;
margin: 0.15rem 0 0;
color: var(--color-text);
font-weight: 600;
}

/* The period is what the whole page shows, so it reads as such: a calendar in the accent colour
ahead of it, rather than a muted footnote. */
.view-header__caption-icon {
color: var(--color-primary-light);
}

/* The heading with its info button beside it: they travel together to a phone's top bar. */
.view-header__title {
display: flex;
align-items: center;
gap: 0.25rem;
min-width: 0;
}

/* 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;
flex-shrink: 0;
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;
Expand Down
44 changes: 25 additions & 19 deletions frontend/src/components/ViewHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// 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.
// A phone's top bar shows the heading and its info button 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'
Expand All @@ -25,26 +25,32 @@ const aboutOpen = ref(false)

<template>
<div class="view-header">
<div v-if="caption" class="view-header__heading">
<div class="view-header__heading">
<Teleport defer to="#mobile-topbar-title" :disabled="!isPhone">
<h1>{{ title }}</h1>
<div class="view-header__title">
<h1>{{ title }}</h1>
<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>
</Teleport>
<p class="text-muted text-sm view-header__caption">{{ caption }}</p>
<p v-if="caption" class="text-sm view-header__caption">
<font-awesome-icon
icon="calendar-days"
class="view-header__caption-icon"
aria-hidden="true"
/>
<span>{{ caption }}</span>
</p>
</div>
<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>
Expand Down
20 changes: 16 additions & 4 deletions frontend/src/components/__tests__/ViewHeader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('ViewHeader', () => {
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 () => {
it('puts the heading and its info button in the top bar on a phone, the caption in the row', async () => {
vi.stubGlobal('matchMedia', (query: string) => ({
matches: query === PHONE_MEDIA_QUERY,
media: query,
Expand All @@ -59,11 +59,23 @@ describe('ViewHeader', () => {
const topbar = document.body.appendChild(document.createElement('div'))
topbar.id = 'mobile-topbar-title'

const wrapper = mountHeader({ title: 'Map', caption: '27 Aug - 25 Nov 2026' })
const wrapper = mountHeader({
title: 'Trip log',
caption: 'November 2026',
subtitle: 'Every trip, for the taxman.',
})
await flushPromises()

expect(topbar.querySelector('h1')?.textContent).toBe('Map')
expect(topbar.querySelector('h1')?.textContent).toBe('Trip log')
expect(topbar.querySelector('.view-header__info')).not.toBeNull()
expect(wrapper.find('.view-header h1').exists()).toBe(false)
expect(wrapper.get('.view-header__caption').text()).toBe('27 Aug - 25 Nov 2026')
expect(wrapper.find('.view-header .view-header__info').exists()).toBe(false)
expect(wrapper.get('.view-header__caption').text()).toBe('November 2026')

;(topbar.querySelector('.view-header__info') as HTMLButtonElement).click()
await flushPromises()
expect(document.querySelector('[role="dialog"]')?.textContent).toContain(
'Every trip, for the taxman.',
)
})
})
Loading