From 018e2b93b4655cdab8d645dbd829bc0d73a9ef8f Mon Sep 17 00:00:00 2001 From: dvcolomban Date: Mon, 10 Aug 2026 19:37:32 +0200 Subject: [PATCH 1/2] feat(core): color a dock-bar entry's badge via a new badgeVariant field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DockEntry's badge has always been a plain count with a fixed gray fill — no way to distinguish, at a glance, "this count is provisional" from "this is the settled value". json-render's own Tabs component already solved this one level down (TabDescriptor.badgeVariant, with a real variant→color map); this carries that same variant set up to the dock-bar entry itself. badgeVariant is declared via the existing DevframeDockEntryRegistry declaration-merge pattern this package already uses, staying optional so every existing badge consumer keeps its current look unchanged. DockEntry.vue falls back to its pre-existing bg-gray-6/text-white classes at 'default'/ unset, and only switches to an inline-styled fill (reusing Tabs.ts's own colors map) for a non-default variant. --- .../components/dock/DockEntries.vue | 1 + .../components/dock/DockEntry.stories.ts | 7 +++++++ .../components/dock/DockEntry.vue | 19 +++++++++++++++++-- packages/kit/src/types/docks.ts | 14 ++++++++++++++ .../@vitejs/devtools-kit/index.snapshot.d.ts | 1 + 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/packages/core/src/client/webcomponents/components/dock/DockEntries.vue b/packages/core/src/client/webcomponents/components/dock/DockEntries.vue index 299d628e3..c67ccf1f4 100644 --- a/packages/core/src/client/webcomponents/components/dock/DockEntries.vue +++ b/packages/core/src/client/webcomponents/components/dock/DockEntries.vue @@ -77,6 +77,7 @@ function toggleDockEntry(dock: DevToolsDockEntry) { :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/core/src/client/webcomponents/components/dock/DockEntry.stories.ts b/packages/core/src/client/webcomponents/components/dock/DockEntry.stories.ts index 5eca60252..07642fc68 100644 --- a/packages/core/src/client/webcomponents/components/dock/DockEntry.stories.ts +++ b/packages/core/src/client/webcomponents/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. a staged-but-unapplied override count, warning-orange until it reloads. */ +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/core/src/client/webcomponents/components/dock/DockEntry.vue b/packages/core/src/client/webcomponents/components/dock/DockEntry.vue index a94574bd6..9546a8031 100644 --- a/packages/core/src/client/webcomponents/components/dock/DockEntry.vue +++ b/packages/core/src/client/webcomponents/components/dock/DockEntry.vue @@ -1,8 +1,9 @@