feat: mp-3203-add a small size to KvSwitch - #902
Conversation
e24fbb6 to
68f79ba
Compare
|
We should probably add documentation using this prompt: |
dyersituations
left a comment
There was a problem hiding this comment.
Looks good pending using Skill to update docs.
|
I don't think this is related to this change specifically, but I noticed that the "disabled" functionality is not working: |
mcstover
left a comment
There was a problem hiding this comment.
Seems fine. We should make sure that Design knows about the updates as they are incorporating these into the design system
cristhianDt
left a comment
There was a problem hiding this comment.
LGTM , just add the link to the ticket please, or any additional confirmation by design/product team, thanks
Hey @eddieferrer, you're right. I just made a quick fix. It was only a Storybook issue, not component-related, so I think it's fine to include it here. |
|
@infante-jaime Need a small update to the Kitchen Sink story for the disabled state too: |
yes on it TY |
https://kiva.atlassian.net/browse/MP-3203
What this does
Adds a size prop to KvSwitch: default and small.
Checkout's tip-from-balance experiment needs a 48×28 switch per design, and KvSwitch hardcoded 56×32 with no way to change it — the consuming app is currently doing it with a scoped :deep override of the component's internals, which is the kind of thing this prop exists to remove.
The prop
Follows the KvButton size pattern: validated string, default | small, computed classes per size.
default — 56×32 track, 24px knob, 24px travel. Byte-for-byte the same classes as before, just moved from the static class attribute into the computed's default branch, so every existing consumer renders unchanged.
small — 48×28 track, 20px knob, 20px travel. The travel is derived from the geometry (track minus knob minus its margins), so the knob sits flush at both ends.
Tests
Both sizes pinned in the spec — including default, so a future change to the stock size fails a test instead of slipping through. The 53 pre-existing failures in unrelated suites are identical on main.
Story
Added a Small story and a size select control. This meant rewriting KvSwitch.stories.js to the modern args pattern (setup() { return { args }; }, as in KvButton.stories.js) — the old Vue 2-style props: Object.keys(argTypes) template was silently ignoring args in the current Storybook, so the existing Disabled story has been rendering an enabled switch. That's fixed as a side effect. The dead checked arg (never a real prop) and the console.log on change were dropped in the rewrite.
Consumer follow-up
Once this publishes, ui swaps its :deep override for size="small" (change already staged there, riding with the version bump).