kernel: the shared toggle switch primitive (UI primitives, tier 3) - #462
Open
nyblnet wants to merge 1 commit into
Open
kernel: the shared toggle switch primitive (UI primitives, tier 3)#462nyblnet wants to merge 1 commit into
nyblnet wants to merge 1 commit into
Conversation
Tier 3, third of four, built AHEAD of a consumer on the maintainer's call — not a consolidation. The four-way read found the three "toggle"-named classes are three unrelated things (a native checkbox, a disclosure block body, a segmented button group); no shared on/off switch exists. DECISIONS records it as such. kernel/src/ui/toggle.ts is a real <button role="switch"> with aria-checked, so the platform gives it keyboard activation and a screen reader announces it as a switch — not mouse-only. Click toggles and fires onChange; set() updates state WITHOUT firing onChange (a set is the app's doing). The ON track is --accent, which apps deliberately do not invert, so it is the one chain checked for "defines" not "themes". Same discipline: --bks-* chains onto host tokens (--chrome-2 off-track, --accent on-track, --surface/--field knob), no light-dark(), shared theming guard. A GUARD IMPROVEMENT rides with it: scripts/lib/ui-theme-guard.ts now follows one level of alias indirection — a token defined as `--x: var(--y)` is themed iff --y is. dash writes `--chrome-2: var(--hover)` and --hover is themed via light-dark(); without this the guard read --chrome-2 as un-themed though it inverts at runtime. Adding to the themed set can only relax, never regress, and all five UI rigs re-run green against it (menu 118, panel 86, dialog 66, tooltip 34, toggle 61). test-ui-toggle 61 checks; role, click-toggle, aria, set-not-firing-onChange and destroy each mutation-caught. test-ci-registered 311. Built off main-with-#461, so ci.yml and DECISIONS append after the tooltip's, no rebase conflict.
Build size
Updated: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tier 3, third of four — built ahead of a consumer on the maintainer's call.
kernel/src/ui/toggle.ts+toggle.css, guarded byscripts/test-ui-toggle.ts.Kernel half only.
Not a consolidation
The four-way read found the three "toggle"-named classes are three unrelated
things — slides'
input.ed-toggleis a native checkbox, spaces'.sp-toggle-bodyis a disclosure block's body, type's
.t-togglesis a segmented button group.No shared switch exists;
DECISIONS.mdrecords this as built-ahead-of-a-consumer.What it gets right
A real
<button role="switch">witharia-checked— the platform gives itkeyboard activation and a screen reader announces it as a switch and its state,
so it is not mouse-only.
set()updates state without firingonChange(a setis the app's doing, not the user's). The ON track is
--accent, which appsdeliberately do not invert, so it is the one colour chain checked for "defines"
but not "themes".
A guard improvement rides with it
scripts/lib/ui-theme-guard.tsnow follows one level of alias indirection:a token defined as
--x: var(--y)is themed iff--yis. dash writes--chrome-2: var(--hover)and--hoveris themed vialight-dark()— withoutthis the guard read
--chrome-2as un-themed though it inverts at runtime.Adding to the themed set can only relax, never regress; all five UI rigs
re-run green against it (menu 118, panel 86, dialog 66, tooltip 34, toggle 61).
Verification
test-ui-toggle— 61 checks, mutation-caught:rolechanged off switch,click not toggling, aria not updated,
set()firingonChange, anddestroyleaving the listener each fail it.
--bks-*chains onto host tokens; nolight-dark().test-ci-registered311.Sequencing
Built off
main-with-#461, soci.yml/DECISIONSappend after the tooltip's —fast-forward, no rebase. Chip follows once this lands — the last of tier 3,
and the one with a real behaviour to shape against (dash's removable filter
chip).
No changelog line: a user notices nothing until an app adopts it.