Skip to content

feat(Tag): add a soft primary theme - #1421

Merged
tenphi merged 2 commits into
mainfrom
andrew/cub-4527-tag-soft-primary-theme
Sep 22, 2026
Merged

tenphi merged 2 commits into
mainfrom
andrew/cub-4527-tag-soft-primary-theme

Conversation

@tenphi

@tenphi tenphi commented Sep 22, 2026

Copy link
Copy Markdown
Member

Closes CUB-4527.

The gap

Tag renders the soft card — pale fill, tinted border, strong colored text — in default, danger, success, warning and note, but not in the brand hue. The one purple spelling, theme="special", is rewritten internally to default.primary, which is a solid fill — a different visual weight entirely.

So a design calling for a soft purple chip had no spelling in the kit. Cloud's bin/group editor settles for theme="note" and says so in a comment: soft, but one hue over — magenta 302.3 where the design wants primary 280.3.

The change

<Tag theme="primary"> now renders the soft chip at hue 280. special is untouched and still renders the solid fill.

It is small because Tag already built variant={`${theme}.${type}`} with type pinned to 'card' — the only thing missing was that key in the map. So: a PRIMARY_CARD_STYLES constant, one union member, one map entry, one value in the public enum, and no change to Tag's body at all.

Why primary and not special or default

Neither obvious spelling works, which is why the code carries a comment saying so:

  • not special.card — the item-themes special theme is a fixed-mode dark purple anchored on #special-surface with white text, so a card cut from it would be a dark chip.
  • not default.carddefault is the untinted path, so its card is the neutral grey one.
  • primary is the same brand theme with the tinted surface (palette.tsprimaryTheme), which is exactly what the three-token card shape needs.

Verification

Gate Result
pnpm test 2820 passed
pnpm test:types exit 0, zero errors
pnpm audit-docs --component=Tag 1/1 passed, 0 issues
pnpm size 526.92 kB — identical to the main baseline
pnpm chromatic:check budget passed

The strongest evidence is the computed colour from a real browser, not the eye:

  • Primary — bg oklch(0.2618 0.0089 280.3), text oklch(0.7636 0.12 280.3)
  • Note — the identical L and C at 302.3

Provably the same chip one hue over. It inverts correctly across all four scheme variants (light / dark / HC / dark+HC), tracking note's lightness within ~0.005, so it is contrast-safe wherever note.card already is. The isClosable action inherits the theme correctly (--current-color resolves to --primary-accent-text).

No new story — primary goes into the existing Themes matrix next to special, so the soft/solid pair reads as one comparison and costs no extra Chromatic snapshot.

Scope

Item's CARD_THEMES whitelist is deliberately unchanged. Tag reaches primary.card because it passes variant straight through rather than going via theme/type, so nothing warns. The consequence, documented in item-themes.ts rather than left latent: <Item type="card" theme="primary"> renders correctly but still emits the invalid-combination warning. Widening Item — which would give Alert, NotificationCard, Toast and ItemButton the same chip — is a clean follow-up.

item-themes.ts is internal, so the only public API change is Tag's theme enum. The widening of ItemVariant reaches consumers only through Item's variant prop, additively.

Follow-ups (not in this PR)

  1. Extend primary to Item's CARD_THEMES and the TypesAndThemes matrix.
  2. Flip the Cloud call site to theme="primary" and drop its // Workaround for CUB-4527 comment, once console-ui bumps its pin.
  3. Pre-existing drift, unrelated to this change: Tag's stories and docs both advertise a disabled theme that is not in the prop union and has no disabled.card variant — probing <Tag theme="disabled"> shows a fully transparent background, not the grey chip the docs promise. Worth its own issue.

🤖 Generated with Claude Code

`Tag` could render the soft card in `default`, `danger`, `success`,
`warning` and `note`, but not in the brand hue — `theme="special"` is
rewritten to `default.primary`, a solid fill. A design calling for a soft
purple chip had no spelling, so call sites borrowed `note` one hue over
(302.3 vs 280.3).

Adds `primary.card` to `ITEM_VARIANTS` and `primary` to `Tag`'s theme
enum. `Tag` already built `${theme}.${type}` with `type` pinned to
`card`, so there is no logic change. `special` is untouched.

The card is spelled `primary` rather than `special` because the
item-themes `special` theme is a fixed-mode dark purple with white text;
`default` is the untinted path, so its card is neutral grey. `primary`
is the brand theme carrying the tinted surface, which is what the
three-token card shape needs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cube-ui-kit Ready Ready Preview Sep 22, 2026 3:50pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c7f5c7c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cube-dev/ui-kit Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

📦 NPM canary release

Deployed canary version 0.0.0-canary-02bd39f.

@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

🧪 Storybook is successfully deployed!

@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

🏋️ Size limit report

Name Size Passed?
All 576.64 KB (+0.01% 🔺) Yes 🎉
Tree shaking (just a Button) 128.29 KB (+0.02% 🔺) Yes 🎉

Compared against main at 095f53crun 35745770032, 2026-09-22T15:13:05Z.

To see which modules changed, download the size-limit-statoscope-report artifact from this run and open report.html.

@tenphi
tenphi merged commit a8295d4 into main Sep 22, 2026
17 checks passed
@tenphi
tenphi deleted the andrew/cub-4527-tag-soft-primary-theme branch September 22, 2026 16:19
@tenphi tenphi mentioned this pull request Sep 22, 2026

This branch was successfully deployed

2 active deployments
Chromatic staging c7f5c7ca Deployed Sep 22, 2026 by tenphi via Prepare Storybook for review & tests #3851
Preview c7f5c7ca Deployed Sep 22, 2026 by vercel[bot]
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.

1 participant