From f0b944b6829f42fef561722ebedea3f435f30d96 Mon Sep 17 00:00:00 2001 From: arthur-lzrs <55158951+arthur-lzrs@users.noreply.github.com> Date: Fri, 27 Nov 2026 14:24:35 -0300 Subject: [PATCH] feat: resize the dashboard overview and map in the layout editor On a phone the dashboard's car diagram and location map stand one above the other, and the diagram is tall. There was no way to give the map more of the screen. In the dashboard's layout editor on a phone, the car diagram and the location map each get a pair of magnifier buttons (minus and plus). The car goes from standard to three smaller sizes, the map from standard to two taller ones. Making the car smaller shrinks the drawing and the readings over it together, the text less than the drawing so it stays legible. The sizes are kept per device and standard is the layout as it was, so nothing changes until a button is used. Beside the sidebar the two cards stand side by side, so the buttons are not offered. Sizes are CSS custom properties (--car-scale, --car-text-scale, --map-min-height) set by a class on the dashboard, so they stay within the Content-Security-Policy. A smaller car also lets go of the 320 px flex-basis its box has in the phone's column, which would otherwise keep the room of a shrunk card empty. EditableCardSlot gets a "controls" slot, which EditableCardGrid forwards, and CardSizeControl fills it. A button at the end of its range is aria-disabled rather than disabled, so a key or a finger that has just taken the last step keeps its focus. overviewCarSize and overviewMapHeight are local to the device, so they are not synced to the account. Co-Authored-By: Claude Sonnet 5.5 --- README.md | 2 +- frontend/src/assets/carDiagram.css | 26 +-- frontend/src/assets/dashboard.css | 39 +++- frontend/src/assets/editMode.css | 38 ++++ frontend/src/components/CardSizeControl.vue | 50 +++++ frontend/src/components/EditableCardGrid.vue | 9 +- frontend/src/components/EditableCardSlot.vue | 2 + .../__tests__/CardSizeControl.spec.ts | 48 +++++ frontend/src/locales/en.json | 2 + frontend/src/locales/es.json | 2 + frontend/src/locales/nl.json | 2 + frontend/src/locales/pt-PT.json | 2 + frontend/src/locales/pt.json | 2 + frontend/src/plugins/icons.ts | 2 + .../stores/__tests__/settingsStores.spec.ts | 47 +++++ .../src/stores/__tests__/settingsSync.spec.ts | 22 +++ frontend/src/stores/settingsUi.ts | 31 ++- frontend/src/views/DashboardView.vue | 61 +++++- .../src/views/__tests__/DashboardView.spec.ts | 181 +++++++++++++++++- 19 files changed, 548 insertions(+), 20 deletions(-) create mode 100644 frontend/src/components/CardSizeControl.vue create mode 100644 frontend/src/components/__tests__/CardSizeControl.spec.ts diff --git a/README.md b/README.md index e57d5279..f2ec506e 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ The map behind the dashboard, the layout editor, the offline view, the HV batter ### Dashboard cards -Cards are shown or hidden automatically based on vehicle type (HEV / PHEV / BEV). You can also reorder and toggle individual cards in the dashboard's edit mode. +Cards are shown or hidden automatically based on vehicle type (HEV / PHEV / BEV). You can also reorder and toggle individual cards in the dashboard's edit mode. On a phone, where the car overview and the location map stand one above the other, the edit mode shows magnifier buttons (**+** and **-**) over each of them: make the overview smaller (in three steps) and the map taller (in two). Making the overview smaller shrinks the car drawing and the readings over it together (the text a little less, to stay legible), so the map can have the room. Both are kept per device, and the standard size is the layout the dashboard has always had. | Card | Description | Vehicle types | | ---- | ----------- | ------------- | diff --git a/frontend/src/assets/carDiagram.css b/frontend/src/assets/carDiagram.css index 6d66d851..f050404a 100644 --- a/frontend/src/assets/carDiagram.css +++ b/frontend/src/assets/carDiagram.css @@ -84,7 +84,7 @@ position: absolute; top: 0; right: 0; - width: 80px; + width: calc(80px * var(--car-scale, 1)); pointer-events: auto; user-select: none; z-index: 1; @@ -161,11 +161,13 @@ justify-content: center; } -/* SVG viewBox is 420×480 (widened for 3-lane road); max-width keeps it on small screens */ +/* SVG viewBox is 420×480 (widened for 3-lane road); max-width keeps it on small screens. The + dashboard's --car-scale (a phone's smaller overview, see dashboard.css) shrinks the drawing, and + with it everything laid over it by percentage. */ .tyre-car-wrap { position: relative; display: inline-block; - width: 300px; + width: calc(300px * var(--car-scale, 1)); max-width: 100%; } @@ -203,12 +205,14 @@ pointer-events: none; } +/* What is written over the drawing shrinks with it by --car-text-scale, which falls more slowly than + --car-scale so the readings stay legible. */ .tyre-label { position: absolute; - font-size: 0.68rem; + font-size: calc(0.68rem * var(--car-text-scale, 1)); font-weight: 600; font-variant-numeric: tabular-nums; - padding: 2px 5px; + padding: calc(2px * var(--car-text-scale, 1)) calc(5px * var(--car-text-scale, 1)); border-radius: 4px; background: var(--color-surface); border: 1px solid var(--color-border); @@ -297,14 +301,14 @@ transform: translateX(-50%); display: flex; align-items: center; - gap: 0.35rem; - font-size: 0.85rem; + gap: calc(0.35rem * var(--car-text-scale, 1)); + font-size: calc(0.85rem * var(--car-text-scale, 1)); font-weight: 700; color: var(--color-text); background: var(--color-surface); border: 1px solid currentcolor; border-radius: 20px; - padding: 3px 10px; + padding: calc(3px * var(--car-text-scale, 1)) calc(10px * var(--car-text-scale, 1)); white-space: nowrap; pointer-events: auto; user-select: none; @@ -474,15 +478,15 @@ .car-badge { position: absolute; - width: 26px; - height: 26px; + width: calc(26px * var(--car-text-scale, 1)); + height: calc(26px * var(--car-text-scale, 1)); border-radius: 50%; background: var(--color-warning); color: #000; display: flex; align-items: center; justify-content: center; - font-size: 0.65rem; + font-size: calc(0.65rem * var(--car-text-scale, 1)); pointer-events: auto; user-select: none; border: 2px solid var(--color-surface); diff --git a/frontend/src/assets/dashboard.css b/frontend/src/assets/dashboard.css index 72ba71be..0e823e15 100644 --- a/frontend/src/assets/dashboard.css +++ b/frontend/src/assets/dashboard.css @@ -29,6 +29,43 @@ .overview-row__map { max-width: none; } + + /* The car's flex-basis is a width beside the map, but on a phone's column it is a height, a floor + of 320px that would keep a shrunk card's box that tall with the room left empty. A smaller + car lets go of it; standard keeps it, so the standard layout is as it was. */ + .dashboard--car-small .overview-row__car, + .dashboard--car-smaller .overview-row__car, + .dashboard--car-smallest .overview-row__car { + flex-basis: auto; + } + + /* The overview's two cards stand one above the other on a phone, so a phone can trade height + between them (the magnifier buttons over each card in the layout editor): a smaller car + drawing, and with it the readings over it, makes room for a taller map. --car-text-scale + falls more slowly than --car-scale so the pressures and badges stay legible. Standard is no + class at all. */ + .dashboard--car-small { + --car-scale: 0.8; + --car-text-scale: 0.94; + } + + .dashboard--car-smaller { + --car-scale: 0.62; + --car-text-scale: 0.86; + } + + .dashboard--car-smallest { + --car-scale: 0.48; + --car-text-scale: 0.8; + } + + .dashboard--map-tall { + --map-min-height: 240px; + } + + .dashboard--map-taller { + --map-min-height: 300px; + } } /* Edit mode wraps each slot in extra card-slot/card-slot__content layers, which @@ -82,7 +119,7 @@ .location-map-card__map { position: relative; flex: 1; - min-height: 180px; + min-height: var(--map-min-height, 180px); border-radius: var(--radius); overflow: hidden; cursor: pointer; diff --git a/frontend/src/assets/editMode.css b/frontend/src/assets/editMode.css index 870afb4c..2aa5626b 100644 --- a/frontend/src/assets/editMode.css +++ b/frontend/src/assets/editMode.css @@ -139,6 +139,44 @@ color: var(--color-on-success); } +/* The magnifier buttons that make a card larger or smaller (CardSizeControl.vue), in the card's + bottom corner. Inside the card rather than over its edge, so they never cover the card below. */ +.card-slot__size { + position: absolute; + right: 0.5rem; + bottom: 0.5rem; + display: flex; + background: var(--color-surface); + border: 1px solid var(--color-border); + border-radius: calc(var(--touch-target) / 2); + box-shadow: 0 2px 8px var(--shadow-pop); + z-index: 2; +} + +.card-slot__size-btn { + display: flex; + align-items: center; + justify-content: center; + width: var(--touch-target); + height: var(--touch-target); + border: 0; + border-radius: 50%; + background: transparent; + color: var(--color-text); + font-size: 1rem; + cursor: pointer; +} + +.card-slot__size-btn:hover:not([aria-disabled='true']) { + background: var(--color-surface-2); +} + +.card-slot__size-btn[aria-disabled='true'] { + color: var(--color-text-muted); + opacity: 0.4; + cursor: default; +} + /* Placeholder for hidden or data-less cards in edit mode */ .card-slot__placeholder { background: var(--color-surface); diff --git a/frontend/src/components/CardSizeControl.vue b/frontend/src/components/CardSizeControl.vue new file mode 100644 index 00000000..a087c4d3 --- /dev/null +++ b/frontend/src/components/CardSizeControl.vue @@ -0,0 +1,50 @@ + + + diff --git a/frontend/src/components/EditableCardGrid.vue b/frontend/src/components/EditableCardGrid.vue index 460ed57a..2d4be39e 100644 --- a/frontend/src/components/EditableCardGrid.vue +++ b/frontend/src/components/EditableCardGrid.vue @@ -15,7 +15,11 @@ defineProps<{ defineEmits<{ 'toggle-visible': [item: T] }>() -defineSlots<{ default(props: { item: T }): unknown }>() +defineSlots<{ + default(props: { item: T }): unknown + /** Buttons over the card, for what only some grids offer (the dashboard's sizes). */ + controls?(props: { item: T }): unknown +}>() diff --git a/frontend/src/components/EditableCardSlot.vue b/frontend/src/components/EditableCardSlot.vue index b8fb0899..3f1f4202 100644 --- a/frontend/src/components/EditableCardSlot.vue +++ b/frontend/src/components/EditableCardSlot.vue @@ -24,6 +24,8 @@ defineEmits<{ 'toggle-visible': [] }>()
+ +