From 42fa17f97b9f1398d294334b8b52c2be2d68aa5d Mon Sep 17 00:00:00 2001 From: John Coffey Date: Thu, 19 Nov 2026 10:59:28 -0700 Subject: [PATCH] Top bar: scale a wide custom logo down on a phone instead of cutting it off The custom logo in the top bar is 34px high and up to 180px wide. A wide wordmark asked for the full 180px, the image wouldn't shrink below its own width (a flex item's min-width), and on a phone the search field painted over the rest of it: "ARCVA" on an iPhone in portrait (#124). At phone widths the logo now has min-width 0, a 30vw cap and object-position left, so it scales down whole (object-fit: contain was already set). A square logo is under the cap and doesn't change; desktop is unchanged. Checked in Chromium at 320, 375, 440 and 900px with a wide and a square logo. Test: the phone rule, pinned. Fixes #124 --- web/src/styles/__tests__/topbar-logo.test.ts | 32 ++++++++++++++++++++ web/src/styles/app.css | 8 +++++ 2 files changed, 40 insertions(+) create mode 100644 web/src/styles/__tests__/topbar-logo.test.ts diff --git a/web/src/styles/__tests__/topbar-logo.test.ts b/web/src/styles/__tests__/topbar-logo.test.ts new file mode 100644 index 0000000..2a64a44 --- /dev/null +++ b/web/src/styles/__tests__/topbar-logo.test.ts @@ -0,0 +1,32 @@ +import { readFileSync } from "node:fs"; +import { dirname, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { describe, expect, it } from "vitest"; + +// Read off disk: `?raw` comes back empty for a stylesheet under the test runner. +const css = readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), "../app.css"), "utf8"); + +/* + * #124: a wide custom logo in the top bar was cut off on a phone, the search + * field painting over the rest. jsdom does no layout, so this pins the rule; + * the result was checked in Chromium at 320, 375 and 440px. + */ +describe("top bar custom logo on a phone", () => { + const phone = css.slice(css.indexOf("@media (max-width: 768px) {")); + const rule = phone.slice(phone.indexOf(".topbar .brand img.server-logo {")); + + it("has a phone rule for the server logo", () => { + expect(phone.indexOf(".topbar .brand img.server-logo {")).toBeGreaterThan(-1); + }); + + it("lets the logo shrink, capped by the screen, kept to the left", () => { + const body = rule.slice(0, rule.indexOf("}")); + expect(body).toMatch(/min-width:\s*0/); + expect(body).toMatch(/max-width:\s*\d+vw/); + expect(body).toMatch(/object-position:\s*left/); + }); + + it("still scales the logo whole rather than cropping it", () => { + expect(css).toMatch(/\.topbar \.brand img \{[^}]*object-fit:\s*contain/); + }); +}); diff --git a/web/src/styles/app.css b/web/src/styles/app.css index d028d5b..a0cd1c9 100644 --- a/web/src/styles/app.css +++ b/web/src/styles/app.css @@ -2254,6 +2254,14 @@ select optgroup { background-color: var(--bg-elev); color: var(--fg); } */ .topbar { padding: 0 max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left)); gap: 4px; } .topbar .brand .brand-name { display: none; } + /* + inbuxa-webmail #124: an administrator's wide wordmark asked for its full + 180px, the image wouldn't shrink below that (a flex item's min-width is + its own width), and the search field painted over the rest of it. On a + phone it's capped by the screen instead and scaled down whole, kept to + the left; a square logo is under the cap and doesn't change. + */ + .topbar .brand img.server-logo { min-width: 0; max-width: 30vw; object-position: left center; } .searchbar .search-input { height: 40px; } /* On a phone the search field is only what's left between the menu, logo -- 2.54.0