Thanks to visit codestin.com
Credit goes to github.com

Skip to content

kernel: the shared toggle switch primitive (UI primitives, tier 3) - #462

Open
nyblnet wants to merge 1 commit into
mainfrom
bento-ui-toggle
Open

kernel: the shared toggle switch primitive (UI primitives, tier 3)#462
nyblnet wants to merge 1 commit into
mainfrom
bento-ui-toggle

Conversation

@nyblnet

@nyblnet nyblnet commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Tier 3, third of four — built ahead of a consumer on the maintainer's call.
kernel/src/ui/toggle.ts + toggle.css, guarded by scripts/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-toggle is a native checkbox, spaces' .sp-toggle-body
is a disclosure block's body, type's .t-toggles is a segmented button group.
No shared switch exists; DECISIONS.md records this as built-ahead-of-a-consumer.

What it gets right

A real <button role="switch"> with aria-checked — the platform gives it
keyboard activation and a screen reader announces it as a switch and its state,
so it is not mouse-only. set() updates state without firing onChange (a set
is the app's doing, not the user's). The ON track is --accent, which apps
deliberately 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.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; all five UI rigs
re-run green
against it (menu 118, panel 86, dialog 66, tooltip 34, toggle 61).

Verification

  • test-ui-toggle61 checks, mutation-caught: role changed off switch,
    click not toggling, aria not updated, set() firing onChange, and destroy
    leaving the listener each fail it.
  • --bks-* chains onto host tokens; no light-dark().
  • test-ci-registered 311.

Sequencing

Built off main-with-#461, so ci.yml/DECISIONS append 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.

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.
@github-actions

Copy link
Copy Markdown

Build size

main (ad43bb3) → bento-ui-toggle (7f03c78)

app base PR change
bento/slides 691.7 KiB 691.7 KiB 0.0 KiB (0.00%)
bento/spaces 273.0 KiB 273.0 KiB 0.0 KiB (0.00%)
bento/dash 424.4 KiB 424.4 KiB 0.0 KiB (0.00%)

Updated: 2026-09-13T16:41:13Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant