Skip to content

Commit 9e87506

Browse files
committed
refactor: enhance badge color handling and update spacing in speaking page
1 parent 69c89a3 commit 9e87506

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

app/pages/posts/index.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ defineOgImageComponent('Saas')
1919
const activePost = useState<number | null>('activePost', () => null)
2020
2121
// Map badge labels to colors for visual variety
22-
const badgeColors: Record<string, 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'error' | 'neutral'> = {
22+
type BadgeColor = 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'error' | 'neutral'
23+
type BadgeVariant = 'solid' | 'outline' | 'soft' | 'subtle'
24+
25+
const badgeColors: Record<string, BadgeColor> = {
2326
development: 'primary',
2427
tips: 'success',
2528
tutorial: 'warning',
@@ -29,24 +32,24 @@ const badgeColors: Record<string, 'primary' | 'secondary' | 'success' | 'info' |
2932
announcement: 'error'
3033
}
3134
32-
function getBadgeWithColor(badge: string | { label?: string, color?: string } | undefined) {
35+
function getBadgeWithColor(badge: string | { label?: string, color?: BadgeColor, variant?: BadgeVariant } | undefined) {
3336
if (!badge) return undefined
3437
if (typeof badge === 'string') {
3538
const color = badgeColors[badge.toLowerCase()] || 'primary'
36-
return { label: badge, color, variant: 'subtle' }
39+
return { label: badge, color, variant: 'subtle' as const }
3740
}
3841
// If badge is already an object, add color if not present
3942
const label = badge.label || badge
4043
const color = badge.color || badgeColors[String(label).toLowerCase()] || 'primary'
41-
return { ...badge, color, variant: badge.variant || 'subtle' }
44+
return { ...badge, color, variant: badge.variant || 'subtle' as const }
4245
}
4346
</script>
4447

4548
<template>
4649
<UContainer>
4750
<UPageHeader
4851
v-bind="page"
49-
class="py-[50px]"
52+
class="py-12.5"
5053
/>
5154

5255
<UPageBody>

app/pages/speaking.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function formatDate(date?: string) {
126126
<UPageHeader
127127
:title="page?.title || 'Speaking'"
128128
:description="page?.description"
129-
class="py-[50px]"
129+
class="py-12.5"
130130
>
131131
<template #headline>
132132
<UBadge

0 commit comments

Comments
 (0)