feat(Switch, Checkbox, Radio): add padded variant + new Radio component#751
feat(Switch, Checkbox, Radio): add padded variant + new Radio component#751sadiqxansari wants to merge 9 commits into
Conversation
4a71f65 to
26dddf7
Compare
|
/barista review |
|
Re-reviewing per @netchampfaris. Concerns — new public surface drifts from the canonical
Non-blocking, verified fine:
Suggest: rename barista · claude-opus-4-8 · 66 in / 7.7k out · 1347k cached · 120s · $0.435 |
|
@sadiqxansari Add UI tests |
- Add `variant` prop (`default` | `padded`) — padded wraps the row in a clickable surface with hover, active and focus-visible ring states - Left-align the switch before the label for inline (default) rows; right-align when a description is present - Make the entire padded row clickable via a container click handler; guard against double-toggle from the label `for` attribute and the control itself using `data-slot` selectors - Use `has(:focus-visible)` instead of `focus-within` so the focus ring only appears on keyboard navigation, not mouse clicks - Add Variants, SettingsList and SettingsRows story examples - Regenerate Switch.api.md to include the new `variant` prop Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add `switchPosition` prop with automatic defaults — `left` for label-only rows, `right` when a description is present; explicit value always wins - Restore default variant layout to original (switch right, label left) so existing callers are unaffected; new prop required to opt in to left placement - Fix description rows: `items-start` → `items-center` so switch aligns with the label vertically - Padded variant: fixed height (`h-7` sm / `h-8` md) with `justify-center` instead of vertical padding, and `group` moved to outer container so hover applies across the entire row including corners - Focus ring switched from `focus-within` to `has(:focus-visible)` so it only appears on keyboard navigation - Replace grouped-toggles card example with a toolbar story showing the padded switch alongside Button components - Icons story: Notifications row now `justify-between` with switch right - Variants story: default row padded to align switch with padded row - Remove deprecated `change` emit section and LegacyChange story - Regenerate Switch.api.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rename the `switchPosition` values from physical `left`/`right` to logical `start`/`end` so the prop reads correctly under RTL (matching the codebase's `ps-`/`me-` logical-property convention). The underlying layout already used direction-aware `flex-row-reverse` / `justify-*`, so only the public values change. - `start` = leading side, `end` = trailing side - Auto default unchanged in behaviour: `start` for label-only rows, `end` when a description is present - Update the Icons story and regenerate Switch.api.md Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mirror the Switch padded variant so the two controls stay consistent. - Add a `variant` prop (`default` | `padded`); `padded` wraps the control and label in a clickable surface with hover, active and keyboard-only focus ring states, at a fixed 28px (sm) / 32px (md) row height. The checkbox always stays on the leading side - Make the whole padded row clickable via a container click handler, guarding against double-toggle from the input and the label `for` using `data-slot` selectors - Point the deprecated `padding` prop at `variant="padded"` - Add Variants, MemberList (selection list) and SettingsList example stories - Regenerate Checkbox.api.md Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- New Radio component mirroring Checkbox/Switch: size, variant, label, description, error, disabled, name, value props; v-model group selection - `padded` variant: 28/32px clickable surface, same tokens as Checkbox/Switch - Selected state: thick ring (4px sm / 4.5px md) + white hollow centre - All interaction states: hover, active, keyboard-only focus ring; disabled states use muted #ededed ring and #c7c7c7 centre - `required` intentionally omitted — asterisk belongs on the group heading; docs show the correct pattern in a new Required section - Stories: Default, Variants, Sizes, Labeling, Required, States, Settings list - Checkbox: px-2 → px-1.5 for sm padded; transition-colors on padded container - Switch: error/description text aligned with label (not switch) for switch-at-start rows; transition-colors on padded container - Radio padded container: transition-colors Co-Authored-By: Sadiq Ansari <sadiqxansari@gmail.com>
Co-Authored-By: Sadiq Ansari <sadiqxansari@gmail.com>
Co-Authored-By: Sadiq Ansari <sadiqxansari@gmail.com>
9261af0 to
90a5bbd
Compare
defineModel's setter already emits update:modelValue internally; the explicit emit() calls were firing it twice, causing the padded variant "does not double-toggle/select" Cypress tests to fail. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a
paddedvariant to Switch, Checkbox, and Radio — a clickable row surface with hover, active, and keyboard-only focus states. All three share the same tokens, 28/32px row heights, anddata-slotclick guards.variant+ RTL-safeswitchPosition(start/end). Error text now aligns with label (not the switch) on switch-at-start rows.variant,paddingdeprecated.px-2 → px-1.5on sm padded rows.value+namegroup selection; thick-ring/white-centre selected state (4px sm / 4.5px md);requiredomitted by design (asterisk belongs on the group heading). Stories: Variants, Sizes, Labeling, Required, States, Settings list.transition-colorsfor smooth hover.Default variants are unchanged; existing callers are unaffected.
Coverage: 56.14% (+0.11% vs
main)