Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 5 additions & 1 deletion src/kit.css
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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)); }
Expand Down
51 changes: 51 additions & 0 deletions tests/focus.test.mjs
Original file line number Diff line number Diff line change
@@ -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/);
});
Loading