refactor(ui,settings): Round D — SettingsSegmented primitive + retire 4 hand-rolled radiogroup helpers - #268
Merged
Conversation
… 4 hand-rolled radiogroup helpers @WAWQAQ msg `f1461d30` 「用库的应该用库」: continue collapsing the hand-rolled wrappers in SettingsModal.tsx into shared `@maka/ui` primitives. **New primitive.** `packages/ui/src/primitives/settings-segmented.tsx` wraps Base UI's `ToggleGroup` (single-select by default). Caller's `className` (legacy `.settingsSegmented`) still owns the visual chrome — the primitive only contributes Base UI's behavior contract. **Migration.** SettingsModal's `function Segmented` is gone (3 call sites use the imported primitive aliased as `Segmented` so their markup is byte-identical). `.settingsSegmented button[data-active= "true"]` → `[data-pressed]` to match Base UI's Toggle state attribute. **Helper retirement.** With Theme/Palette migrated via #263 (`ChoiceCard`) and Segmented migrated here, the four hand-rolled keyboard-nav helpers in SettingsModal — `onSettingsRadioGroupKeyDown`, `focusRadioValue`, `radioTabIndex`, and the `nextRadioId` import — are all dead. Removed. `nextRadioId` itself stays in `model-table-keyboard.ts` because ProvidersPanel's model default picker keeps its hand-rolled radiogroup; that's a separate lane. **Contract test pivot.** The keyboard-nav assertion in `settings-theme-contract.test.ts` flips from "Segmented uses the legacy helpers" → "Segmented imports SettingsSegmented from @maka/ui; the local function Segmented declaration is gone; the 4 hand-rolled helpers are gone". Same regression-prevention intent, pinned one layer up. All test suites pass: ✔ Settings theme page contract (6/6) ✔ renderer style pruning contract (2/2)
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.
Summary
@WAWQAQ msg `f1461d30` 「用库的应该用库」: continue collapsing the hand-rolled wrappers in SettingsModal.tsx into shared @maka/ui primitives.
Primitive
packages/ui/src/primitives/settings-segmented.tsxwraps Base UI'sToggleGroup(single-select by default). Caller'sclassName(legacy.settingsSegmented) still owns the visual chrome — the primitive only contributes Base UI's behavior contract.Migration
function Segmenteddeleted from SettingsModal. 3 call sites use the imported primitive aliased asSegmentedso their JSX is byte-identical..settingsSegmented button[data-active=\"true\"]→[data-pressed](Base UI's Toggle state attribute).Helper retirement
With Theme/Palette migrated via #263 (
ChoiceCard) and Segmented migrated here, all four hand-rolled keyboard-nav helpers in SettingsModal are dead:onSettingsRadioGroupKeyDown,focusRadioValue,radioTabIndex— deleted.nextRadioIdimport — deleted from SettingsModal.nextRadioIditself stays inmodel-table-keyboard.tsbecause ProvidersPanel's model default picker keeps its hand-rolled radiogroup.Contract test pivot
Keyboard-nav assertion in
settings-theme-contract.test.tsflips: was 'Segmented uses the legacy helpers' → 'Segmented imports SettingsSegmented; the local function Segmented declaration is gone; the 4 hand-rolled helpers are gone'.Test plan
pnpm -F @maka/ui build— clean.tsc --noEmit -p apps/desktop/tsconfig.renderer.json— only the pre-existing unrelated TS2366.settings-theme-contract.test.ts— 6/6 pass.renderer-style-pruning-contract.test.ts— 2/2 pass.