Skip to content

feat: resize the dashboard overview and map in the layout editor - #776

Open
arthur-lzrs wants to merge 1 commit into
joszz:mainfrom
arthur-lzrs:feat/overview-height
Open

arthur-lzrs wants to merge 1 commit into
joszz:mainfrom
arthur-lzrs:feat/overview-height

Conversation

@arthur-lzrs

Copy link
Copy Markdown
Contributor

Summary

On a phone the dashboard's car diagram and location map stand one above the other, and the diagram is tall. There is no way to give the map more of the screen.

In the dashboard's layout editor (long press a card, or Edit layout), on a phone, the car diagram and the location map each get a pair of magnifier buttons (minus and plus) in their corner:

  • The car goes from standard to three smaller sizes (about 80%, 62% and 48% of the drawing, which is 410, 341, 280 and 232 px of card height on a 375 px phone). Making it smaller shrinks the drawing and everything laid over it (tyre pressures, charge badge, speed gauge) together. The text shrinks less than the drawing so the readings stay legible.
  • The map goes from standard to two taller ones (180, 240 and 300 px of map).
  • The result shows at once, in the layout being edited. A button at the end of its range is dimmed.
  • Kept per device. 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 there (and nothing is applied).

I first made this a setting under Settings > General > Appearance, but sizing a card belongs where the cards are rearranged, and buttons need no names for the levels.

How it works

  • The sizes are CSS custom properties (--car-scale, --car-text-scale, --map-min-height) switched by a class on the dashboard. No inline styles, so the Content-Security-Policy is untouched. They are defined for phones only (width <= 767px), the same query as PHONE_MEDIA_QUERY, and everything that reads them has the old value as its fallback.
  • In a phone's column, the car card's flex: 2 1 320px is a height, a floor of 320 px, so a shrunk card's box would stay that tall with the room empty. The smaller sizes let go of it (flex-basis: auto); standard keeps it.
  • EditableCardSlot gets a controls slot, which EditableCardGrid forwards, and the new CardSizeControl fills it. The statistics view uses the same components and passes nothing, so it is unchanged.
  • 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 in the UI settings and listed in localKeys, so they stay on the device and are not synced to the account. A stored value that is not one of the sizes reads as standard.

Type of Change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation
  • Dependency update
  • Other

Related Issues

None.

How it was tested

  • Unit tests for the buttons (the component, and in the dashboard: only on a phone, only on a shown card, the steps both ways and where they stop, the result at once), for the size classes the dashboard sets, and for the settings staying on the device (parse, fallback, sync).
  • Demo mode, in the browser at 375 px wide and at 320 px: every size, the layout editor, no horizontal scroll, the labels over the drawing legible and not overlapping at the smallest size.
  • On a real iPhone, with the real data of two cars.

Notes for review

  • The levels are a few numbers in dashboard.css (--car-scale, --car-text-scale, --map-min-height) and the two lists in settingsUi.ts, easy to tune or extend.
  • The map's attribution sits under the buttons while editing only; it is back when editing is done.
  • Translations: the labels in nl, es and pt-PT are my own drafts ("Make smaller" and "Make larger", read by screen readers), so a native check is welcome.
  • Merging with a sibling PR: the menu swipe PR also adds a device-local UI setting, so both touch settingsUi.ts, settingsStores.spec.ts and settingsSync.spec.ts next to the same lines. Whichever lands second needs a trivial rebase.

Checklist

  • Tests added or updated
  • Checks pass: pnpm check in frontend/ (frontend only: the .NET side is untouched, so dotnet test and dotnet format were not run)
  • Commit messages follow Conventional Commits (feat: ..., fix(frontend): ...)
  • If trips changed (ITripRepository): done in the demo too, with a step in TripRepositoryContractTests (not applicable)
  • If the API changed: the rewritten documentation/openapi.json is committed (not applicable, the API did not change)
  • New fields or features have demo data in src/GarageStack.Data/Demo/ (not applicable, the demo's dashboard already has both cards)
  • No secrets or personal data committed, and no real VIN or licence plate in test data
  • Responsive on mobile, down to 320 px wide
  • Every new UI text is an i18n key, in every file in frontend/src/locales/
  • If unraid/garagestack.xml changed: synced to joszz/unraid-community-apps after merge (not applicable, it did not change)

🤖 Generated with Claude Code

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 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant