Anti-AI-slop design skill for Claude Code, Cursor, and Codex.
CSS
Contrast is measured on the pixels, and themes cannot ship faint text
Youssefbf89eb860473
diff --git a/skills/hallmark/references/themes/formwork.md b/skills/hallmark/references/themes/formwork.mdindex 67a8eb6..70ea876 100644--- a/skills/hallmark/references/themes/formwork.md+++ b/skills/hallmark/references/themes/formwork.md@@ -22,7 +22,7 @@ A warm grey concrete surface that keeps its board lines and tie holes, Oswald ca:root {--color-paper: oklch(74% 0.008 80); --color-paper-2: oklch(69% 0.009 80); --color-paper-3: oklch(64% 0.01 80);--color-plate: oklch(81% 0.008 80);- --color-ink: oklch(18% 0.005 270); --color-ink-2: oklch(30% 0.006 80); --color-muted: oklch(36% 0.008 80);+ --color-ink: oklch(18% 0.005 270); --color-ink-2: oklch(30% 0.006 80); --color-muted: oklch(32% 0.008 80);--color-rule: oklch(64% 0.01 80);--color-accent: oklch(66% 0.21 38); --color-accent-ink: oklch(18% 0.005 270); --color-focus: oklch(42% 0.15 38);--color-accent-deep: oklch(48% 0.17 38);diff --git a/skills/hallmark/references/themes/hum.md b/skills/hallmark/references/themes/hum.mdindex d4fe51f..2b2346e 100644--- a/skills/hallmark/references/themes/hum.md+++ b/skills/hallmark/references/themes/hum.md@@ -24,8 +24,8 @@ Cream pulled toward pear-yellow, three accents that never blend, Chillax for eve--color-ink: oklch(20% 0.012 250); --color-ink-2: oklch(28% 0.012 250); --color-muted: oklch(48% 0.012 250);--color-rule: oklch(88% 0.014 95);--color-accent: oklch(86% 0.18 95); --color-accent-deep: oklch(72% 0.16 95); --color-accent-ink: oklch(20% 0.012 250);- --color-accent-2: oklch(54% 0.17 235); --color-accent-3: oklch(68% 0.24 18);- --color-mint: oklch(80% 0.16 150); --color-glow: oklch(76% 0.20 95); --color-lavender: oklch(74% 0.16 305); --color-focus: oklch(54% 0.17 235);+ --color-accent-2: oklch(51% 0.17 235); --color-accent-3: oklch(68% 0.24 18);+ --color-mint: oklch(80% 0.16 150); --color-glow: oklch(76% 0.20 95); --color-lavender: oklch(74% 0.16 305); --color-focus: oklch(51% 0.17 235);--font-display: "Chillax", "Geist", ui-rounded, ui-sans-serif, sans-serif; --font-body: var(--font-display);--font-outlier: "Geist Mono", ui-monospace, monospace;--radius-card: 20px; --radius-input: 12px; --radius-pill: 999px; --rule-hair: 1px;diff --git a/skills/hallmark/scripts/sloplint-render.mjs b/skills/hallmark/scripts/sloplint-render.mjsindex 357d660..4d8b100 100644--- a/skills/hallmark/scripts/sloplint-render.mjs+++ b/skills/hallmark/scripts/sloplint-render.mjs@@ -9,6 +9,45 @@ const isUrl = (t) => /^https?:\/\//.test(t);const slugOf = (t) => isUrl(t) ? t.replace(/^https?:\/\//, '').replace(/[^\w.-]+/g, '-').replace(/-+$/, '') : basename(t, '.html');const SHOTS = [];+function contrast(a, b) {+ const lin = (c) => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4);+ const Y = (c) => 0.2126 * lin(c[0]) + 0.7152 * lin(c[1]) + 0.0722 * lin(c[2]);+ const x = Y(a), y = Y(b);+ return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05);+}++async function pixelBehind(page, probe) {+ try {+ const rect = await page.evaluate((n) => {+ 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');+ 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;+ await new Promise((r) => setTimeout(r, 60));+ 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);+ 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);+ const d = x.getImageData(0, 0, c.width, c.height).data;+ 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; }+}+async function shoot(page, file, tag, fullPage) {try {const dir = isUrl(file) ? join(process.cwd(), '.hallmark', 'shots') : join(dirname(file), '.hallmark', 'shots');@@ -77,7 +116,17 @@ export async function renderCheck(htmlFiles, metaIn) {if (width === 1280) await shoot(page, file, `${prefix}1280x800`, false);if (width === 375) await shoot(page, file, heroOnly ? 'hero-375x812' : '375', !heroOnly);const res = await page.evaluate(observe, width === 1280, pageMeta);- for (const f of res) findings.push({ ...f, file, line: 1, evidence: `[${width}px] ${f.evidence}` });+ const measured = new Map();+ for (const f of res) {+ if (f.probe == null) continue;+ if (!measured.has(f.probe)) measured.set(f.probe, await pixelBehind(page, f.probe));+ const bg = measured.get(f.probe);+ if (!bg) continue;+ const real = contrast(f.fg, bg);+ if (real >= f.threshold - 0.05) f.drop = true;+ else f.evidence = f.evidence.replace(/computed contrast [\d.]+:1/, `contrast ${real.toFixed(2)}:1 against the pixels behind`).replace(/\([\d.]+:1\)$/, `(${real.toFixed(2)}:1)`);+ }+ for (const f of res) if (!f.drop) { const { probe, fg, threshold, drop, ...rest } = f; findings.push({ ...rest, file, line: 1, evidence: `[${width}px] ${f.evidence}` }); }}for (const [w, h] of [[1440, 900], [1920, 1080]]) {await page.setViewport({ width: w, height: h });@@ -114,7 +163,7 @@ export async function renderCheck(htmlFiles, metaIn) {function observe(checkFold, meta) {meta = meta || { genre: null, posture: 'restrained' };const out = [];- const push = (gate, grade, evidence, fix) => out.push({ gate: String(gate), grade, evidence, fix });+ const push = (gate, grade, evidence, fix, extra) => out.push({ gate: String(gate), grade, evidence, fix, ...(extra || {}) });const describe = (el) => {const cls = (el.className && typeof el.className === 'string') ? '.' + el.className.trim().split(/\s+/).slice(0, 2).join('.') : '';return el.tagName.toLowerCase() + cls;@@ -233,7 +282,7 @@ function observe(checkFold, meta) {const seenSel = new Set();for (const el of document.querySelectorAll('body *')) {if (reported >= 10) break;- if (!visible(el)) continue;+ if (!visible(el) || el.closest('svg')) continue;const hasText = [...el.childNodes].some((n) => n.nodeType === 3 && n.textContent.trim().length > 2);if (!hasText) continue;const cs = getComputedStyle(el);@@ -244,24 +293,27 @@ function observe(checkFold, meta) {const weight = parseInt(cs.fontWeight, 10) || 400;const large = size >= 24 || (size >= 18 && weight >= 700);const threshold = large ? 3.0 : 4.5;- const r = ratio(fg, bg);const key = describe(el);+ 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'); }+ continue;+ }+ const r = ratio(fg, bg);if (r < threshold - 0.05 && !seenSel.has(key)) {seenSel.add(key);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}`,- 'Raise the contrast to threshold');+ 'Raise the contrast to threshold', probe);const btnish = el.closest('a, button, [class*="btn"], [class*="cta"]');if (btnish && r < 1.6) {push(41, 'FAIL', `button text ~ button fill on ${key} (${r.toFixed(2)}:1)`,- 'Use accent-ink or paper for the label');- }- } else if (!seenSel.has(key)) {- const worst = gradStops(el, bg).reduce((m, c) => Math.min(m, ratio(fg, c)), Infinity);- 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');+ 'Use accent-ink or paper for the label', probe);}}}diff --git a/skills/hallmark/scripts/theme.mjs b/skills/hallmark/scripts/theme.mjsindex a22471a..e066e6a 100644--- a/skills/hallmark/scripts/theme.mjs+++ b/skills/hallmark/scripts/theme.mjs@@ -85,6 +85,13 @@ function readLog(p) {try { const j = JSON.parse(readFileSync(p, 'utf8')); return Array.isArray(j) ? j : (j.runs || []); } catch { return []; }}+function contrastOf(f, b) {+ const rgb = ([L, C, H]) => { const h = H * Math.PI / 180, x = C * Math.cos(h), y = C * Math.sin(h); const l = (L + 0.3963377774 * x + 0.2158037573 * y) ** 3, m = (L - 0.1055613458 * x - 0.0638541728 * y) ** 3, s2 = (L - 0.0894841775 * x - 1.2914855480 * y) ** 3; return [4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s2, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s2, -0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s2].map((c) => Math.min(1, Math.max(0, c))); };+ const Y = (c) => 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];+ const a = Y(rgb(f)), c = Y(rgb(b));+ return (Math.max(a, c) + 0.05) / (Math.min(a, c) + 0.05);+}+const triple = (t) => `${t.paper.band}/${t.display.class}/${t.accent.band}`;const sameTriple = (a, b) => a === b;const words = (s) => (s || '').toLowerCase().replace(/[^a-z0-9\s-]/g, ' ').split(/\s+/).filter((w) => w.length > 2);@@ -317,6 +324,10 @@ function validate(files) {if (!existsSync(f.replace(/\.md$/, '.jpg'))) console.log(`${f}: note, no picture yet (scripts/picture.mjs)`);if (!/waive 22/.test(src)) for (const m of fence.matchAll(/(--color-(?:paper|paper-2|paper-3|ink|ink-2|muted|rule|rule-2)):\s*oklch\(\s*[\d.]+%\s+([\d.]+)/g)) if (Number(m[2]) < 0.005) problems.push(`${m[1]} chroma ${m[2]} is under the 0.005 floor (gate 22), or the file names waive 22`);for (const k of ['--color-paper', '--color-ink', '--color-muted', '--color-rule', '--color-accent', '--color-accent-ink', '--color-focus', '--font-display', '--font-body', '--radius-card', '--tracking-display']) if (!fence.includes(k + ':')) problems.push(`token block lacks ${k}`);+ const tok = {};+ for (const m of fence.matchAll(/(--color-[\w-]+):\s*oklch\(\s*([\d.]+)%\s+([\d.]+)\s+([\d.]+)\s*\)/g)) tok[m[1]] = [Number(m[2]) / 100, Number(m[3]), Number(m[4])];+ const pairs = [['--color-ink-2', '--color-paper'], ['--color-muted', '--color-paper'], ['--color-muted', '--color-paper-2'], ['--color-accent-ink', '--color-accent']];+ for (const [fg, bg] of pairs) if (tok[fg] && tok[bg]) { const r = contrastOf(tok[fg], tok[bg]); if (r < 4.5) problems.push(`${fg} on ${bg} is ${r.toFixed(2)}:1, under 4.5 (gate 40)`); }if (problems.length) { bad++; console.log(`${f}: ${problems.join('; ')}`); } else console.log(`${f}: ok (${e.name}, ${triple(e)}, ${src.length} bytes)`);} catch (err) { bad++; console.log(`${f}: ${err.message}`); }}