Skip to content

feat(hub,hub-ui): color a dock-bar entry's badge via badgeVariant - #216

Merged
antfu merged 1 commit into
mainfrom
feat/dock-badge-variant
Aug 14, 2026
Merged

feat(hub,hub-ui): color a dock-bar entry's badge via badgeVariant#216
antfu merged 1 commit into
mainfrom
feat/dock-badge-variant

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Why

DockEntry's badge is a plain string label with a fixed neutral fill — no way to color it. json-render's own Tabs component already supports this one level down (TabDescriptor.badgeVariant), but the dock-bar entry itself has no equivalent, even though it's the same kind of label.

Port of vitejs/devtools#528 by @dvcolomban, closing #214.

What changed

  • badgeVariant?: 'default' | 'info' | 'success' | 'warning' | 'danger' added directly to DevframeDockEntryBase in packages/hub/src/types/docks.ts. The original PR added this via a declare module '@devframes/hub/types' merge from a separate augmenting package (@vitejs/devtools-kit) — that split doesn't exist here, since the augmenting and augmented packages are both @devframes/hub already, so the field lands on the base type directly.
  • packages/hub-ui/src/client/components/dock/DockEntry.vue threads the new prop through and applies it as an inline fill, mirroring json-render's Badge.ts variant→color naming (info/success/warning/danger).
  • DockEntries.vue and DockGroupButton.vue (both feed DockEntry) pass badgeVariant through alongside the existing badge.
  • DockEntry.stories.ts gets a WithBadgeVariant story plus an entry in States.
  • Backward-compatible by construction: DockEntry.vue falls back to its pre-existing bg-primary text-white classes at 'default'/unset, and only switches to an inline-styled fill for an explicit non-default variant — every existing badge consumer keeps its current look, unchanged.
  • Updated the @devframes/hub tsnapi snapshots for the new exported type/field.

Credit

Original implementation and design by @dvcolomban in vitejs/devtools#528 — co-authored here.


Created with the help of an agent.

Port of vitejs/devtools#528 by @dvcolomban, adapted for this repo's own
split into `@devframes/hub` (types) and `@devframes/hub-ui` (dock
components) — the field lands directly on `DevframeDockEntryBase`
rather than via a cross-package `declare module` augmentation, since
the augmenting and augmented packages both live here now.

`badgeVariant?: 'default' | 'info' | 'success' | 'warning' | 'danger'`
mirrors json-render's `TabDescriptor.badgeVariant` / `Badge.ts` variant
naming. `DockEntry.vue` applies it as an inline fill, falling back to
the existing neutral classes at `'default'`/unset so every current
badge consumer keeps its look. Threaded through `DockEntries.vue` and
`DockGroupButton.vue`, with new stories in `DockEntry.stories.ts`.

Closes #214.

Co-authored-by: Dinh-Van Colomban <dinh-van.colomban@contentsquare.com>
@netlify

netlify Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit 3141fad
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a7ea5dc9ad85d0008ca6ef1
😎 Deploy Preview https://deploy-preview-216--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@antfu
antfu merged commit e3c6fe7 into main Aug 14, 2026
12 checks passed
@antfu
antfu deleted the feat/dock-badge-variant branch August 14, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants