Skip to content

refactor(ui,settings): move SettingsSwitch adapter to @maka/ui primitive - #265

Merged
jackwener merged 1 commit into
mainfrom
yuejing/switch-primitive-and-css-cleanup
Jun 25, 2026
Merged

refactor(ui,settings): move SettingsSwitch adapter to @maka/ui primitive#265
jackwener merged 1 commit into
mainfrom
yuejing/switch-primitive-and-css-cleanup

Conversation

@jackwener

Copy link
Copy Markdown
Member

Summary

@WAWQAQ msg f1461d30 「用库的应该用库」: keep collapsing local hand-rolled wrappers into shared @maka/ui primitives.

The 17-line Switch adapter inside SettingsModal.tsx that reshapes Base UI's { checked, onCheckedChange, aria-label } API into the settings-toggle { ariaLabel, checked, onChange, disabled, ariaDescribedBy } shape moves to packages/ui/src/primitives/settings-switch.tsx as SettingsSwitch.

SettingsModal.tsx imports it aliased as Switch so all 15+ call sites stay byte-identical:

import{SettingsSwitchasSwitch,}from'@maka/ui';

The other <Switch> consumer in packages/ui/src/components.tsx:2290 already uses Base UI's direct API (<Switch checked={false} disabled aria-label=\"…\" />) and stays untouched — it's not a settings-row toggle.

Test plan

  • pnpm -F @maka/ui build — clean.
  • tsc --noEmit -p apps/desktop/tsconfig.renderer.json — only pre-existing unrelated TS2366.
  • renderer-style-pruning-contract.test.ts — 2/2 pass (kenji's selector inventory guard found no new orphan CSS).

@WAWQAQ msg `f1461d30`「用库的应该用库」: keep collapsing local
hand-rolled wrappers into shared `@maka/ui` primitives.
The 17-line `Switch` adapter inside SettingsModal.tsx that reshapes
Base UI's `{ checked, onCheckedChange, aria-label }` API into the
settings-toggle `{ ariaLabel, checked, onChange, disabled,
ariaDescribedBy }` shape now lives at
`packages/ui/src/primitives/settings-switch.tsx` as `SettingsSwitch`.
SettingsModal imports it aliased as `Switch` so all 15+ call sites
stay byte-identical:
import { SettingsSwitch as Switch, … } from '@maka/ui';
The local `function Switch` is gone (replaced with a 4-line breadcrumb
comment pointing at the new home).
The other `<Switch>` consumer in `packages/ui/src/components.tsx:2290`
already uses Base UI's direct API (`<Switch checked={false} disabled
aria-label="…" />`) and stays untouched — it's not a settings-row
toggle.
Verified clean:
✔ @maka/ui build
✔ tsc -p apps/desktop/tsconfig.renderer.json (only pre-existing
unrelated TS2366)
✔ renderer-style-pruning-contract.test.ts 2/2 (kenji's selector
inventory guard found no new orphan CSS)
@jackwener
jackwener merged commit 5c7b2ac into mainJun 25, 2026
@jackwener
jackwener deleted the yuejing/switch-primitive-and-css-cleanup branch June 25, 2026 18:53
Sign up for freeto 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

@jackwener