Skip to content

Align badge to architecture goals#200

Merged
lifeiscontent merged 3 commits into
mainfrom
align/badge
Jun 24, 2026
Merged

Align badge to architecture goals#200
lifeiscontent merged 3 commits into
mainfrom
align/badge

Conversation

@lifeiscontent

Copy link
Copy Markdown
Contributor

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-size per 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)
  • label text (children) and optional leading/trailing nodes (inlineStartNode, inlineEndNode)

Changes

variants.ts

  • Moved rounded-full into the cva base string. Previously each magnitude slot had its own rounded-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.
  • Added a variant cva axis with a single solid value. 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.
  • Cleaned up magnitude comments to remove the radius note (no longer relevant).

badge.tsx

  • Exported BadgeVariant type (derived from VariantProps<typeof badgeVariants>).
  • Added variant: BadgeVariant as a required prop (no defaultVariants, per the no-default-variants rule).
  • Passes variant through to badgeVariants({ tone, magnitude, variant }).

Stories (ui/badge, components/badge, components/menu)

  • Added variant: "solid" to meta args in both badge story files.
  • Updated the three <Badge> usages in menu.stories.tsx (Submenu demo) to pass the new required prop.

Notes

  • No visual change other than the corner radius: rounded-sm/rounded-mdrounded-full on 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.
  • Needs design approval from @bhaveshraja before merge.

@github-actions

Copy link
Copy Markdown

📚 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.
@lifeiscontent lifeiscontent merged commit e4f4bc1 into main Jun 24, 2026
2 checks passed
@lifeiscontent lifeiscontent deleted the align/badge branch June 24, 2026 10:42
Sign up for free to 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.

Badge: what should always look the same, and what should be adjustable?

1 participant