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
23 changes: 15 additions & 8 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 { APP_NAME, usePageTitle } from '@/composables/usePageTitle'
import { usePageTitle } from '@/composables/usePageTitle'
import { useScreenWakeLock } from '@/composables/useScreenWakeLock'
import { usePhoneGpsRecorder } from '@/composables/usePhoneGpsRecorder'
import { useRelativeTime } from '@/composables/useRelativeTime'
Expand Down Expand Up @@ -257,13 +257,11 @@ watch(
>
<font-awesome-icon :icon="menuOpen ? 'xmark' : 'bars'" />
</button>
<RouterLink to="/" class="mobile-brand" :aria-label="APP_NAME" :title="APP_NAME">
<font-awesome-icon icon="car" />
</RouterLink>
<!-- The page's heading, which ViewHeader moves here on a phone. -->
<!-- The page's heading, info button and caption, 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. -->
<!-- The page's own buttons (ViewHeader), then Settings (AppFooter), on a phone. -->
<div id="mobile-topbar-page-actions" class="mobile-topbar__slot" />
<div id="mobile-topbar-actions" class="mobile-topbar__slot" />
<button class="notif-bell" :aria-label="notificationsLabel" @click="togglePanel">
<font-awesome-icon icon="bell" />
Expand Down Expand Up @@ -376,17 +374,26 @@ watch(
>
</template>
</div>
<div v-if="isInitialLoading || lastFetched" class="sidebar-timestamp">
<!-- v-show, not v-if: AppFooter moves Refresh into this line on a phone, and a line
rebuilt after hiding would leave the button in the old one. -->
<div v-show="isInitialLoading || lastFetched" class="sidebar-timestamp">
<template v-if="isInitialLoading">
<span class="skeleton skeleton--icon" />
<span class="skeleton skeleton--text skeleton--text-sm" />
</template>
<template v-else>
<font-awesome-icon icon="rotate" :spin="vehicleStore.loading" aria-hidden="true" />
<font-awesome-icon
icon="rotate"
class="sidebar-timestamp__icon"
:spin="vehicleStore.loading"
aria-hidden="true"
/>
<span class="sidebar-footer__text" :title="`${t('common.fetched')} ${lastFetched}`"
>{{ t('common.fetched') }} {{ lastFetched }}</span
>
</template>
<!-- Refresh, which AppFooter moves here on a phone: beside the time it renews. -->
<span id="sidebar-refresh" class="sidebar-timestamp__action" />
</div>
<div v-if="isInitialLoading || lastRecorded" class="sidebar-timestamp">
<template v-if="isInitialLoading">
Expand Down
24 changes: 21 additions & 3 deletions frontend/src/__tests__/App.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,34 @@ describe('App mobile menu', () => {
})

describe('App top bar', () => {
// Refresh and Settings land in the slot on a phone; with the bell they form one evenly spaced
// group, the slot coming first so the bell stays at the far end.
// On a phone the page's own buttons and then Settings land in the slots; with the bell they form
// one evenly spaced group, the slots coming first so the bell stays at the far end.
it('keeps the bell in one group with the teleported buttons, after them', async () => {
const wrapper = await mountAt('/')

const group = wrapper.find('.mobile-topbar__actions')
const children = group.element.children
expect(children[0]?.id).toBe('mobile-topbar-actions')
expect(children[0]?.id).toBe('mobile-topbar-page-actions')
expect(children[1]?.id).toBe('mobile-topbar-actions')
expect(children[children.length - 1]?.classList.contains('notif-bell')).toBe(true)
})

// The page's heading takes the room the app's car icon had: home is in the menu.
it('gives the page heading the bar beside the menu button', async () => {
const wrapper = await mountAt('/')

const bar = wrapper.get('.mobile-topbar').element.children
expect(bar[0]?.classList.contains('hamburger')).toBe(true)
expect(bar[1]?.id).toBe('mobile-topbar-title')
})

// Refresh moves next to the time it renews, which stays in the page while it hides, so the
// button moved into it is never left in a removed line.
it('keeps a place for Refresh on the fetched line of the menu', async () => {
const wrapper = await mountAt('/')

expect(wrapper.find('.sidebar-timestamp #sidebar-refresh').exists()).toBe(true)
})
})

describe('App menu', () => {
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/__tests__/inlineTeleport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineComponent, h } from 'vue'

/**
* A stand-in for Teleport that renders its content in place, for a spec that wants a dialog
* inside its wrapper. Use it rather than `teleport: true`: that stub is a new component on every
* render, so whatever sits inside a Teleport (ViewHeader's actions, with their open filter
* dialog) is rebuilt each time the page around it updates, and a spec ends up typing into a
* dialog that is gone.
*/
export const InlineTeleport = defineComponent({
name: 'InlineTeleport',
setup:
(_, { slots }) =>
() =>
h('div', { class: 'inline-teleport' }, slots.default?.()),
})
20 changes: 3 additions & 17 deletions frontend/src/assets/editMode.css
Original file line number Diff line number Diff line change
Expand Up @@ -220,27 +220,13 @@
border-radius: calc(var(--touch-target) / 2);
}

/* Room under the page for the bar, so it never covers the last card. */
.view-container:has(.edit-layout-btn--editing) {
/* Room under the page for the bar, so it never covers the last card. Asked of the whole layout,
as on a phone the edit button sits in the top bar rather than in the page. */
.app-layout:has(.edit-layout-btn--editing) .view-container {
padding-bottom: calc(var(--touch-target) + 3rem);
}
}

/* 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
67 changes: 43 additions & 24 deletions frontend/src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -980,56 +980,75 @@ body,
display: flex;
}

/* The footer's row goes back to the page: AppFooter moves Refresh and Settings into the top
bar and the copyright and update notice into the menu. */
/* The footer's row goes back to the page: AppFooter moves Settings into the top bar, Refresh
into the menu beside the time it renews, and the copyright and update notice into the menu. */
.app-footer {
display: none;
}

.mobile-topbar .app-footer__actions {
display: flex;
align-items: center;
gap: var(--topbar-gap);
}

/* Drawn like the bell beside them: an icon, no box. */
.mobile-topbar .app-footer__btn {
/* The top bar's buttons (the page's own from ViewHeader, then Settings) and Refresh in the menu
are drawn like the bell: an icon in a touch-sized square, no box. A page button's words stay
for screen readers and in its tooltip. */
.mobile-topbar .app-footer__btn,
.mobile-topbar .view-header__actions .btn,
.sidebar-timestamp__action .app-footer__btn {
width: var(--touch-target);
height: var(--touch-target);
padding: 0;
justify-content: center;
background: none;
border: none;
border-radius: 6px;
color: var(--color-text-muted);
font-size: var(--topbar-icon-size);
}

.mobile-topbar .app-footer__btn:hover {
.mobile-topbar .app-footer__btn:hover,
.mobile-topbar .view-header__actions .btn:hover,
.sidebar-timestamp__action .app-footer__btn:hover {
background: var(--color-surface-2);
color: var(--color-text);
}

/* Add keeps the accent it has as a page's main button, and Live its green while on. */
.mobile-topbar .view-header__actions .btn-primary {
color: var(--color-primary-light);
}

.mobile-topbar .app-footer__btn-label {
.mobile-topbar .view-header__actions .btn[aria-pressed='true'] {
color: var(--color-success);
}

.mobile-topbar .app-footer__btn-label,
.sidebar-timestamp__action .app-footer__btn-label {
display: none;
}

/* The page's actions keep the small button's text and padding (their height stays the touch
target), so three of them still fit beside a short title such as the map's. */
.view-header__actions .btn {
font-size: 0.78rem;
padding-inline: 0.65rem;
.mobile-topbar .btn__label {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}

/* 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;
/* A filter count sits on the icon's corner, as the bell's count does. */
.mobile-topbar .toolbar-panel__btn .toolbar-panel__count {
top: 2px;
right: 2px;
transform: none;
border-color: var(--color-surface);
}

.view-header__caption {
margin: 0;
/* The dashboard's refresh spinner floats beside the actions, which in the top bar would put it
on the title; Refresh in the menu spins instead. */
.mobile-topbar .refresh-indicator {
display: none;
}

/* With no caption and no actions left, the row would be an empty band above the first card. */
/* With its heading, caption and actions in the top bar, a page's own row would be an empty band
above the first card. */
.view-header:not(:has(.view-header__caption, .view-header__actions > *)) {
display: none;
}
Expand Down
64 changes: 44 additions & 20 deletions frontend/src/assets/shell.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
flex-shrink: 0;
}

/* Refresh and Settings (teleported in by AppFooter) and the bell, as one group. */
/* The page's own buttons (teleported in by ViewHeader), Settings (by AppFooter) and the bell, as
one group. */
.mobile-topbar__actions {
display: flex;
align-items: center;
Expand All @@ -76,30 +77,36 @@
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;
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;
/* The page's heading, with its caption as a second line under it (ViewHeader moves both here on
a phone). Each keeps to 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-brand:hover {
background: var(--color-surface-2);
.mobile-topbar__title .view-header__heading {
display: flex;
flex-direction: column;
min-width: 0;
}

/* 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;
.mobile-topbar__title .view-header__caption {
min-width: 0;
margin: 0;
font-size: 0.75rem;
line-height: 1.2;
}

.mobile-topbar__title .view-header__caption span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

/* The page's buttons join the bar's own row of buttons, with its gap. */
.mobile-topbar .view-header__actions {
display: contents;
}

.mobile-topbar__title h1 {
Expand All @@ -118,9 +125,11 @@
gap: 0;
}

/* Its negative block margin keeps the 28px hit area from spacing the caption off the heading. */
.mobile-topbar__title .view-header__info {
width: 28px;
height: 28px;
margin-block: -4px;
margin-left: -0.1rem;
font-size: 0.8rem;
transform: translateY(-0.55rem);
Expand Down Expand Up @@ -434,6 +443,21 @@
white-space: nowrap;
}

/* Refresh, which AppFooter moves here on a phone, at the end of the line with the time it renews.
It reaches into the line's padding, so the line grows no more than the touch target needs. */
.sidebar-timestamp__action {
display: flex;
margin-block: -0.25rem;
margin-left: auto;
margin-right: -0.5rem;
}

/* The line's own turning icon gives way to the button, which turns while a refresh runs. Its place
stays, so the text keeps in line with the lines under it. */
.sidebar-timestamp:has(.sidebar-timestamp__action > *) .sidebar-timestamp__icon {
visibility: hidden;
}

.sidebar-user__email {
white-space: nowrap;
overflow: hidden;
Expand Down
16 changes: 10 additions & 6 deletions frontend/src/components/AppFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ const copyrightLabel = ['© 2026 GarageStack', APP_VERSION].filter(Boolean).join

const vin = computed(() => vehicleStore.activeVin)

// A phone hides the footer and gives its row to the page: the buttons go to the top bar and the
// copyright and update notice to the bottom of the menu (both targets are in App.vue).
// A phone hides the footer and gives its row to the page: Settings goes to the top bar, Refresh to
// the menu beside the time it renews, and the copyright and update notice to the bottom of the
// menu (every target is in App.vue).
const isPhone = useMediaQuery(PHONE_MEDIA_QUERY)

function refresh() {
Expand Down Expand Up @@ -76,24 +77,27 @@ function refresh() {
</a>
</div>
</Teleport>
<Teleport defer to="#mobile-topbar-actions" :disabled="!isPhone">
<div class="app-footer__actions">
<div class="app-footer__actions">
<Teleport defer to="#sidebar-refresh" :disabled="!isPhone">
<button
v-if="canSend"
class="app-footer__btn"
:aria-label="t('control.refresh')"
:title="t('control.refresh')"
:disabled="vehicleStore.loading || sending === 'refresh' || !vin"
@click="refresh"
>
<font-awesome-icon icon="rotate" :spin="vehicleStore.loading || sending === 'refresh'" />
<span class="app-footer__btn-label">{{ t('control.refresh') }}</span>
</button>
</Teleport>
<Teleport defer to="#mobile-topbar-actions" :disabled="!isPhone">
<button class="app-footer__btn" :aria-label="t('settings.title')" @click="openModal">
<font-awesome-icon icon="gear" />
<span class="app-footer__btn-label">{{ t('settings.title') }}</span>
</button>
</div>
</Teleport>
</Teleport>
</div>
</footer>

<component :is="settingsModal" v-if="settingsModal" :open="modalOpen" @close="closeModal" />
Expand Down
Loading
Loading