11<script setup lang="ts">
2- import type { DevframeDockEntryBase } from ' @devframes/hub'
2+ import type { DevframeDockBadgeVariant , DevframeDockEntryBase } from ' @devframes/hub'
33import type { DocksContext } from ' @devframes/hub/client'
44import { useEventListener } from ' @vueuse/core'
5- import { useTemplateRef } from ' vue'
5+ import { computed , useTemplateRef } from ' vue'
66import { setFloatingTooltip } from ' ../../state/floating-tooltip'
77import { openDockContextMenu } from ' ./DockContextMenu'
88import DockIcon from ' ./DockIcon.vue'
@@ -16,13 +16,33 @@ const props = withDefaults(
1616 isDimmed? : boolean
1717 isVertical? : boolean
1818 badge? : string
19+ badgeVariant? : DevframeDockBadgeVariant
1920 tooltip? : boolean
2021 }>(),
2122 {
2223 tooltip: true ,
2324 },
2425)
2526
27+ // Mirrors json-render's `Badge` variant→color-name map (see
28+ // `@devframes/json-render-ui`'s `Badge.ts`), applied as an inline fill since
29+ // the dock bar doesn't pull in json-render-ui's `DisplayBadge` component.
30+ // `undefined` at `'default'`/unset keeps the existing `bg-primary text-white`
31+ // classes below — every existing badge consumer keeps its current look.
32+ const badgeColors: Record <Exclude <DevframeDockBadgeVariant , ' default' >, { bg: string , fg: string }> = {
33+ info: { bg: ' #3b82f6' , fg: ' #eff6ff' },
34+ success: { bg: ' #22c55e' , fg: ' #f0fdf4' },
35+ warning: { bg: ' #f59e0b' , fg: ' #fffbeb' },
36+ danger: { bg: ' #ef4444' , fg: ' #fef2f2' },
37+ }
38+
39+ const badgeStyle = computed (() => {
40+ if (! props .badgeVariant || props .badgeVariant === ' default' )
41+ return undefined
42+ const { bg, fg } = badgeColors [props .badgeVariant ]
43+ return { backgroundColor: bg , color: fg }
44+ })
45+
2646const button = useTemplateRef <HTMLButtonElement >(' button' )
2747
2848function updateTooltip() {
@@ -87,7 +107,12 @@ useEventListener('pointerdown', () => {
87107 class =" flex items-center justify-center p1.5 hover:bg-[#8881] hover:scale-110 transition-all duration-300 relative outline-none"
88108 >
89109 <DockIcon :icon =" dock .icon " class="w-5 h-5 select-none" />
90- <div v-if =" badge" class =" absolute top-0.5 right-0 bg-primary text-white text-0.6em px-1 rounded-full shadow" >
110+ <div
111+ v-if =" badge"
112+ class =" absolute top-0.5 right-0 text-0.6em px-1 rounded-full shadow"
113+ :class =" badgeStyle ? '' : 'bg-primary text-white'"
114+ :style =" badgeStyle"
115+ >
91116 {{ badge }}
92117 </div >
93118 </button >
0 commit comments