mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
fix(desktop): restore zoom on timeline text via rem tokens
Cmd +/- zoom scales the root <html> font-size (rem-only by design), but PR #891 converted the message-timeline + thread render path from rem tokens to hardcoded px (text-[15px]/text-[13px], font-size: 15px), freezing that text against zoom. Preserve Kenny's 15px chat sizing intent but express it in rem so it scales: add rem-based `text-chat` (0.9375rem === 15px) and `text-code` (0.8125rem === 13px) Tailwind tokens, and swap the px classes over in MessageRow, markdown, mentionChip, and globals.css (.mention-highlight). Codify it: add `pnpm check:px-text` CI guard flagging new px text in the timeline/thread render path, wired into `pnpm check`, plus an AGENTS.md note steering future agents to rem tokens. Scoped to the regression footprint — no app-wide sweep. Co-authored-by: Taylor Ho <taylorkmho@gmail.com> Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
This commit is contained in:
co-authored by
Taylor Ho
parent
9ee5aeebd9
commit
bfb892c985
@@ -8,8 +8,9 @@
|
||||
"build": "tsc && vite build",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"check:file-sizes": "node ./scripts/check-file-sizes.mjs",
|
||||
"check:px-text": "node ./scripts/check-px-text.mjs",
|
||||
"lint": "biome lint .",
|
||||
"check": "biome check . && pnpm check:file-sizes",
|
||||
"check": "biome check . && pnpm check:file-sizes && pnpm check:px-text",
|
||||
"format": "biome format --write .",
|
||||
"test": "node --import ./test-loader.mjs --experimental-strip-types --test 'src/**/*.test.mjs'",
|
||||
"preview": "vite preview",
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { runPxTextCheck } from "../../scripts/check-px-text-core.mjs";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const projectRoot = path.resolve(__dirname, "..");
|
||||
|
||||
// Scoped to the message-timeline / thread render path — the surface where the
|
||||
// rem→px zoom regression (PR #891) landed. Readable message text here MUST use
|
||||
// rem-based tokens (`text-chat`, `text-code`) so Cmd +/- zoom scales it. We
|
||||
// intentionally do NOT sweep the whole app yet (decorative chrome — avatar
|
||||
// initials, day dividers, diff-viewer labels — still uses px); widen these
|
||||
// roots when that sweep happens.
|
||||
const rules = [
|
||||
{
|
||||
root: "src/shared/ui",
|
||||
extensions: new Set([".ts", ".tsx"]),
|
||||
files: new Set(["markdown.tsx", "mentionChip.ts"]),
|
||||
},
|
||||
{
|
||||
root: "src/features/messages/ui",
|
||||
extensions: new Set([".tsx"]),
|
||||
files: new Set(["MessageRow.tsx"]),
|
||||
},
|
||||
{
|
||||
// `.mention-highlight` lives here and was part of the #891 px regression —
|
||||
// guard the `font-size: NNpx` form too, not just the Tailwind utility.
|
||||
root: "src/shared/styles",
|
||||
extensions: new Set([".css"]),
|
||||
files: new Set(["globals.css"]),
|
||||
},
|
||||
];
|
||||
|
||||
// Decorative / chrome px-text exceptions: `relativePath:lineNumber`. Empty for
|
||||
// now — the regression footprint is fully on rem tokens.
|
||||
const overrides = new Set();
|
||||
|
||||
await runPxTextCheck({
|
||||
projectRoot,
|
||||
rules,
|
||||
overrides,
|
||||
label: "Desktop",
|
||||
scriptPath: "desktop/scripts/check-px-text.mjs",
|
||||
});
|
||||
@@ -188,7 +188,7 @@ export const MessageRow = React.memo(
|
||||
<Markdown
|
||||
channelNames={channelNames}
|
||||
className={cn(
|
||||
"max-w-full text-[15px] leading-6",
|
||||
"max-w-full text-chat",
|
||||
emojiOnly &&
|
||||
"text-4xl leading-tight [&_img[data-custom-emoji]]:h-[1.45em] [&_img[data-custom-emoji]]:align-middle [&_button:has(img[data-custom-emoji])]:align-middle",
|
||||
)}
|
||||
@@ -245,11 +245,11 @@ export const MessageRow = React.memo(
|
||||
);
|
||||
|
||||
const authorNode = message.pubkey ? (
|
||||
<span className="truncate text-[15px] font-semibold leading-none tracking-tight hover:underline">
|
||||
<span className="truncate text-chat font-semibold leading-none tracking-tight hover:underline">
|
||||
{message.author}
|
||||
</span>
|
||||
) : (
|
||||
<h3 className="truncate text-[15px] font-semibold leading-none tracking-tight">
|
||||
<h3 className="truncate text-chat font-semibold leading-none tracking-tight">
|
||||
{message.author}
|
||||
</h3>
|
||||
);
|
||||
|
||||
@@ -615,7 +615,8 @@
|
||||
border-radius: 4px;
|
||||
background: hsl(var(--primary) / 0.15);
|
||||
padding: 3px 4px 2px;
|
||||
font-size: 15px;
|
||||
/* 0.9375rem === 15px; rem so it scales with the root-font-size zoom. */
|
||||
font-size: 0.9375rem;
|
||||
line-height: 1;
|
||||
color: hsl(var(--primary));
|
||||
font-weight: 500;
|
||||
|
||||
@@ -78,7 +78,7 @@ const MAX_CACHE_ENTRIES = 100;
|
||||
const MAX_LOADED_LANGUAGES = 30;
|
||||
const MAX_HIGHLIGHT_LINES = 150;
|
||||
const CODE_BLOCK_CLASS =
|
||||
"code-block-lines block min-w-full whitespace-pre font-mono text-[13px] leading-6 text-foreground";
|
||||
"code-block-lines block min-w-full whitespace-pre font-mono text-code text-foreground";
|
||||
const DIFF_ADD_RE = /\s*\/\/\s*\[!code\s*\+\+\]\s*$/;
|
||||
const DIFF_REMOVE_RE = /\s*\/\/\s*\[!code\s*--\]\s*$/;
|
||||
|
||||
@@ -850,7 +850,7 @@ function createMarkdownComponents(
|
||||
<code
|
||||
{...props}
|
||||
className={cn(
|
||||
"rounded-md bg-muted px-1.5 py-0.5 font-mono text-[13px] text-foreground",
|
||||
"rounded-md bg-muted px-1.5 py-0.5 font-mono text-code text-foreground",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
@@ -1221,7 +1221,7 @@ function MarkdownInner({
|
||||
].join(" ")
|
||||
: compact
|
||||
? [
|
||||
"max-w-none break-words text-[15px] leading-6 text-foreground/90",
|
||||
"max-w-none break-words text-chat text-foreground/90",
|
||||
"[&>*:first-child]:mt-0 [&>*:last-child]:mb-0",
|
||||
"[&>*+*]:mt-2",
|
||||
"[&>*+h1]:mt-3 [&>*+h2]:mt-3 [&>*+h3]:mt-3",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export const MENTION_CHIP_BASE_CLASSES =
|
||||
"inline-block rounded-[4px] bg-primary/15 px-1 pt-[3px] pb-[2px] text-[15px] font-medium leading-none text-primary";
|
||||
"inline-block rounded-[4px] bg-primary/15 px-1 pt-[3px] pb-[2px] text-chat font-medium leading-none text-primary";
|
||||
|
||||
export const MENTION_CHIP_HOVER_CLASSES =
|
||||
"transition-colors hover:bg-primary/25 hover:text-primary/90";
|
||||
|
||||
@@ -2,6 +2,15 @@
|
||||
export default {
|
||||
theme: {
|
||||
extend: {
|
||||
fontSize: {
|
||||
// Chat body/author sizing. 15px sits between Tailwind's stock
|
||||
// `text-sm` (14px) and `text-base` (16px), so we express it as a rem
|
||||
// token instead of a hardcoded px value — px would not scale with the
|
||||
// root-font-size zoom (Cmd +/-). 0.9375rem === 15px at the 16px root.
|
||||
chat: ["0.9375rem", { lineHeight: "1.5rem" }],
|
||||
// Inline & block code inside chat messages (13px → 0.8125rem).
|
||||
code: ["0.8125rem", { lineHeight: "1.5rem" }],
|
||||
},
|
||||
borderRadius: {
|
||||
lg: "var(--radius)",
|
||||
md: "calc(var(--radius) - 2px)",
|
||||
|
||||
Reference in New Issue
Block a user