Top bar: scale a wide custom logo down on a phone instead of cutting it off #125
No files matched your search
@@ -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/);
|
||||
});
|
||||
});
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user