Files
kevinveenbirkenbachandClaude Opus 5.5 f4e5d73cd0 fix(web-app-kix): draw the forced KIX focus ring from the design tokens
KIX ships its own application.css that forces every focus ring with outline:var(--focus-outline)!important and resolves --focus-outline once on :root from --focus-color, its green --primary-6 (120,190,90). The outline style.css declares on :root :focus-visible therefore never won, and every keyboard ring stayed KIX green. With the sidebar docked, the design spec now reaches the skip link in its keyboard walk and fails (push run 44939230779 KIX#0, test-design.js:348: keyboard stop a.skip-to-main sits on --design-frame, Expected rgb(255, 255, 255), Received rgb(120, 190, 90)). style.css now maps --focus-color and --focus-color-alternative onto --design-link-rgb and --design-on-frame-rgb, sets --focus-outline on the focused element from --design-focus so the focus token of a frame reaches the ring, and puts the skip link on the frame colours. test_design_focus.py checks the three mappings; the old sheet declares none of them. Tests: KIX unit tests plus design and CSS lints, 17 passed, 11 subtests.

🎯 Fix: 90 %
💥 Break: 3 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 87
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:37:19 +00:00

76 lines
2.3 KiB
Python

from __future__ import annotations
import re
import unittest
from utils.cache.files import read_text
from . import PROJECT_ROOT
STYLESHEET = PROJECT_ROOT / "roles" / "web-app-kix" / "files" / "style.css"
RULE = re.compile(r"([^{}]+)\{([^{}]*)\}")
def _rules() -> list[tuple[frozenset[str], dict[str, str]]]:
"""
Returns:
One entry per rule: its selectors and its declarations by property.
"""
rules = []
for selectors, body in RULE.findall(read_text(str(STYLESHEET))):
names = frozenset(" ".join(s.split()) for s in selectors.split(","))
declarations = {}
for declaration in body.split(";"):
name, _, value = declaration.partition(":")
if value:
declarations[name.strip()] = value.strip()
rules.append((names, declarations))
return rules
def _declared(selector: str, prop: str) -> list[str]:
"""
Args:
selector: a selector of the rule, whitespace collapsed.
prop: the property name.
Returns:
Every value declared for it, in stylesheet order.
"""
return [
declarations[prop]
for selectors, declarations in _rules()
if selector in selectors and prop in declarations
]
class TestDesignFocus(unittest.TestCase):
def test_kix_focus_colors_take_the_tokens(self) -> None:
self.assertIn("var(--design-link-rgb)", _declared(":root", "--focus-color"))
self.assertIn(
"var(--design-on-frame-rgb)",
_declared(":root", "--focus-color-alternative"),
)
def test_the_ring_follows_the_focus_token_of_its_frame(self) -> None:
for selector in (":root :focus", ":root :focus-within"):
with self.subTest(selector=selector):
self.assertIn(
"2px solid var(--design-focus, var(--design-link))",
_declared(selector, "--focus-outline"),
)
def test_the_skip_link_sits_on_the_frame(self) -> None:
self.assertIn(
"var(--design-frame)",
_declared("#kix-header .skip-to-main", "background-color"),
)
self.assertIn(
"var(--design-on-frame)",
_declared("#kix-header .skip-to-main", "color"),
)
if __name__ == "__main__":
unittest.main()