From 3141fadd5815155ec2a861978b6a1cdef662e003 Mon Sep 17 00:00:00 2001 From: "Anthony Fu (via agent)" Date: Fri, 14 Aug 2026 05:20:58 +0000 Subject: [PATCH] feat(hub,hub-ui): color a dock-bar entry's badge via badgeVariant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../client/components/dock/DockEntries.vue | 1 + .../components/dock/DockEntry.stories.ts | 7 +++++ .../src/client/components/dock/DockEntry.vue | 31 +++++++++++++++++-- .../components/dock/DockGroupButton.vue | 1 + packages/hub/src/types/docks.ts | 8 +++++ .../tsnapi/@devframes/hub/index.snapshot.d.ts | 2 ++ .../tsnapi/@devframes/hub/types.snapshot.d.ts | 1 + 7 files changed, 48 insertions(+), 3 deletions(-) diff --git a/packages/hub-ui/src/client/components/dock/DockEntries.vue b/packages/hub-ui/src/client/components/dock/DockEntries.vue index db5661c2..8c5a0045 100644 --- a/packages/hub-ui/src/client/components/dock/DockEntries.vue +++ b/packages/hub-ui/src/client/components/dock/DockEntries.vue @@ -77,6 +77,7 @@ function toggleDockEntry(dock: DevframeDockEntry) { :is-dimmed="dimInactive && selected ? (selected.id !== dock.id) : false" :is-vertical="isVertical" :badge="dock.badge" + :badge-variant="dock.badgeVariant" @click="toggleDockEntry(dock)" /> diff --git a/packages/hub-ui/src/client/components/dock/DockEntry.stories.ts b/packages/hub-ui/src/client/components/dock/DockEntry.stories.ts index 5eca6025..0bfc60ac 100644 --- a/packages/hub-ui/src/client/components/dock/DockEntry.stories.ts +++ b/packages/hub-ui/src/client/components/dock/DockEntry.stories.ts @@ -12,6 +12,7 @@ interface EntryArgs { isVertical?: boolean isAction?: boolean badge?: string + badgeVariant?: 'default' | 'info' | 'success' | 'warning' | 'danger' tooltip?: boolean } @@ -43,6 +44,7 @@ const meta = { isVertical: args.isVertical, isAction: args.isAction, badge: args.badge || undefined, + badgeVariant: args.badgeVariant, tooltip: args.tooltip, }))), ), @@ -67,6 +69,9 @@ export const Action: Story = { args: { isAction: true } } /** A count badge in the corner (e.g. pending items). */ export const WithBadge: Story = { args: { badge: '3' } } +/** A colored badge, e.g. flagging a state that needs attention. */ +export const WithBadgeVariant: Story = { args: { badge: '3', badgeVariant: 'warning' } } + /** Rotated for a left/right edge dock. */ export const Vertical: Story = { args: { isVertical: true } } @@ -81,6 +86,8 @@ export const States: Story = { h(DockEntry, { context: ctx, dock: sample, isDimmed: true }), h(DockEntry, { context: ctx, dock: sample, isAction: true }), h(DockEntry, { context: ctx, dock: sample, badge: '9+' }), + h(DockEntry, { context: ctx, dock: sample, badge: '2', badgeVariant: 'warning' }), + h(DockEntry, { context: ctx, dock: sample, badge: '5', badgeVariant: 'success' }), ])), ), }), diff --git a/packages/hub-ui/src/client/components/dock/DockEntry.vue b/packages/hub-ui/src/client/components/dock/DockEntry.vue index 8e76f0a9..c6c609e7 100644 --- a/packages/hub-ui/src/client/components/dock/DockEntry.vue +++ b/packages/hub-ui/src/client/components/dock/DockEntry.vue @@ -1,8 +1,8 @@