Follow the browser's text size instead of sliding out from under it
Every length in this stylesheet that isn't a structural clearance is in `rem`. That is the right way round — it means the page follows the browser's font size, which is what a phone's text-size slider changes — and it means there was a whole axis of behaviour that 320 audits had never once touched, because every one of them ran at the default 16px. The sweep gets a third pass: the same surfaces on the eight phone-shaped viewports at 20px of root text, which is 125% on an Android slider. Everything it found on its first run was caught by a check that had been sitting there for months with nothing to say. The page slid sideways. Three header buttons that will not break and will not shrink — `white-space: nowrap` and a `min-width: auto` floor apiece — were told `flex-wrap: nowrap`, so when they stopped fitting they had nowhere to go: "Resolve Pot" ended 23px past the right edge of a 360px window and put a horizontal scrollbar under the whole document; at 24px, 60px past the edge of a 390px one. They take a second row now on the day they need one, and still fit on the first and still grow into it at any ordinary size. Figures painted over the seat next door. Which of the two type steps an amount got was decided by counting characters — eight for one, ten for the other — which is a guess at how wide a figure is that happens to hold at one text size and one puck width. At 20px on a 44px puck, "$1,200" is six characters, took no step at all, and wanted 38px of the 34 it had. Render.fitAmounts measures now, in the batched passes fitSeatNames already uses, and takes the separators out before it takes a step of type: "$1200" at full size beats "$1,200" at three-quarters of it. And the pucks grew, which the ring cannot answer. The row heights are px tokens so an amount stepping its type down shortens its digits and not its row — but a token is a floor, not a ceiling. At 125% the puck went from 55px tall to 65 and twelve of them came down on each other, because at the 44px floor a thumb needs there is nowhere narrower to search. The two sizes a puck is written at are capped at exactly the sizes they have always been drawn at, so nothing changes for anybody at an ordinary text size — and the felt is a diagram, so the rule that already governed a puck's width now governs its height. Roomy pucks are exempt; they have the room. The same figure is in Standings in full, at whatever size its owner asked for. Two smaller things on the way. The landscape rail opened at its top, so its overflow came off the bottom — where Cancel and Raise to are; it opens at the end now, which is the same reason it is anchored low at all. And the check that called those buttons unreachable was wrong: the rail scrolls on purpose, and a sweep that cries wolf is a sweep nobody reads. 418 audits, clean. One shape it is not held to, with the arithmetic in runUiAudit.js: twelve players all-in on a 360x640 phone leaves the felt 290x163 once the bar has taken 283px of the 640, and twelve 44x62 pucks do not fit around an ellipse 163px deep. Reported as a note every run rather than a failure every run. 1026 unit tests. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015bnp7xKUPFFSpwkYNFaPgb
This commit is contained in:
@@ -1017,6 +1017,53 @@ lose. Chromium and Safari answer silently on their own engagement heuristics; Fi
|
||||
asks. A no is not an error worth reporting at a table, so the only thing that changes is
|
||||
how confident Save & reset is allowed to sound, and whether it offers the ask as a button.
|
||||
|
||||
## The sweep had never once been run at a size anybody sets
|
||||
|
||||
Every length in `holdem.css` that isn't a structural clearance is in `rem`. That is the
|
||||
right way round: it means the whole page follows the browser's font size, which is what
|
||||
a phone's text-size slider changes. It also means the page had a whole axis of behaviour
|
||||
that 320 audits had never touched, because every one of them ran at the default 16px.
|
||||
|
||||
A third pass now runs the same surfaces on the eight phone-shaped viewports with the
|
||||
root at **20px** — the 125% an Android accessibility slider gives you. It found four
|
||||
things on its first run, and every check that caught them was already written:
|
||||
|
||||
- **The page slid sideways.** `#holdemHeaderActions` was `flex-wrap: nowrap` with three
|
||||
`white-space: nowrap` labels inside it, so when they stopped fitting they had nowhere
|
||||
to go: "Resolve Pot" ended 23px past the right edge of a 360px window and put a
|
||||
horizontal scrollbar under the whole document. At 24px it was 60px past the edge of a
|
||||
390px one. `page never scrolls sideways` had been in the audit for months and had never
|
||||
had anything to say.
|
||||
- **Figures painted over the seat next door.** Which of the two type steps an amount got
|
||||
was decided by *counting characters* — eight for one, ten for the other — which is a
|
||||
guess at how wide a figure is that happens to hold at one text size and one puck width.
|
||||
At 20px, "$1,200" is six characters, took no step at all, and wanted 38px of a 34px
|
||||
puck. `Render.fitAmounts` measures now, in the same batched passes `fitSeatNames` uses,
|
||||
and takes the separators out before it takes a step of type.
|
||||
- **Pucks grew and the ring could not answer.** The row heights are `px` tokens so that
|
||||
an amount stepping its type down shortens its digits and not its row — but a token is
|
||||
a floor, not a ceiling, and text bigger than its row makes the row taller. The puck
|
||||
went from 55px to 65 and twelve of them came down on each other, because at the 44px
|
||||
floor there is nowhere narrower for the search to go. The two sizes a puck is written
|
||||
at are capped at exactly the sizes they have always been drawn at, so nothing changes
|
||||
at an ordinary text size; the felt is a diagram, and the rule that already governed a
|
||||
puck's width now governs its height. `.seatsRoomy` is exempt — those pucks have room.
|
||||
- **A check that was crying wolf.** `no control is parked where scrolling can't reach it`
|
||||
flagged the raise pad's Cancel and Raise-to in the landscape rail. The rail is
|
||||
`overflow-y: auto` on purpose and they were one flick away, so the message was untrue;
|
||||
it now asks whether a scrollable ancestor can bring the control back. What was true is
|
||||
that the rail opened at its *top*, so the overflow came off the bottom — where the two
|
||||
buttons that end a raise are. It opens at the end now, which is the same reason it is
|
||||
anchored low in the first place.
|
||||
|
||||
One shape it is not held to, with the arithmetic in `runUiAudit.js`: twelve players
|
||||
all-in on a 360x640 phone. The action bar is at its tallest there — 283px of the 640 at
|
||||
20px — and with the header that leaves the felt 290x163 where it had 296x262. Twelve
|
||||
pucks 44px wide (the floor a thumb needs) and 62px tall do not fit around an ellipse
|
||||
163px deep. That is a geometry with no answer rather than a fault with a fix, so it is
|
||||
reported as a note every run instead of a failure every run — a sweep that is always red
|
||||
stops being read.
|
||||
|
||||
## Why the hand evaluator is tested the way it is
|
||||
|
||||
`handRank.js` is the only module here that can pay the wrong person without anybody
|
||||
|
||||
@@ -79,15 +79,26 @@ describe("the spacing scale", () => {
|
||||
describe("the type scale", () => {
|
||||
// 16px — the size below which iOS zooms the page when a field is focused, so
|
||||
// every text input states it. Not a typographic choice.
|
||||
// 1.05em, 0.44rem — relative bumps inside a component, and the shrink-to-fit for
|
||||
// a six-figure stack on a 58px seat puck.
|
||||
// 9px — the floor under the same shrink-to-fit applied to a name. It is a limit
|
||||
// rather than a size: past it the word stops being legible from across a
|
||||
// table and an honest ellipsis is the better answer.
|
||||
const ALLOWED = new Set(["16px", "1.05em", "0.44rem", "9px"]);
|
||||
// 1.05em — a relative bump inside a component.
|
||||
// 9px — the floor under the seat puck's shrink-to-fit applied to a name. It is a
|
||||
// limit rather than a size: past it the word stops being legible from
|
||||
// across a table and an honest ellipsis is the better answer.
|
||||
// 10px, 12px — the ceilings on a seat puck's two sizes, which are the one place in
|
||||
// this file where type does not follow the browser's font size. Each is
|
||||
// exactly the size that row has always been drawn at, so a cap only ever
|
||||
// engages when a phone's text is turned up; see the #seatsLayer token block
|
||||
// for why a ring whose pucks are already at the 44px floor cannot answer a
|
||||
// taller row any other way. Limits rather than sizes.
|
||||
const ALLOWED = new Set(["16px", "1.05em", "9px", "10px", "12px"]);
|
||||
|
||||
// The seat puck's two sizes are custom properties that feed `font-size` through
|
||||
// `var()`, so the sweep above walks straight past them — which is exactly where a
|
||||
// raw number would end up hiding. They are held to the same scale.
|
||||
const TYPE_TOKENS = ["--seatNameSize", "--seatAmountSize"];
|
||||
|
||||
test("every font-size comes off the scale", () => {
|
||||
const offenders = valuesIn(["font-size"]).filter(v => !ALLOWED.has(v.value));
|
||||
const offenders = valuesIn(["font-size", ...TYPE_TOKENS])
|
||||
.filter(v => !ALLOWED.has(v.value));
|
||||
assert.deepEqual(offenders, [],
|
||||
"use var(--fs-2xs … --fs-2xl), or add the value to ALLOWED with a reason");
|
||||
});
|
||||
|
||||
+64
-18
@@ -110,23 +110,72 @@ async function main() {
|
||||
const warnings = [];
|
||||
let checks = 0;
|
||||
|
||||
// Twice over: once with a mouse, once with a thumb. The 44px rule stands itself
|
||||
// down where `hover: hover` says there's a pointer, and a headless desktop browser
|
||||
// is a pointer — so a single pass here has never once measured a touch target,
|
||||
// however many viewports it visited. The phone-sized ones are exactly the pass that
|
||||
// needs it.
|
||||
for (const touch of [false, true]) {
|
||||
// Three passes over the same surfaces.
|
||||
//
|
||||
// A mouse and a thumb, because the 44px rule stands itself down where `hover: hover`
|
||||
// says there's a pointer, and a headless desktop browser is a pointer — so a single
|
||||
// pass has never once measured a touch target, however many viewports it visited.
|
||||
//
|
||||
// And a thumb on a phone whose owner has turned the text up. Every length in this
|
||||
// stylesheet that isn't a structural clearance is in `rem`, which is the right way
|
||||
// round and means the whole page follows the browser's font size — including out of
|
||||
// the side of the window, which is what it was doing: at 20px, which is the 125%
|
||||
// an Android text-size slider gives you, "Resolve Pot" ran 23px off the right of a
|
||||
// 360px phone and took the document's scroll width with it. Every check in the
|
||||
// audit already knew how to catch that; not one of them had ever been run at a size
|
||||
// anybody actually sets.
|
||||
//
|
||||
// One shape it is not held to, and the arithmetic for why. Twelve players all-in on
|
||||
// a 360x640 phone is the tallest the action bar ever gets — the status block and the
|
||||
// pot breakdown both grow with the text — and at 20px it stands 283px of the 640,
|
||||
// which with the header leaves the felt 290x163 where it had 296x262. Twelve pucks
|
||||
// 44px wide (the floor a thumb needs; there is nothing narrower to go to) and 62px
|
||||
// tall do not fit around an ellipse 163px deep: two per side is all the height there
|
||||
// is, and the sweep reports it as seats 9, 10 and 11 written across each other.
|
||||
//
|
||||
// That is a geometry with no answer rather than a fault with a fix, so it is
|
||||
// reported as a note every run instead of a failure every run. A sweep that is
|
||||
// always red stops being read — the same reasoning as the 30% furniture warning.
|
||||
const CROWDED_BEYOND_HELP = "all in";
|
||||
const LARGE_TEXT_PX = 20;
|
||||
const PHONES = VIEWPORTS.filter(([w, h]) => Math.min(w, h) <= 430);
|
||||
const PASSES = [
|
||||
{ hand: "mouse", touch: false, viewports: VIEWPORTS },
|
||||
{ hand: "touch", touch: true, viewports: VIEWPORTS },
|
||||
{ hand: "large text", touch: true, viewports: PHONES, rootPx: LARGE_TEXT_PX, soft: CROWDED_BEYOND_HELP },
|
||||
];
|
||||
|
||||
for (const { hand, touch, viewports, rootPx, soft } of PASSES) {
|
||||
const context = await browser.newContext(touch
|
||||
? { hasTouch: true, isMobile: true, deviceScaleFactor: 3 }
|
||||
: {});
|
||||
// Before any of the page's own scripts, so its listener is registered first and
|
||||
// the size is in place before main.js measures anything. A stylesheet rather
|
||||
// than an inline style because that is what a browser font-size setting is: the
|
||||
// root's used size, from first paint, not something applied afterwards.
|
||||
if (rootPx) {
|
||||
await context.addInitScript((px) => {
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const style = document.createElement("style");
|
||||
style.textContent = `html { font-size: ${px}px }`;
|
||||
document.head.appendChild(style);
|
||||
}, { once: true });
|
||||
}, rootPx);
|
||||
}
|
||||
const page = await context.newPage();
|
||||
const hand = touch ? "touch" : "mouse";
|
||||
|
||||
for (const [width, height, rawLabel] of VIEWPORTS) {
|
||||
for (const [width, height, rawLabel] of viewports) {
|
||||
await page.setViewportSize({ width, height });
|
||||
|
||||
for (const [shape, seats, players, board, shoves] of TABLES) {
|
||||
const label = `${rawLabel} · ${shape} · ${hand}`;
|
||||
// Measured either way; where the shape has no answer at this text size,
|
||||
// said in the notes rather than counted against the run.
|
||||
const record = (where, offenders) => {
|
||||
if (!offenders.length) return;
|
||||
if (shape === soft) warnings.push(`${where}: ${offenders.join("; ")}`);
|
||||
else failures.push({ where, offenders });
|
||||
};
|
||||
await page.goto(`${BASE}/Casino/TexasHoldem`);
|
||||
await page.evaluate(seedTable, [seats, players, board]);
|
||||
await page.goto(`${BASE}/Casino/TexasHoldem`);
|
||||
@@ -201,7 +250,7 @@ async function main() {
|
||||
|
||||
const table = await page.evaluate(() => LayoutAudit.runAll());
|
||||
checks++;
|
||||
if (!table.clean) failures.push({ where: `table · ${label} ${width}x${height}`, offenders: table.failed.flatMap(f => f.offenders) });
|
||||
record(`table · ${label} ${width}x${height}`, table.failed.flatMap(f => f.offenders));
|
||||
table.warnings.forEach(w => warnings.push(`${label}: ${w}`));
|
||||
|
||||
// The raise pad, which is part of the bar rather than an overlay and so
|
||||
@@ -224,12 +273,8 @@ async function main() {
|
||||
const pad = await page.evaluate(() => LayoutAudit.runAll({
|
||||
occlusionSelector: "#actionBar button, #actionBar input",
|
||||
}));
|
||||
if (!pad.clean) {
|
||||
failures.push({
|
||||
where: `raise pad · ${label} ${width}x${height}`,
|
||||
offenders: pad.failed.flatMap(f => f.offenders),
|
||||
});
|
||||
}
|
||||
record(`raise pad · ${label} ${width}x${height}`,
|
||||
pad.failed.flatMap(f => f.offenders));
|
||||
await page.evaluate(() => {
|
||||
const cancel = [...document.querySelectorAll("#actionBar button")]
|
||||
.find(b => /^Cancel/.test(b.textContent.trim()));
|
||||
@@ -253,12 +298,12 @@ async function main() {
|
||||
return LayoutAudit.occlusion(`#${overlay.id} button, #${overlay.id} a, #${overlay.id} input`);
|
||||
});
|
||||
await page.evaluate(() => document.querySelectorAll("[id$='Overlay']").forEach(o => { o.hidden = true; }));
|
||||
if (result.offenders.length) failures.push({ where: `${name} · ${label} ${width}x${height}`, offenders: result.offenders });
|
||||
record(`${name} · ${label} ${width}x${height}`, result.offenders);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const [width, height, rawLabel] of VIEWPORTS.filter((_, i) => i % 4 === 0)) {
|
||||
for (const [width, height, rawLabel] of viewports.filter((_, i) => i % 4 === 0)) {
|
||||
const label = `${rawLabel} · ${hand}`;
|
||||
await page.setViewportSize({ width, height });
|
||||
await page.goto(`${BASE}/Casino/TexasHoldem/QuickSplit`);
|
||||
@@ -278,7 +323,8 @@ async function main() {
|
||||
|
||||
await browser.close();
|
||||
|
||||
console.log(`${checks} audits across ${VIEWPORTS.length} viewports, with a mouse and with a thumb`);
|
||||
console.log(`${checks} audits across ${VIEWPORTS.length} viewports — with a mouse, with a thumb, ` +
|
||||
`and with a thumb at ${LARGE_TEXT_PX}px of root text on ${PHONES.length} phones`);
|
||||
warnings.forEach(w => console.log(` note: ${w}`));
|
||||
if (failures.length === 0) {
|
||||
console.log("clean");
|
||||
|
||||
@@ -240,3 +240,118 @@ describe("and the ring checks its own measurement afterwards", () => {
|
||||
assert.equal(withBox(null, () => Render.seatBoxMoved({ width: 72, height: 56 })), false);
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe("how much room a figure has on the puck it is written on", () => {
|
||||
// The two steps of type an amount comes down used to be chosen by counting
|
||||
// characters: eight for the first, ten for the second. That is a guess at how wide a
|
||||
// figure is, and it happens to hold at one text size and one puck width.
|
||||
//
|
||||
// Turn a phone's text up — 20px of root text is what an Android slider gives you at
|
||||
// 125%, and every size in the stylesheet is in `rem` on purpose — and it stops
|
||||
// holding. Measured at 360x640 twelve-handed: the puck is at its 44px floor, which
|
||||
// is 34px of usable width, and "$1,200" is six characters, took no step at all, and
|
||||
// wanted 38. The sweep caught it as a stack figure painted over the seat next door
|
||||
// at every phone in the list, and as "ALL IN" doing the same on the all-in table.
|
||||
//
|
||||
// So it is measured. A cell is a stand-in for the real one: what it wants against
|
||||
// what it has, and a class list to write the answer into.
|
||||
const cell = (figure, wants, has) => ({
|
||||
dataset: { figure },
|
||||
textContent: figure,
|
||||
classes: new Set(),
|
||||
classList: {
|
||||
add(name) { this.owner.classes.add(name); },
|
||||
remove(name) { this.owner.classes.delete(name); },
|
||||
},
|
||||
// What the text wants is proportional to how many characters are in it and how
|
||||
// far down the ladder it has come — which is what a browser would tell us.
|
||||
get scrollWidth() {
|
||||
const step = this.classes.has("puckAmountHuge") ? 0.7
|
||||
: this.classes.has("puckAmountLong") ? 0.85 : 1;
|
||||
return Math.round((wants * this.textContent.length / figure.length) * step);
|
||||
},
|
||||
clientWidth: has,
|
||||
});
|
||||
|
||||
const make = (...args) => {
|
||||
const c = cell(...args);
|
||||
c.classList.owner = c;
|
||||
return c;
|
||||
};
|
||||
|
||||
const fit = cells => {
|
||||
const before = Render.overflowing;
|
||||
Render.overflowing = el => el.scrollWidth > el.clientWidth + 1;
|
||||
try { Render.fitAmounts(cells); } finally { Render.overflowing = before; }
|
||||
};
|
||||
|
||||
test("a figure that fits is left at the size it is meant to be read at", () => {
|
||||
const c = make("$600", 30, 34);
|
||||
fit([c]);
|
||||
assert.equal(c.textContent, "$600");
|
||||
assert.deepEqual([...c.classes], []);
|
||||
});
|
||||
|
||||
test("one that doesn't gives up its separators first", () => {
|
||||
// Grouping is a reading aid for a column of figures. This is one number on a
|
||||
// 44px puck, and a step of type costs more than the commas do.
|
||||
const c = make("$1,200", 38, 34);
|
||||
fit([c]);
|
||||
assert.equal(c.textContent, "$1200");
|
||||
assert.deepEqual([...c.classes], [], "no type step needed once the commas are out");
|
||||
});
|
||||
|
||||
test("then a step of type, and then another", () => {
|
||||
const c = make("$1,234,567", 90, 34);
|
||||
fit([c]);
|
||||
assert.equal(c.textContent, "$1234567");
|
||||
assert.deepEqual([...c.classes], ["puckAmountHuge"]);
|
||||
});
|
||||
|
||||
test("and only ever one step at a time is worn", () => {
|
||||
// The two rules have the same specificity, so a puck wearing both would be sized
|
||||
// by whichever the stylesheet happens to mention last.
|
||||
const c = make("$1,234,567", 45, 34);
|
||||
fit([c]);
|
||||
assert.equal(c.classes.has("puckAmountHuge") && c.classes.has("puckAmountLong"), false);
|
||||
});
|
||||
|
||||
test("a figure with no separators to give goes straight to the type", () => {
|
||||
// "ALL IN" is the one thing on this row that isn't a number, and it is the widest
|
||||
// — six characters and a space, at 700 weight with its letters spread apart.
|
||||
const c = make("ALL IN", 39, 34);
|
||||
fit([c]);
|
||||
assert.equal(c.textContent, "ALL IN");
|
||||
assert.deepEqual([...c.classes], ["puckAmountLong"]);
|
||||
});
|
||||
|
||||
test("a puck that went small can come back", () => {
|
||||
// Everything is measured from the figure and the size it is meant to be read at,
|
||||
// not from whatever the last render left behind. Otherwise this is a ratchet: one
|
||||
// crowded frame and the seat is small for the rest of the night.
|
||||
const c = make("$600", 30, 34);
|
||||
c.classes.add("puckAmountHuge");
|
||||
c.textContent = "$600";
|
||||
fit([c]);
|
||||
assert.deepEqual([...c.classes], []);
|
||||
});
|
||||
|
||||
test("and the grouped figure is what it comes back to", () => {
|
||||
const c = make("$1,200", 38, 34);
|
||||
fit([c]);
|
||||
assert.equal(c.textContent, "$1200");
|
||||
c.clientWidth = 96;
|
||||
fit([c]);
|
||||
assert.equal(c.textContent, "$1,200", "a wider puck should get its separators back");
|
||||
});
|
||||
|
||||
test("an empty row is not an amount", () => {
|
||||
// The pill keeps its place on a seat with nothing in the pot — that is what makes
|
||||
// every puck on the ring the same puck — and there is nothing there to fit.
|
||||
const c = make("", 0, 34);
|
||||
assert.doesNotThrow(() => fit([c]));
|
||||
assert.deepEqual([...c.classes], []);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -213,6 +213,26 @@ const LayoutAudit = {
|
||||
// accessibility tree, and because a fixed element does not move when the page does,
|
||||
// no amount of scrolling could bring it back. visibility:hidden puts it away; a
|
||||
// transform only moves it.
|
||||
// A fixed panel that scrolls is a different thing from a fixed panel that doesn't,
|
||||
// and this check could not tell them apart. The landscape rail is `overflow-y: auto`
|
||||
// on purpose — the raise pad outgrows a 360px-tall screen the moment the text is
|
||||
// turned up, and the stylesheet chose overflow over drawing controls on top of one
|
||||
// another — so a button below its fold is one flick away, not lost. Reported as
|
||||
// unreachable it is simply untrue, and a sweep that cries wolf is a sweep nobody
|
||||
// reads.
|
||||
//
|
||||
// The ancestor has to be on screen itself for this to hold, which the rail is: it
|
||||
// is `top: 0; bottom: 0`. If a scrolling panel is ever parked off the side, the
|
||||
// thing to report is the panel, not the button inside it.
|
||||
scrollableAncestor(el) {
|
||||
for (let node = el.parentElement; node; node = node.parentElement) {
|
||||
const overflow = getComputedStyle(node).overflowY;
|
||||
if ((overflow === "auto" || overflow === "scroll") &&
|
||||
node.scrollHeight > node.clientHeight + 1) return node;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
focusablesReachable() {
|
||||
const offenders = this.visibleControls()
|
||||
.filter(el => {
|
||||
@@ -225,6 +245,7 @@ const LayoutAudit = {
|
||||
const b = el.getBoundingClientRect();
|
||||
return b.top >= innerHeight || b.bottom <= 0 || b.left >= innerWidth || b.right <= 0;
|
||||
})
|
||||
.filter(el => !this.scrollableAncestor(el))
|
||||
.map(el => `${this.describe(el)} :: fixed and off-screen, so nothing can scroll to it`);
|
||||
|
||||
return { name: "no control is parked where scrolling can't reach it", offenders };
|
||||
|
||||
Reference in New Issue
Block a user