Align badge to architecture goals#200
Merged
Merged
Conversation
|
📚 Storybook preview: https://pr-200-propel-storybook.vamsi-906.workers.dev |
- Fixes pill shape: moves border-radius from per-magnitude slots into the cva base string as `rounded-full` (spec: "Pill shape — always the same"). - Adds required `variant` prop (BadgeVariant type, cva `variant` axis) with `solid` as the only current value; "outline" is noted in the spec as a potential future step — introducing the axis now keeps call sites forward-compatible (closes #119). - Drops the per-magnitude `rounded-sm`/`rounded-md` values; every step now inherits the full-radius base. - Updates all Badge call sites (badge stories + menu submenu story) to pass the now-required `variant` prop.
Break the badge into atomic single-element ui parts the way the accordion is: the Badge pill now renders only its container, with the leading icon, label, and the optional dismiss action each extracted into their own part (BadgeIcon, BadgeLabel, BadgeDismiss), each with its own cva. The ready-made components/badge composition wires them behind convenience props and carries no styling of its own.
BadgeDismiss baked a default X glyph via children ?? <X />. Per the single-element rule, a ui part renders only its child and bakes no glyph. The default X now lives in the components-tier Badge composition (passed in when onDismiss is set) and the ui story passes it explicitly.
a03d2be to
b8f1537
Compare
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.
Closes #119
What the designer's spec says
From the issue comment:
Always the same — baked into the cva base string, not props:
pill shape (full border-radius), inline-flex layout, centered content, gap-1, font-medium, whitespace-nowrap (single-line), leading-none (text-icon vertical alignment), and
--node-sizeper magnitude step.Depends (adjustable) — required props:
magnitude— S / Base / Large (height, padding, text size, node size)tone— color/sentiment (neutral, grey, brand, info, indigo, success, emerald, warning, yellow, danger, crimson, orange)variant— Solid (outline noted as a potential future value)children) and optional leading/trailing nodes (inlineStartNode,inlineEndNode)Changes
variants.tsrounded-fullinto the cva base string. Previously each magnitude slot had its ownrounded-sm/rounded-md; the spec is explicit that pill shape is "always the same," so it belongs in the invariant base, not the magnitude axis.variantcva axis with a singlesolidvalue. The spec lists "Variant: Solid (potentially outline)" as an adjustable axis; introducing it now means existing call sites opt in explicitly and "outline" can be added without a breaking prop change later.badge.tsxBadgeVarianttype (derived fromVariantProps<typeof badgeVariants>).variant: BadgeVariantas a required prop (nodefaultVariants, per the no-default-variants rule).variantthrough tobadgeVariants({ tone, magnitude, variant }).Stories (
ui/badge,components/badge,components/menu)variant: "solid"to metaargsin both badge story files.<Badge>usages inmenu.stories.tsx(Submenu demo) to pass the new required prop.Notes
rounded-sm/rounded-md→rounded-fullon all badge sizes. This corrects a spec deviation.variant: "solid"currently produces no additional classes (the cva entry is an empty string), so it is a zero-cost forward-compatibility hook.