Skip to content

Commit a871a9f

Browse files
committed
feat(messages): distinguish category and label tags (left border vs pill)
1 parent 147b39a commit a871a9f

6 files changed

Lines changed: 49 additions & 17 deletions

File tree

plugins/messages/src/client/components/FilterToggles.stories.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,20 @@ export const LevelsFiltered: Story = {
3232
},
3333
}
3434

35-
export const BadgeColored: Story = {
35+
export const CategoryTags: Story = {
3636
args: {
3737
label: 'Category',
3838
items: ['a11y', 'lint', 'runtime', 'build'],
3939
active: new Set<string>(),
40-
badge: true,
40+
tag: 'category',
41+
},
42+
}
43+
44+
export const LabelTags: Story = {
45+
args: {
46+
label: 'Labels',
47+
items: ['axe', 'eslint', 'vite', 'hmr'],
48+
active: new Set<string>(),
49+
tag: 'label',
4150
},
4251
}

plugins/messages/src/client/components/FilterToggles.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<script setup lang="ts">
2-
import DisplayBadge from '@antfu/design/components/Display/DisplayBadge.vue'
2+
import MessageTag from './MessageTag.vue'
33
44
defineProps<{
55
label: string
66
items: string[]
77
active: Set<string>
88
/** Map item key → { icon, color, label } for styled (level/source) items. */
99
styles?: Record<string, { icon?: string, color?: string, label?: string }>
10-
/** Render items as hash-colored `DisplayBadge` chips (category/label). */
11-
badge?: boolean
10+
/** Render items as hash-colored `MessageTag` chips of this kind (category/label). */
11+
tag?: 'category' | 'label'
1212
}>()
1313
1414
defineEmits<{
@@ -29,14 +29,14 @@ function isDimmed(active: Set<string>, item: string): boolean {
2929
type="button"
3030
class="rounded flex items-center transition"
3131
:class="[
32-
badge ? 'p-0.5' : 'px-1.5 py-0.5 gap-0.5 text-xs',
33-
!badge && !isDimmed(active, item) ? (styles?.[item]?.color || '') : '',
32+
tag ? 'p-0.5' : 'px-1.5 py-0.5 gap-0.5 text-xs',
33+
!tag && !isDimmed(active, item) ? (styles?.[item]?.color || '') : '',
3434
isDimmed(active, item) ? 'op30 saturate-50' : '',
3535
]"
3636
@click="$emit('toggle', item)"
3737
>
38-
<template v-if="badge">
39-
<DisplayBadge :text="item" class="text-xs" />
38+
<template v-if="tag">
39+
<MessageTag :text="item" :kind="tag" />
4040
</template>
4141
<template v-else>
4242
<div v-if="styles?.[item]?.icon" :class="styles[item]!.icon" class="w-3.5 h-3.5" />

plugins/messages/src/client/components/MessageDetail.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<script setup lang="ts">
22
import type { DevframeMessageEntry, DevframeMessageEntryFrom } from '@devframes/hub/types'
33
import ActionIconButton from '@antfu/design/components/Action/ActionIconButton.vue'
4-
import DisplayBadge from '@antfu/design/components/Display/DisplayBadge.vue'
54
import FeedbackSpinner from '@antfu/design/components/Feedback/FeedbackSpinner.vue'
65
import LayoutSeparator from '@antfu/design/components/Layout/LayoutSeparator.vue'
76
import { useClipboard, useTimeAgo } from '@vueuse/core'
87
import { computed } from 'vue'
98
import { fromEntries, levels } from './message-styles'
9+
import MessageTag from './MessageTag.vue'
1010
1111
const props = defineProps<{
1212
entry: DevframeMessageEntry
@@ -92,8 +92,8 @@ function filePositionLabel(pos: NonNullable<DevframeMessageEntry['filePosition']
9292

9393
<!-- Category + Labels -->
9494
<div v-if="entry.category || entry.labels?.length" class="flex flex-wrap gap-1 mb-3">
95-
<DisplayBadge v-if="entry.category" :text="entry.category" as="button" class="text-xs cursor-pointer" @click="emit('toggleCategory', entry.category)" />
96-
<DisplayBadge v-for="label of entry.labels" :key="label" :text="label" as="button" class="text-xs cursor-pointer" @click="emit('toggleLabel', label)" />
95+
<MessageTag v-if="entry.category" :text="entry.category" kind="category" as="button" class="cursor-pointer" @click="emit('toggleCategory', entry.category)" />
96+
<MessageTag v-for="label of entry.labels" :key="label" :text="label" kind="label" as="button" class="cursor-pointer" @click="emit('toggleLabel', label)" />
9797
</div>
9898

9999
<!-- File position -->

plugins/messages/src/client/components/MessageFilterBar.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const { filters } = props
3838
label="Category"
3939
:items="filters.allCategories"
4040
:active="(filters.activeCategories as Set<string>)"
41-
badge
41+
tag="category"
4242
@toggle="filters.toggleCategory"
4343
/>
4444
</template>
@@ -49,7 +49,7 @@ const { filters } = props
4949
label="Labels"
5050
:items="filters.allLabels"
5151
:active="(filters.activeLabels as Set<string>)"
52-
badge
52+
tag="label"
5353
@toggle="filters.toggleLabel"
5454
/>
5555
</template>

plugins/messages/src/client/components/MessageItem.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script setup lang="ts">
22
import type { DevframeMessageEntry } from '@devframes/hub/types'
3-
import DisplayBadge from '@antfu/design/components/Display/DisplayBadge.vue'
43
import FeedbackSpinner from '@antfu/design/components/Feedback/FeedbackSpinner.vue'
54
import { useTimeAgo } from '@vueuse/core'
65
import { levels } from './message-styles'
6+
import MessageTag from './MessageTag.vue'
77
88
const props = defineProps<{
99
entry: DevframeMessageEntry
@@ -40,8 +40,8 @@ const timeAgo = useTimeAgo(() => props.entry.timestamp)
4040
{{ entry.description }}
4141
</div>
4242
<div v-if="!compact && (entry.category || entry.labels?.length)" class="flex flex-wrap items-center gap-1">
43-
<DisplayBadge v-if="entry.category" :text="entry.category" class="text-xs" />
44-
<DisplayBadge v-for="label of entry.labels" :key="label" :text="label" class="text-xs" />
43+
<MessageTag v-if="entry.category" :text="entry.category" kind="category" />
44+
<MessageTag v-for="label of entry.labels" :key="label" :text="label" kind="label" />
4545
</div>
4646
</div>
4747
</div>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<script setup lang="ts">
2+
import DisplayBadge from '@antfu/design/components/Display/DisplayBadge.vue'
3+
4+
// A hash-colored chip for an entry's category/label, distinguished by kind so
5+
// the two read apart at a glance: a `category` keeps a thicker left border,
6+
// a `label` renders as a rounded pill.
7+
defineProps<{
8+
text: string
9+
kind: 'category' | 'label'
10+
/** Render as another element (e.g. `button` for a clickable filter chip). */
11+
as?: string
12+
}>()
13+
</script>
14+
15+
<template>
16+
<DisplayBadge
17+
:text="text"
18+
:as="as"
19+
:rounded="kind === 'label' ? 'full' : 'md'"
20+
class="text-xs"
21+
:class="kind === 'category' ? 'border-l-2!' : ''"
22+
/>
23+
</template>

0 commit comments

Comments
 (0)