diff --git a/package-lock.json b/package-lock.json index 7e4fafa..24233b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@addiscorp/kit", - "version": "0.3.0", + "version": "0.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@addiscorp/kit", - "version": "0.3.0", + "version": "0.3.1", "license": "MIT", "devDependencies": { "@types/react": "19.2.7", diff --git a/package.json b/package.json index a6f68c5..384b0a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@addiscorp/kit", - "version": "0.3.0", + "version": "0.3.1", "description": "The header, footer, theme and tool-site layout every Addis site shares, in each project's own brand colours.", "license": "MIT", "type": "module", diff --git a/src/kit.css b/src/kit.css index c569356..d291b18 100644 --- a/src/kit.css +++ b/src/kit.css @@ -51,6 +51,10 @@ .ak-top-center { position: relative; } .ak-anchor { position: relative; } .ak-topbar :focus-visible, .ak-help :focus-visible { outline: 2px solid var(--ak-accent); outline-offset: 3px; } +/* Text fields never draw a focus ring (Sami, 14 Nov): the caret shows where you are typing. + Zero specificity, so a site can still style its own fields on purpose. */ +:where(input, textarea, select):focus, :where(input, textarea, select):focus-visible, +.ak-topbar :is(input, textarea, select):focus-visible, .ak-help :is(input, textarea, select):focus-visible { outline: none; box-shadow: none; } .ak-profile-btn, .ak-icon-btn, .ak-launcher { border: 0; color: var(--ak-ink); cursor: pointer; background: transparent; font: inherit; } .ak-profile-btn, .ak-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; padding: 0; } @@ -77,7 +81,7 @@ .ak-popover.ak-end { left: auto; right: 0; } .ak-popover p { margin: 0; } -.ak-search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--ak-accent); border-radius: 10px; padding: 0 10px; background: var(--ak-ground); color: var(--ak-soft); } +.ak-search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--ak-edge); border-radius: 10px; padding: 0 10px; background: var(--ak-ground); color: var(--ak-soft); } .ak-search input { flex: 1; min-width: 0; height: 40px; border: 0; outline: none; background: transparent; color: var(--ak-ink); font: inherit; } .ak-search input::placeholder { color: var(--ak-soft); } .ak-group-label { margin: 14px 4px 8px; font-size: 11px; color: color-mix(in srgb, var(--ak-soft) 72%, var(--ak-ground)); } diff --git a/tests/focus.test.mjs b/tests/focus.test.mjs new file mode 100644 index 0000000..ca94748 --- /dev/null +++ b/tests/focus.test.mjs @@ -0,0 +1,51 @@ +// Text fields never draw a focus ring (Sami, 14 Nov 2026): not the kit's +// search box, and not any input, textarea or select on a site that loads kit.css. +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; + +const css = readFileSync(new URL('../dist/kit.css', import.meta.url), 'utf8'); + +/** A selector list split at its own commas, not the ones inside :where(…) or :is(…). */ +function splitTopLevel(list) { + const parts = []; + let depth = 0, start = 0; + for (let i = 0; i < list.length; i++) { + if (list[i] === '(') depth++; + else if (list[i] === ')') depth--; + else if (list[i] === ',' && depth === 0) { parts.push(list.slice(start, i)); start = i + 1; } + } + parts.push(list.slice(start)); + return parts; +} + +/** Every rule's declarations for a selector, as one string (whitespace-normalised). */ +function rulesFor(selector) { + const out = []; + for (const m of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) { + const selectors = splitTopLevel(m[1].replace(/\/\*[\s\S]*?\*\//g, '')).map((s) => s.trim().replace(/\s+/g, ' ')); + if (selectors.includes(selector)) out.push(m[2]); + } + return out.join(';'); +} + +test('fields lose the outline and the ring shadow when focused, at zero specificity', () => { + for (const sel of [':where(input, textarea, select):focus', ':where(input, textarea, select):focus-visible']) { + const decl = rulesFor(sel); + assert.match(decl, /outline:\s*none/, sel); + assert.match(decl, /box-shadow:\s*none/, sel); + } +}); + +test('the top bar and help panel ring buttons and links, never their fields', () => { + assert.match(rulesFor('.ak-topbar :is(input, textarea, select):focus-visible'), /outline:\s*none/); + assert.match(rulesFor('.ak-help :is(input, textarea, select):focus-visible'), /outline:\s*none/); + // Buttons and links keep theirs: keyboard users still see where they are. + assert.match(rulesFor('.ak-topbar :focus-visible'), /outline:\s*2px solid/); +}); + +test('the menu search box has a quiet border, not the accent ring', () => { + const decl = rulesFor('.ak-search'); + assert.match(decl, /border:\s*1px solid var\(--ak-edge\)/); + assert.doesNotMatch(decl, /--ak-accent/); +});