Skip to content

Anti-AI-slop design skill for Claude Code, Cursor, and Codex.

CSS

The render tier samples the right pixels; four Floor gates stop staying silent

Youssef47585e571276
diff --git a/skills/hallmark/references/gates.md b/skills/hallmark/references/gates.md
index c6cf29b..ea90667 100644
--- a/skills/hallmark/references/gates.md
+++ b/skills/hallmark/references/gates.md
@@ -69,7 +69,7 @@ One line each. `a`/`b` clauses share a number and carry their own tier. Genre no
| Gate | Tier | Class | The tell | The fix |
| --- | --- | --- | --- | --- |
| 1 | Reflex | M | Inter, Roboto, Open Sans, Poppins, Lato or a system face as the display | a display face from the theme or `fonts.md` |
-| 25 | Reflex | M | Running prose `max-width` outside 45 to 75ch; a lede or caption of two sentences or fewer may sit from 28ch | `max-width: 65ch` |
+| 25 | Reflex | M/R | Running prose `max-width` outside 45 to 75ch, or rendered lines of about 88 characters or more over three lines; a lede or caption of two sentences or fewer may sit from 28ch | `max-width: 65ch` |
| 37 | Reflex | M | More than three font families | display, body, one outlier |
| 38i | Floor | M | One italic word inside an otherwise roman heading | a line break, or the whole head set one way |
| 38ii | Reflex | M | An italic display system. Guard: declared on `--font-display`, applied to every head at that level, true italic with `font-synthesis: none` | roman display |
@@ -84,7 +84,7 @@ One line each. `a`/`b` clauses share a number and carry their own tier. Genre no
| Gate | Tier | Class | The tell | The fix |
| --- | --- | --- | --- | --- |
-| 3 | Reflex | M | Card tells: three equal columns of icon-above-heading tiles, an icon in a rounded tile above a heading, a thick coloured side stripe on a card | vary widths and heights, inline icons, hairline or no border |
+| 3 | Reflex | M/R | Card tells: three equal columns of icon-above-heading tiles, an icon in a rounded tile above a heading, a thick coloured side stripe on a card | vary widths and heights, inline icons, hairline or no border |
| 4 | Floor | M | A card inside a card | one containment layer |
| 6a | Floor | M | Hero sized in `vh` | `dvh` or `svh` |
| 6b | Reflex | J | Hero runs 92dvh or taller on a page with no stamped `hero:` posture, or title, lede, CTA and mark all sit on one centred axis. Guard: 44b passes. **at**, **pl** reach the centred canvas as their normal answer | at most two centred elements; break one alignment |
@@ -109,7 +109,7 @@ One line each. `a`/`b` clauses share a number and carry their own tier. Genre no
| Gate | Tier | Class | The tell | The fix |
| --- | --- | --- | --- | --- |
-| 19 | Floor | M | Copy tells: placeholder names (Jane Doe), startup clichés (Acme, Nexus), buzzwords (seamless, robust, empower, supercharge, elevate, effortless, unlock, unleash, next-generation, world-class, best-in-class, industry-leading, mission-critical, future-proof), the rebuttal cadence repeated ("Not a feature. A platform." three or more times), "quietly trusted by", em or en dashes, filler openers ("Built for the modern team", "In today's landscape"), a stock second action beside the primary (*Learn more*, *Get started*, *Book a demo*) | say what the product does, in its own nouns |
+| 19 | Floor | M | Copy tells: placeholder names (Jane Doe), startup clichés (Acme, Nexus), buzzwords (seamless, robust, empower, supercharge, elevate, effortless, unlock, unleash, next-generation, world-class, best-in-class, industry-leading, mission-critical, future-proof), the rebuttal cadence repeated ("Not a feature. A platform." three or more times), "quietly trusted by", em or en dashes, filler openers ("Built for the modern team", "In today's landscape"), a stock second action beside the primary (*Learn more*, *Get started*, *Book a demo*). A stock footer line (*All rights reserved*) is a `WARN`, and the page's own name is never a cliché | say what the product does, in its own nouns |
| 20 | Floor | M | The Hallmark stamp missing from the first lines of CSS (build form or checked form) | write it |
| 42 | Reflex | M | Chrome by reflex: the AI nav (wordmark left, inline links, button right, hairline under) or the AI footer (four link columns, social row, copyright) without the stamp naming it | decide it and name it (`nav:`, `footer:`), or build another shape |
| 46a | Floor | M | An invented metric, testimonial, logo wall or case-study count | the user's number, a labelled placeholder, or no slot |
@@ -136,9 +136,9 @@ One line each. `a`/`b` clauses share a number and carry their own tier. Genre no
| 16 | Reflex | J | A celebratory toast for an effect the user already sees | silent success |
| 17 | Floor | M | Tooltip focus delay equal to hover delay | hover 800 to 1000ms, focus 0 |
| 18 | Floor | M | Auto-rotating content with no pause on hover and focus | pause on hover and focus, and a visible pause control on anything moving past 5 seconds |
-| 26a | Floor | M | An interactive element with no `:focus-visible` | ring at 3:1 or better, instant |
+| 26a | Floor | M/R | An interactive element with no `:focus-visible`, a ring under 3:1 against what it is drawn over, or an outline removed with nothing in its place | ring at 3:1 or better, instant |
| 26b | Reflex | M | Missing `:active` or `:disabled`. Guard: not a form control, no `aria-disabled` anywhere | all eight states |
-| 27 | Floor | M | Any keyframe or transform transition without a `prefers-reduced-motion: reduce` fallback | add it |
+| 27 | Floor | M | Any keyframe or transform transition without a `prefers-reduced-motion: reduce` fallback (`transition: all` over a hover transform counts) | add it |
| 28a | Floor | M | A video autoplaying without `muted`; `loading="lazy"` on the LCP element | `autoplay muted loop playsinline`; `fetchpriority="high"` on an LCP image, a preloaded poster for an LCP video |
| 28b | Reflex | M | Video without `poster` or priority hint. Guard: below the fold and not the LCP | add them |
| 39a | Floor | M | Input states that break: border width shifting between states, a focus ring built from `border`, input height unequal to its adjacent button, disabled by opacity alone | constant border, `outline`, shared height, three disabled channels (opacity, `cursor: not-allowed`, the native attribute) |
diff --git a/skills/hallmark/references/redesign.md b/skills/hallmark/references/redesign.md
index 2c80a92..4eb16d5 100644
--- a/skills/hallmark/references/redesign.md
+++ b/skills/hallmark/references/redesign.md
@@ -6,7 +6,7 @@ Loaded when the request opens with `redesign` or `audit`, or plainly asks to red
- **The content.** Every fact, claim, name, price, date and quote the page states. Figures, quotes and logos already on the page are the user's material: carried over as found, never added to, and listed in the handoff for the user to verify.
- **The wiring.** Every link, form field, action, handler, route, id and test hook; every script, data call and analytics call. Edit markup inside the component that owns it. Never move logic, rename a prop, or drop a `name`, an `id`, a `key`, an `href` or a `data-testid` that a script or a test reads.
-- **The files.** No file deleted, no route removed and no component tree replaced without a file-level plan the user approved, and no test edited to make the redesign pass. Documents in the repo (a README, a brief, a deck) explain the product; they are not page copy. In a git project, start from a clean tree (ask the user to commit or stash; never do it for them), so the redesign is one diff they can read and revert.
+- **The files.** No file deleted, no route removed and no component tree replaced without a file-level plan the user approved, and no test edited to make the redesign pass. Documents in the repo (a README, a brief, a deck) explain the product; they are not page copy. In a git project, start from a clean tree, `.hallmark/` aside (ask the user to commit or stash; never do it for them), so the redesign is one diff they can read and revert.
- **The brand.** A logo, a brand colour and a brand face the pre-flight finds stay at every depth unless the user lets them go; a real brand runs `brand-truth.md`. A locked `design.md` is the system at every depth.
- **The words,** unless a gate names them. Wording that fails a copy gate (19, 58, 63, 69) is tightened from the facts already on the page, and the handoff lists every changed line, before and after. Terms, disclaimers and consent text are never reworded. When the user says to keep every word, stamp `copy: verbatim`: 19, 58 and 69 then report as notes.
@@ -24,18 +24,18 @@ How far the run goes. The user's words pick it; otherwise the project does, and
## Before
-1. Run the pre-flight (Step 0), then list the pages in the target: route, file, and whether each is a marketing page, a content page or an app screen (`flow.md` § App screens). In a framework project start the dev server.
+1. Run the pre-flight (Step 0), then list the pages in the target: route, file, and whether each is a page or an app screen (`flow.md` § App screens). In a framework project start the dev server. An unstamped page has no genre: infer it as Step 1 does and say so.
2. Record the page as it stands:
```
-node <skill-dir>/scripts/sloplint.mjs <target> --render --before [--url <route> ...] [--scope app]
+node <skill-dir>/scripts/sloplint.mjs <target> --genre <genre> --render --before [--url <route> ...] [--scope app]
```
-It lints, writes the screenshots to `.hallmark/before/`, and records every link, field, action, handler, test hook, heading and figure in `.hallmark/before.json`. An unstamped page has no genre: infer it as Step 1 does and say so.
+It prints the findings grouped by gate and writes every line to `.hallmark/before.txt`, the screenshots to `.hallmark/before/`, and the record to `.hallmark/before.json`: every link, field, form action, inline handler, test hook, script hook, heading and figure. The folder ignores its own screenshots and records in git.
-3. Look at the screenshots before the findings, so the linter does not write the verdict, then give the read in four lines: what the page is for (the audience, the one action); what works and stays (at least one thing); what reads as generated (the worst tells, by gate); what is broken.
+3. Look at the screenshots before you weigh the findings, so the linter does not write the verdict, then give the read in four lines: what the page is for (the audience, the one action); what works and stays (at least one thing); what reads as generated (the worst tells, by gate); what is broken.
-**`audit <target>` stops here:** the findings by tier with `file:line`, the read, and one line naming the depth that would settle them. It edits nothing.
+**`audit <target>` stops here.** It loads `gates.md` § 1, § 4 and § 5, walks the judged gates from the screenshots, and reports the findings by tier with `file:line`, the read, the lightest depth that settles them and what only a deeper one would. It changes none of the project's files.
## The ask
diff --git a/skills/hallmark/scripts/sloplint-render.mjs b/skills/hallmark/scripts/sloplint-render.mjs
index f21f628..607fe7f 100644
--- a/skills/hallmark/scripts/sloplint-render.mjs
+++ b/skills/hallmark/scripts/sloplint-render.mjs
@@ -19,22 +19,27 @@ function contrast(a, b) {
}
async function pixelBehind(page, probe) {
+ const HIDE = [['color', 'transparent'], ['text-shadow', 'none'], ['-webkit-text-stroke', '0'], ['text-decoration-color', 'transparent']];
+ const restore = () => page.evaluate((n, props) => {
+ const el = document.querySelector(`[data-hm-probe="${n}"]`);
+ if (el) for (const [k] of props) el.style.removeProperty(k);
+ window.scrollTo(0, 0);
+ }, probe, HIDE).catch(() => {});
try {
- const rect = await page.evaluate((n) => {
+ const rect = await page.evaluate((n, props) => {
const el = document.querySelector(`[data-hm-probe="${n}"]`);
if (!el) return null;
- el.scrollIntoView({ block: 'center' });
- for (const [k, v] of [['color', 'transparent'], ['text-shadow', 'none'], ['-webkit-text-stroke', '0'], ['text-decoration-color', 'transparent']]) el.style.setProperty(k, v, 'important');
+ el.scrollIntoView({ block: 'center', behavior: 'instant' });
+ for (const [k, v] of props) el.style.setProperty(k, v, 'important');
const r = el.getBoundingClientRect();
const x = Math.max(0, r.left), y = Math.max(0, r.top);
- return { x, y, width: Math.min(r.right, innerWidth) - x, height: Math.min(r.bottom, innerHeight) - y };
- }, probe);
- if (!rect || rect.width < 2 || rect.height < 2) return null;
+ return { x: x + scrollX, y: y + scrollY, width: Math.min(r.right, innerWidth) - x, height: Math.min(r.bottom, innerHeight) - y };
+ }, probe, HIDE);
+ if (!rect || rect.width < 2 || rect.height < 2) { await restore(); return null; }
await frames(page);
const data = await page.screenshot({ clip: rect, encoding: 'base64' });
- return await page.evaluate(async (b64, n) => {
- const el = document.querySelector(`[data-hm-probe="${n}"]`);
- if (el) for (const k of ['color', 'text-shadow', '-webkit-text-stroke', 'text-decoration-color']) el.style.removeProperty(k);
+ await restore();
+ return await page.evaluate(async (b64) => {
const img = new Image();
img.src = 'data:image/png;base64,' + b64;
await img.decode();
@@ -46,8 +51,8 @@ async function pixelBehind(page, probe) {
const ch = [[], [], []];
for (let i = 0; i < d.length; i += 4) { ch[0].push(d[i]); ch[1].push(d[i + 1]); ch[2].push(d[i + 2]); }
return ch.map((a) => a.sort((p, q) => p - q)[a.length >> 1] / 255);
- }, data, probe);
- } catch { return null; }
+ }, data);
+ } catch { await restore(); return null; }
}
async function shoot(page, file, tag, fullPage) {
@@ -55,7 +60,7 @@ async function shoot(page, file, tag, fullPage) {
const dir = isUrl(file) ? join(process.cwd(), '.hallmark', SHOT_DIR) : join(dirname(file), '.hallmark', SHOT_DIR);
mkdirSync(dir, { recursive: true });
const ignore = join(dirname(dir), '.gitignore');
- if (!existsSync(ignore)) writeFileSync(ignore, 'shots/\nbefore/\nbefore.json\ncompare.html\n');
+ if (!existsSync(ignore)) writeFileSync(ignore, 'shots/\nbefore/\nbefore.json\nbefore.txt\ncompare.html\n');
const out = join(dir, `${slugOf(file)}-${tag}.png`);
await page.screenshot({ path: out, fullPage });
SHOTS.push(out);
@@ -117,7 +122,11 @@ export async function renderCheck(htmlFiles, metaIn) {
const nav = await page.goto(isUrl(file) ? file : 'file://' + file, { waitUntil: isUrl(file) ? 'networkidle0' : 'load', timeout: 30000 }).then((r) => ({ r }), (e) => ({ e }));
if (nav.e && !/timeout/i.test(nav.e.message)) throw nav.e;
if (nav.r && isUrl(file) && !nav.r.ok()) throw new Error(`HTTP ${nav.r.status()} from ${file}`);
- await page.evaluate(async () => { document.documentElement.classList.add('shot'); if (document.fonts) await document.fonts.ready; }).catch(() => {});
+ await page.evaluate(async () => {
+ document.documentElement.classList.add('shot');
+ for (const el of [document.documentElement, document.body]) if (el) el.style.setProperty('scroll-behavior', 'auto', 'important');
+ if (document.fonts) await document.fonts.ready;
+ }).catch(() => {});
if (isUrl(file)) {
const stamp = await page.evaluate(async () => { let t = [...document.querySelectorAll('style')].map((x) => x.textContent.slice(0, 4000)).join('\n'); for (const l of document.querySelectorAll('link[rel~="stylesheet"]')) { try { t += '\n' + (await (await fetch(l.href)).text()).slice(0, 4000); } catch {} } return t; }).catch(() => '');
meta.postureByFile[file] = (/posture:\s*(restrained|committed|full-palette|drenched)/i.exec(stamp)?.[1] || 'restrained').toLowerCase();
@@ -127,6 +136,7 @@ export async function renderCheck(htmlFiles, metaIn) {
const prefix = heroOnly ? 'hero-' : '';
for (const width of heroOnly ? [375, 1280] : WIDTHS) {
await page.setViewport({ width, height: width === 375 && heroOnly ? 812 : 800 });
+ await page.evaluate(() => window.scrollTo(0, 0)).catch(() => {});
await frames(page);
if (width === 1280) await shoot(page, file, `${prefix}1280x800`, false);
if (width === 375) await shoot(page, file, heroOnly ? 'hero-375x812' : '375', !heroOnly);
@@ -145,6 +155,8 @@ export async function renderCheck(htmlFiles, metaIn) {
}
for (const [w, h] of [[1440, 900], [1920, 1080]]) {
await page.setViewport({ width: w, height: h });
+ await page.evaluate(() => window.scrollTo(0, 0)).catch(() => {});
+ await frames(page);
await shoot(page, file, `${prefix}${w}x${h}`, false);
if (!heroOnly && w === 1440) {
await page.evaluate(async () => { for (let y = 0; y < document.documentElement.scrollHeight; y += 800) { window.scrollTo(0, y); await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))); } window.scrollTo(0, 0); });
@@ -163,15 +175,18 @@ export async function renderCheck(htmlFiles, metaIn) {
for (const f of [...quality, ...hidden]) findings.push({ ...f, file, line: 1, evidence: `[1440px] ${f.evidence}` });
await page.evaluate(() => { window.scrollTo(0, 0); if (document.activeElement && document.activeElement.blur) document.activeElement.blur(); });
const rings = new Set();
+ const bare = [];
for (let i = 0; i < 16; i++) {
await page.keyboard.press('Tab');
await frames(page);
const ring = await page.evaluate(focusRing);
if (!ring || rings.has(ring.key)) continue;
rings.add(ring.key);
+ if (ring.bare) { if (bare.length < 4) bare.push(ring.key); continue; }
if (ring.ratio != null && ring.ratio < 2.95) { const bg = await pixelsAroundRing(page, ring); if (bg) ring.ratio = contrast(ring.ring, bg); }
if (ring.ratio != null && ring.ratio < 2.95) findings.push({ gate: '26a', grade: 'FAIL', file, line: 1, evidence: `[1440px] focus ring ${ring.ratio.toFixed(2)}:1 against what is behind it on ${ring.key}`, fix: 'A ring at 3:1 or better against the surface it is drawn over: --color-focus, or a ring colour per band' });
}
+ if (bare.length) findings.push({ gate: '26a', grade: 'FAIL', file, line: 1, evidence: `[1440px] nothing shows keyboard focus on ${bare.join(', ')}`, fix: 'Give every control a :focus-visible ring; never remove an outline without putting one back' });
}
if (!heroOnly) {
await page.setViewport({ width: 1440, height: 900 });
@@ -212,7 +227,7 @@ export async function renderCheck(htmlFiles, metaIn) {
const seen = new Set();
const kept = findings.filter((f) => {
- const k = f.gate + '|' + f.evidence.replace(/^\[\d+px\] /, '');
+ const k = f.file + '|' + f.gate + '|' + f.evidence.replace(/^\[\d+px\] /, '');
if (seen.has(k)) return false;
seen.add(k);
return true;
@@ -292,18 +307,31 @@ function inventory() {
const actions = uniq([...document.querySelectorAll('form[action]')].map((f) => `${(f.getAttribute('method') || 'get').toLowerCase()} ${key(f.getAttribute('action'))}`));
const headings = uniq([...document.querySelectorAll('h1, h2, h3, h4')].filter((h) => !quiet(h)).map((h) => text(h).toLowerCase()).filter((t) => t.length > 1));
const body = text(document.body);
- const figures = uniq((body.match(/[$€£¥]\s?\d[\d,.]*\+?[kKmM]?|\b\d[\d,.]*\s?%|\b\d[\d,.]*[kKmM]?\+(?=\s|$)|\b\d{1,3}(?:,\d{3})+\b|\b\d{1,2}[:.]\d{2}\s?(?:am|pm)?\b/gi) || []).map((t) => t.replace(/\s+/g, '').toLowerCase()));
+ const figures = uniq((body.match(/[$€£¥]\s?\d[\d,.]*\+?[kKmM]?|\b\d[\d,.]*\s?%|\b\d[\d,.]*[kKmM]?\+(?=\s|$)|\b\d{1,3}(?:,\d{3})+\b|\b\d{1,2}[:.]\d{2}\s?(?:am|pm)?\b|\b(?:19|20)\d{2}\b|\b\d+(?:\.\d+)?\s(?:hours?|minutes?|mins?|days?|weeks?|months?|years?|seconds?|ms|km|kg|g|ml|mm|cm|gb|mb|tb|x)\b|\+?\d[\d\s().-]{7,}\d/gi) || []).map((t) => t.replace(/\s+/g, '').toLowerCase()));
const images = uniq([...document.querySelectorAll('img[src]')].map((i) => (i.getAttribute('src') || '').split('?')[0].split('/').pop()));
const controls = document.querySelectorAll('button, [role="button"], input[type="submit"], input[type="button"], select, textarea, input:not([type="hidden"])').length;
return { links, fields, actions, headings, figures, images, controls, words: body ? body.split(' ').length : 0 };
}
function focusRing() {
- const el = document.activeElement;
+ let el = document.activeElement;
if (!el || el === document.body || el === document.documentElement) return null;
+ const box = el.getBoundingClientRect();
+ if (box.width < 4 || box.height < 4) el = el.closest('label') || el.parentElement;
+ if (!el) return null;
+ el.style.setProperty('transition', 'none', 'important');
const cs = getComputedStyle(el);
const key = el.tagName.toLowerCase() + (el.classList[0] ? '.' + el.classList[0] : '') + ((el.textContent || '').trim() ? ` "${el.textContent.trim().slice(0, 18)}"` : '');
- if (cs.outlineStyle === 'none' || !(parseFloat(cs.outlineWidth) > 0)) return { key, ratio: null };
+ if (cs.outlineStyle === 'none' || !(parseFloat(cs.outlineWidth) > 0)) {
+ const active = document.activeElement;
+ const chain = []; for (let n = el, i = 0; n && n !== document.body && i < 5; n = n.parentElement, i++) chain.push(n);
+ const look = () => chain.flatMap((n) => [null, '::before', '::after'].map((ps) => { const c = getComputedStyle(n, ps); return [c.outlineStyle, c.outlineWidth, c.boxShadow, c.borderTopColor, c.borderBottomColor, c.borderLeftColor, c.borderBottomWidth, c.backgroundColor, c.backgroundImage, c.color, c.textDecorationLine, c.opacity].join('|'); })).join('~');
+ const focused = look();
+ active.blur();
+ const rest = look();
+ active.focus({ preventScroll: true });
+ return { key, ratio: null, bare: focused === rest };
+ }
const cv = document.createElement('canvas'); cv.width = cv.height = 1;
const cx = cv.getContext('2d', { willReadFrequently: true });
const rgb = (str) => { cx.clearRect(0, 0, 1, 1); cx.fillStyle = 'rgba(0, 0, 0, 0)'; cx.fillStyle = str; cx.fillRect(0, 0, 1, 1); const d = cx.getImageData(0, 0, 1, 1).data; return [d[0] / 255, d[1] / 255, d[2] / 255, d[3] / 255]; };
@@ -323,16 +351,16 @@ function focusRing() {
async function pixelsAroundRing(page, ring) {
try {
- await page.evaluate(() => { const el = document.activeElement; if (el) { el.style.setProperty('outline-style', 'none', 'important'); el.style.setProperty('box-shadow', 'none', 'important'); } });
+ await page.evaluate(() => { let el = document.activeElement; if (el) { const b = el.getBoundingClientRect(); if (b.width < 4 || b.height < 4) el = el.closest('label') || el.parentElement; } if (el) { el.setAttribute('data-hm-ring', ''); el.style.setProperty('outline-style', 'none', 'important'); el.style.setProperty('box-shadow', 'none', 'important'); } });
await frames(page);
- const vw = await page.evaluate(() => [innerWidth, innerHeight]);
+ const vw = await page.evaluate(() => [innerWidth, innerHeight, scrollX, scrollY]);
const x = Math.max(0, ring.rect.x - ring.pad), y = Math.max(0, ring.rect.y - ring.pad);
- const clip = { x, y, width: Math.min(vw[0], ring.rect.x + ring.rect.w + ring.pad) - x, height: Math.min(vw[1], ring.rect.y + ring.rect.h + ring.pad) - y };
+ const clip = { x: x + vw[2], y: y + vw[3], width: Math.min(vw[0], ring.rect.x + ring.rect.w + ring.pad) - x, height: Math.min(vw[1], ring.rect.y + ring.rect.h + ring.pad) - y };
if (clip.width < 4 || clip.height < 4) return null;
const data = await page.screenshot({ clip, encoding: 'base64' });
return await page.evaluate(async (b64, inner) => {
- const el = document.activeElement;
- if (el) { el.style.removeProperty('outline-style'); el.style.removeProperty('box-shadow'); }
+ const el = document.querySelector('[data-hm-ring]');
+ if (el) { el.removeAttribute('data-hm-ring'); el.style.removeProperty('outline-style'); el.style.removeProperty('box-shadow'); }
const img = new Image(); img.src = 'data:image/png;base64,' + b64; await img.decode();
const c = document.createElement('canvas'); c.width = img.width; c.height = img.height;
const x = c.getContext('2d'); x.drawImage(img, 0, 0);
@@ -498,12 +526,13 @@ function observe(checkFold, meta) {
const large = size >= 24 || (size >= 18 && weight >= 700);
const threshold = large ? 3.0 : 4.5;
const key = describe(el);
+ const where = `${key} "${(el.innerText || el.textContent || '').replace(/\s+/g, ' ').trim().slice(0, 24)}"`;
const stops = gradStops(el, bg);
if (stops.length && !seenSel.has(key)) {
const rs = stops.map((c) => ratio(fg, c));
const worst = Math.min(...rs), best = Math.max(...rs);
- if (best < threshold - 0.05) { seenSel.add(key); reported++; push(40, 'FAIL', `contrast ${best.toFixed(2)}:1 at best over the gradient behind ${key}`, 'Raise the contrast to threshold, or give the text its own ground'); }
- else if (worst < threshold - 0.05) { seenSel.add(key); reported++; push(40, 'WARN', `contrast drops to ${worst.toFixed(2)}:1 over the gradient behind ${key}`, 'Check the text where the gradient is darkest or lightest; give the label its own ground'); }
+ if (best < threshold - 0.05) { seenSel.add(key); reported++; push(40, 'FAIL', `contrast ${best.toFixed(2)}:1 at best over the gradient behind ${where}`, 'Raise the contrast to threshold, or give the text its own ground'); }
+ else if (worst < threshold - 0.05) { seenSel.add(key); reported++; push(40, 'WARN', `contrast drops to ${worst.toFixed(2)}:1 over the gradient behind ${where}`, 'Check the text where the gradient is darkest or lightest; give the label its own ground'); }
continue;
}
const r = ratio(fg, bg);
@@ -512,7 +541,7 @@ function observe(checkFold, meta) {
reported++;
el.setAttribute('data-hm-probe', String(reported));
const probe = { probe: reported, fg: [fg.r, fg.g, fg.b], threshold };
- push(40, 'FAIL', `computed contrast ${r.toFixed(2)}:1 < ${threshold}:1 on ${key}`,
+ push(40, 'FAIL', `computed contrast ${r.toFixed(2)}:1 < ${threshold}:1 on ${where}`,
'Raise the contrast to threshold', probe);
const btnish = el.closest('a, button, [class*="btn"], [class*="cta"]');
if (btnish && r < 1.6) {
@@ -728,8 +757,9 @@ function observeSpace(atLaptop, heroOnly, heroPosture) {
if (textBox && textBox.left < 120) push('44d', 'FAIL', `hero text starts ${Math.round(textBox.left)}px from the edge at 1920`, 'Cap the container at 1360 to 1520px and centre it');
if (heroEnd != null && heroEnd > vh + 8) push('44d', 'FAIL', `hero runs past the 1920x1080 screen (hero ends at ${Math.round(heroEnd)}px)`, 'Cap vw-sized visuals and display sizes');
- const wide = [...document.querySelectorAll('p, h1, h2, h3, li')].filter((e) => vis(e) && !e.querySelector('p, h1, h2, h3, h4, div, figure, ul, ol, table, section') && (e.innerText || '').trim().length > 40 && e.getBoundingClientRect().width > 1600);
- if (wide.length) push('44d', 'FAIL', `${wide.length} text blocks wider than 1600px at 1920`, 'Cap the container; hold the measure');
+ const inkWidth = (e) => { const range = document.createRange(); range.selectNodeContents(e); return range.getBoundingClientRect().width; };
+ const wide = [...document.querySelectorAll('p, h1, h2, h3, li')].filter((e) => vis(e) && !e.querySelector('p, h1, h2, h3, h4, div, figure, ul, ol, table, section') && (e.innerText || '').trim().length > 40 && inkWidth(e) > 1600);
+ if (wide.length) push('44d', 'FAIL', `${wide.length} text block${wide.length > 1 ? 's run' : ' runs'} wider than 1600px at 1920 (first: ${wide[0].tagName.toLowerCase()} "${(wide[0].innerText || '').trim().slice(0, 28)}")`, 'Cap the container; hold the measure');
}
return out;
}
@@ -815,6 +845,40 @@ function observeQuality(scope) {
const offSize = controls.map((el) => ({ el, h: el.getBoundingClientRect().height })).filter((c) => c.h > 8 && (c.h < (scope === 'app' ? 30 : 42) || c.h > 54));
if (offSize.length) push('39b', 'REFLEX', `control height outside ${scope === 'app' ? '32 to 52px' : '44 to 52px'}: ${offSize.slice(0, 3).map((c) => `${name(c.el)} ${Math.round(c.h)}px`).join(', ')}`, 'Marketing controls stand 44 to 52px; app UI 32 to 40px with a 44px hit target');
+ const long = [];
+ for (const el of all) {
+ if (long.length >= 2 || el.tagName !== 'P' || el.closest('nav, footer, table, figure, [data-slot]')) continue;
+ const t = (el.innerText || '').replace(/\s+/g, ' ').trim();
+ if (t.length < 240) continue;
+ const cs = getComputedStyle(el);
+ const lh = parseFloat(cs.lineHeight) || parseFloat(cs.fontSize) * 1.4;
+ const lines = Math.round(el.getBoundingClientRect().height / lh);
+ if (lines >= 3 && t.length / lines > 88) long.push(`${name(el)} about ${Math.round(t.length / lines)} characters a line`);
+ }
+ if (long.length) push(25, 'REFLEX', `running prose set too wide: ${long.join(', ')}`, 'Cap the measure at 45 to 75ch');
+
+ const tiles = all.find((g) => {
+ if (g.closest('nav, footer, form, table')) return false;
+ const kids = [...g.children].filter(vis);
+ if (kids.length < 3 || kids.length > 4) return false;
+ const rects = kids.map((k) => k.getBoundingClientRect());
+ if (rects.some((r) => Math.abs(r.top - rects[0].top) > 4 || r.width < 160) || Math.max(...rects.map((r) => r.width)) > Math.min(...rects.map((r) => r.width)) * 1.04) return false;
+ return kids.every((k) => {
+ const head = k.querySelector('h2, h3, h4');
+ if (!head) return false;
+ const icon = [...k.querySelectorAll('svg, img, [class*="icon"], span, div, i')].find((n) => {
+ if (n.contains(head) || head.contains(n)) return false;
+ const r = n.getBoundingClientRect();
+ const glyph = (n.textContent || '').trim();
+ const iconish = n.tagName === 'svg' || n.tagName === 'IMG' || /icon/i.test(String(n.className && n.className.baseVal != null ? n.className.baseVal : n.className)) || (glyph.length > 0 && glyph.length <= 2 && /\p{Extended_Pictographic}/u.test(glyph));
+ const media = n.tagName === 'svg' || n.tagName === 'IMG';
+ return iconish && r.height > 8 && r.height <= 96 && (!media || r.width <= 96) && r.bottom <= head.getBoundingClientRect().top + 2;
+ });
+ return !!icon;
+ });
+ });
+ if (tiles) push(3, 'REFLEX', `equal columns of icon-above-heading tiles (${name(tiles)})`, 'Vary the widths, set the icon inline with the heading, or drop the icons');
+
const cv = document.createElement('canvas'); cv.width = cv.height = 1;
const cx = cv.getContext('2d', { willReadFrequently: true });
const rgb = (s) => { cx.clearRect(0, 0, 1, 1); cx.fillStyle = 'rgba(0, 0, 0, 0)'; cx.fillStyle = s; cx.fillRect(0, 0, 1, 1); const d = cx.getImageData(0, 0, 1, 1).data; return [d[0] / 255, d[1] / 255, d[2] / 255, d[3] / 255]; };
diff --git a/skills/hallmark/scripts/sloplint.mjs b/skills/hallmark/scripts/sloplint.mjs
index ad754d9..2182135 100644
--- a/skills/hallmark/scripts/sloplint.mjs
+++ b/skills/hallmark/scripts/sloplint.mjs
@@ -214,7 +214,7 @@ function parseHtml(file, src, kind = 'html') {
.replace(/<!--[\s\S]*?-->/g, ' ');
const text = noScript.replace(/<[^>]*>/g, ' ')
.replace(/&quot;|&#0?34;/g, '"').replace(/&#0?39;|&apos;/g, "'")
- .replace(/&hellip;|&#8230;/g, '\u2026').replace(/&mdash;|&#8212;/g, '\u2014')
+ .replace(/&hellip;|&#8230;/g, '\u2026').replace(/&mdash;|&#8212;|&#x2014;/gi, '\u2014').replace(/&ndash;|&#8211;|&#x2013;/gi, '\u2013')
.replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>')
.replace(/&nbsp;/g, ' ').replace(/[ \t]+/g, ' ');
return { file, src, masked, styles, scripts, tags, text, lineOf, kind, comps };
@@ -608,7 +608,8 @@ function ancestorMap(doc) {
function plainText(html) {
return html.replace(/<[^>]*>/g, ' ')
- .replace(/&middot;|&#0?183;/g, '·').replace(/&mdash;|&#8212;/g, '\u2014').replace(/&ndash;|&#8211;/g, '\u2013')
+ .replace(/&middot;|&#0?183;|&#x0?b7;/gi, '·').replace(/&bull;|&#8226;|&#x2022;/gi, '•').replace(/&mdash;|&#8212;|&#x2014;/gi, '\u2014').replace(/&ndash;|&#8211;|&#x2013;/gi, '\u2013')
+ .replace(/&rarr;|&#8594;|&#x2192;|&xrarr;|&#10230;/gi, '\u2192').replace(/&raquo;|&#187;|&#xbb;/gi, '\u00bb').replace(/&rsaquo;|&#8250;|&#x203a;/gi, '\u203a')
.replace(/&nbsp;|&#160;/g, ' ').replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>')
.replace(/&#\d+;|&[a-z]+;/gi, ' ')
.replace(/\s+/g, ' ').trim();
@@ -888,6 +889,7 @@ const COPY_GATES = new Set(['19', '58', '69']);
const findings = [];
function report(gate, grade, file, line, evidence, fix) {
const g = String(gate);
+ if (opts.before && g === '20') return;
if (opts.scope === 'component' && pageOnly(g)) return;
if ((opts.scope === 'app' || APPSCREEN) && appSkip(g)) return;
if (opts.stage === 'hero' && HERO_SKIP.has(String(g))) return;
@@ -1617,8 +1619,10 @@ function check26(ctx) {
function check27(ctx) {
const tw = twGroup(ctx);
+ const moves = (r) => r.decls.some((d) => /^(transform|translate|scale|rotate)$/.test(d.prop) && !/^none\b/.test(d.value.trim()));
const hasMotion = ctx.rules.some((r) => r.keyframes)
- || ctx.rules.some((r) => r.decls.some((d) => /^transition/.test(d.prop) && /transform/.test(d.value)));
+ || ctx.rules.some((r) => r.decls.some((d) => /^transition/.test(d.prop) && /transform/.test(d.value)))
+ || (ctx.rules.some((r) => r.decls.some((d) => /^transition/.test(d.prop) && /(^|[\s,])all\b/.test(d.value))) && ctx.rules.some((r) => /:(hover|active|focus)/.test(r.selector) && moves(r)));
if (!hasMotion && !tw.motion) return;
const hasPRM = ctx.rules.some((r) => r.media && /prefers-reduced-motion/i.test(r.media))
|| ctx.cssFiles.some((f) => /prefers-reduced-motion/i.test(stripComments(f.raw)))
@@ -2180,7 +2184,7 @@ function check53(ctx) {
}
}
-const EYEBROW_CONTAINER = /^(div|header|section|article|aside|hgroup|li|main|figure|a|body|blockquote)$/;
+const EYEBROW_CONTAINER = /^(div|header|footer|section|article|aside|hgroup|li|main|figure|a|body|blockquote)$/;
const EYEBROW_SKIP_TAGS = /^(figcaption|label|legend|caption|th|dt|summary|option|code|kbd|button|select|nav|time)$/;
const EYEBROW_ANCESTOR_SKIP = /^(form|fieldset|table|thead|tbody|nav|menu|dl|select|figcaption|label|button)$/;
@@ -2263,7 +2267,7 @@ function check54(ctx) {
if (t.close || t.selfClosing || !EYEBROW_CONTAINER.test(t.name)) continue;
const ancestors = anc.get(i) || [];
if (ancestors.some((n) => EYEBROW_ANCESTOR_SKIP.test(n))) continue;
- const inOl = ancestors.includes('ol') || t.name === 'li';
+ const inOl = ancestors.includes('ol');
const kids = directChildren(doc, i);
for (let k = 0; k < kids.length - 1; k++) {
const A = kids[k];
@@ -2945,7 +2949,7 @@ function check19Tells(ctx) {
const line = doc.lineOf(idx);
if (lines.has(line)) return;
lines.add(line);
- report(19, 'FAIL', doc.file, line, `${what}: "${trunc(text, 40)}"`, 'Say what the product does, in its own nouns');
+ report(19, what === 'template footer line' ? 'WARN' : 'FAIL', doc.file, line, `${what}: "${trunc(text, 40)}"`, what === 'template footer line' ? 'A stock line with no legal effect; cut it unless the owner wants it' : 'Say what the product does, in its own nouns');
};
for (const [re, what] of TELLS19) {
const m = re.exec(prose);
@@ -4218,7 +4222,7 @@ if (opts.before) {
const inv = takeInventory();
mkdirSync(dirname(SNAP), { recursive: true });
writeFileSync(SNAP, JSON.stringify({ v: 1, at: new Date().toISOString(), scope: opts.scope, summary: { fails, reflex, warns }, ...inv }, null, 1) + '\n');
- beforeLine = `before: recorded ${new Set([...inv.wiring.links, ...Object.values(inv.pages).flatMap((p) => p.links)]).size} links, ${new Set([...inv.wiring.fields, ...Object.values(inv.pages).flatMap((p) => p.fields)]).size} fields, ${inv.wiring.handlers.length} handlers, ${inv.wiring.hooks.length} test hooks${Object.keys(inv.pages).length ? ` and ${Object.keys(inv.pages).length} rendered page(s)` : ''} in ${rel(SNAP)}; --kept checks a redesign against it`;
+ beforeLine = `before: recorded ${new Set([...inv.wiring.links, ...Object.values(inv.pages).flatMap((p) => p.links)]).size} links, ${new Set([...inv.wiring.fields, ...Object.values(inv.pages).flatMap((p) => p.fields)]).size} fields, ${inv.wiring.handlers.length} handlers, ${inv.wiring.hooks.length} test hooks, ${new Set(Object.values(inv.scripts).flatMap((h) => h.hooked)).size} script hooks${Object.keys(inv.pages).length ? ` and ${Object.keys(inv.pages).length} rendered page(s)` : ''} in ${rel(SNAP)}; --kept checks a redesign against it`;
}
const keptNote = keptLine ? `kept: ${keptLine.parts.join(', ') || 'nothing recorded'}${keptLine.was ? `; before ${keptLine.was.fails} FAIL, ${keptLine.was.reflex} REFLEX, now ${fails} FAIL, ${reflex} REFLEX` : ''}` : null;
let compareNote = null;
@@ -4242,7 +4246,12 @@ if (opts.json) {
const by = new Map();
for (const f of unique) { const k = `${f.grade} ${f.gate}`; if (!by.has(k)) by.set(k, []); by.get(k).push(f); }
for (const [k, list] of by) console.log(` ${k}${list.length > 1 ? ` x${list.length}` : ''} ${list.slice(0, 2).map((f) => `${f.file}:${f.line} ${trunc(f.evidence, 64)}`).join('; ')} | fix: ${list[0].fix}`);
- console.log(`sloplint: ${tally.join(', ')} across ${scopeNote}, grouped by gate; run without --before for every line.`);
+ const every = join(dirname(SNAP), 'before.txt');
+ mkdirSync(dirname(SNAP), { recursive: true });
+ const ignore = join(dirname(SNAP), '.gitignore');
+ if (!existsSync(ignore)) writeFileSync(ignore, 'shots/\nbefore/\nbefore.json\nbefore.txt\ncompare.html\n');
+ writeFileSync(every, unique.map((f) => `${f.grade} ${f.gate} ${f.file}:${f.line} ${f.evidence} | fix: ${f.fix}`).join('\n') + '\n');
+ console.log(`sloplint: ${tally.join(', ')} across ${scopeNote}, grouped by gate; every line is in ${rel(every)}.`);
} else {
const byFile = new Map();
for (const f of unique) { if (!byFile.has(f.file)) byFile.set(f.file, []); byFile.get(f.file).push(f); }