Skip to content

Commit 9a34045

Browse files
committed
Enlarge shortlist touch target
1 parent 09b40fa commit 9a34045

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎site/public/styles.css‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,10 @@ input:focus-visible,
560560
/* "Open source" and "Entry and evidence" sit inside the card-wide title
561561
link, so a near miss opened the entry page. Padding cancelled by an
562562
equal negative margin grows each to about 44px without moving a thing. */
563-
.entry-links a {
563+
.entry-links a,
564+
.entry-links button {
564565
display: inline-block;
566+
min-height: 44px;
565567
padding: 13px 6px;
566568
margin: -13px -6px;
567569
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import assert from "node:assert/strict";
2+
import fs from "node:fs";
3+
4+
const css = fs.readFileSync(new URL("./public/styles.css", import.meta.url), "utf8");
5+
const touchRules = css.match(/@media\s*\(pointer:\s*coarse\)\s*\{([\s\S]*?)\n\}/)?.[1] ?? "";
6+
const targetRule = touchRules.match(/([^{}]+)\{([^{}]*)\}/g)?.find((rule) =>
7+
rule.split("{")[0].includes(".entry-links button")
8+
);
9+
assert.ok(targetRule, "coarse-pointer styles must include .entry-links button");
10+
const declarations = Object.fromEntries(
11+
[...targetRule.split("{")[1].matchAll(/([\w-]+):\s*([^;]+);/g)].map(([, name, value]) => [name, value.trim()])
12+
);
13+
assert.equal(Number.parseFloat(declarations["min-height"]), 44, "shortlist hit area must be at least 44px tall");
14+
15+
const padding = declarations.padding?.match(/^(-?\d+(?:\.\d+)?)px\s+(-?\d+(?:\.\d+)?)px$/);
16+
const margin = declarations.margin?.match(/^(-?\d+(?:\.\d+)?)px\s+(-?\d+(?:\.\d+)?)px$/);
17+
assert.ok(padding && margin, "touch target padding and margin must use pixel values");
18+
assert.equal(Number(padding[1]) + Number(margin[1]), 0, "vertical padding and margin must cancel to preserve layout");
19+
assert.equal(Number(padding[2]) + Number(margin[2]), 0, "horizontal padding and margin must cancel to preserve layout");

0 commit comments

Comments
 (0)