[Feature] RubyUI 2.0 — Phase 2.1: the hard components first
What
The first components on the 2.0 layer — Dialog (8 classes), Toggle and ToggleGroup (3), Select (8), Data Table (14 + 3 adapters untouched) and ThemeToggle (1) — each a plain Ruby class inheriting RubyUI::Component beside an .html.erb sidecar. Their 22 golden scenarios are byte-identical to the frozen 1.6 snapshots in both the canonical and the strict form, through the ERB fixtures Phase 2.0b wrote; the scenarios' Phlex blocks are gone (the Kit methods they called no longer exist). No snapshot, fixture or Stimulus controller changed.
Before any of that, docs/ is pinned to the gem at main's commit 92f2619 (a git source with glob:), so the site keeps building unchanged while the gem migrates (Phase 3.3 points it back). Not RubyGems 1.6.0, which is 21 files behind main (decision 15).
Three layer changes the first sidecars needed, each measured before it was written (plan §"What this plan measured"): mixed_attrs, the nested hash a component forwards to a neighbour (decision 11); render_in drops the sidecar file's final newline, which was reaching the page as a text node inside every parent — the check is read once per compiled Template, not per render (decision 12); a class without a sidecar renders its nearest ancestor's, so a host's MyButton < RubyUI::Button keeps working, and a class directly under a component root finds its own (decision 13). Plus ComponentTest#erb, an inline template compiled through Herb for unit tests, and #descriptor.
Every unit test of the five families is ported to the ERB helper, none deleted; the enumerated arguments (DialogContent#size, Toggle/ToggleGroup variant and size, ToggleGroup type and orientation) accept their String form and refuse unknown values, with tests; SelectValue keeps whitespace-only content as Phlex did; DataTableSortHead's href keeps Phlex's javascript: guard; every caller-supplied attribute value goes through Attributes.flat, so nil omits it and a Symbol dasherizes as in 1.6.
Decisions 11–15 recorded; spec §4.3, §6 Phase 2.0, §6.2.1, §6.2.2, §9.2 amended; follow-up 1's Herb note corrected; follow-up 12 (the MCP registry's description fallback now reads a sidecar) filed for 2.2. The plan was reviewed by Codex before execution (ten findings, verified and folded in — plan Appendix B), executed task by task with a review after each, and given a whole-branch review whose two findings are the last three commits.
Stacked on #554 (Phase 2.0b), which is stacked on #548 (2.0a) and #536 (the ruler).
Why
Spec §6 Phase 2.1: the hard components first, so a design error in the layer surfaces now rather than at component 55. It did surface three (decisions 11–13), each a one-place fix, and the review found a fourth (the per-render source read), fixed the same way.
Test steps
From gem/: bundle exec rake → 779 runs, 0 failures, 0 skips; bundle exec rake golden → 388 runs (166 Phlex-lane, 188 ERB-lane, 7 coverage, 27 of the ruler's own); bundle exec standardrb → 427 files, no offenses. git diff --stat v2/fixtures -- gem/test/golden/snapshots gem/test/golden/strict gem/test/golden/views 'gem/lib/ruby_ui/**/*.js' → empty. cd mcp && bundle exec exe/ruby-ui-mcp-build && git diff --exit-code data/registry.json → clean. The CI Docs job builds docs/ against the gem at main's 92f2619.
Read first: the four composite sidecars — dialog_content.html.erb, data_table_column_toggle.html.erb, data_table_sort_head.html.erb, data_table_pagination.html.erb — they are decision 12's readability test.
Plan: design/plans/2026-09-20-phase-2-1-hard-components-implementation.md.
🤖 Generated with Claude Code
Summary by cubic
Migrates Dialog, Toggle/ToggleGroup, Select, DataTable, and ThemeToggle from Phlex to the RubyUI 2.0 layer: each is now a plain Ruby class inheriting RubyUI::Component with an .html.erb sidecar, rendering byte-identical to the frozen 1.6 snapshots in all 22 golden scenarios.
Layer changes
- Adds
mixed_attrs, the nested Symbol-keyed hash a component forwards to a neighbor component, sodata-actionconcatenates as it did in 1.6 instead of producing two attributes. render_innow drops the sidecar file's final newline, read once per compiled template rather than per render.- A class without a sidecar renders its nearest ancestor's, so host subclasses like
MyButton < RubyUI::Buttonkeep working. - Adds
ComponentTest#erb, an inline template compiled through Herb for unit tests, and#descriptorfor Stimulus matching.
Behavior details
- Enumerated arguments (
DialogContent#size,Toggle/ToggleGroupvariant and size,ToggleGrouptype and orientation) accept String form and raise on unknown values instead of silently falling back to defaults. SelectValuekeeps whitespace-only content;DataTableSortHeadkeeps Phlex'sjavascript:href guard; nil attributes are omitted and Symbol keys dasherize throughAttributes.flat.docs/is pinned to the gem atmain's commit since RubyGems 1.6.0 is behind main; it points back atpath:in Phase 3.3.- No snapshots, fixtures, or Stimulus controllers changed; all unit tests are ported to the ERB helper, none deleted.