Skip to content

Commit e104dae

Browse files
committed
Minor(modeling-commons): Use h4 only for tags pages headers and add number of times tagged
1 parent 2c376cb commit e104dae

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

apps/modeling-commons-frontend/app/components/model/list/ModelsListing.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="space-y-8">
3-
<slot name="header" />
3+
<slot name="header" :total-count="totalCount" />
44

55
<div class="flex gap-2 w-full flex-1">
66
<SearchBar v-if="props.showSearch" v-model="searchQuery" placeholder="Search models..." />

apps/modeling-commons-frontend/app/pages/tags/[name].vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<UContainer>
33
<ModelsListing :filters="filters">
4-
<template #header>
4+
<template #header="{ totalCount}">
55
<div v-if="tagStatus === 'pending'" class="space-y-2">
66
<div class="h-8 w-48 bg-accented rounded animate-pulse" />
77
<div class="h-4 w-64 bg-muted rounded animate-pulse" />
@@ -11,8 +11,7 @@
1111

1212
<div v-else-if="tag" class="space-y-2">
1313
<div class="flex items-center gap-3 flex-wrap">
14-
<TagChip :name="tag.name" :display-name="tag.displayName" :linkable="false" />
15-
<h4 class="tracking-tight">{{ tag.displayName }}</h4>
14+
<h4 class="tracking-tight">{{ tag.displayName }} <span v-if="totalCount" class="text-md text-muted">(tagged {{ pluralizeWithCount(totalCount, 'time') }})</span></h4>
1615
</div>
1716
<p class="text-sm text-muted">
1817
Models tagged with <span class="font-medium">{{ tag.displayName }}</span>

apps/modeling-commons-frontend/app/utils/formatters.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ export function pluralize(count: number, singular: string, plural?: string): str
7272
return `${numberFormatter.format(count)} ${plural || singular + "s"}`;
7373
}
7474

75+
export function pluralizeWithCount(count: number, singular: string, plural?: string): string {
76+
if (count === 1) return `1 ${singular}`;
77+
return `${numberFormatter.format(count)} ${plural || singular + "s"}`;
78+
}
79+
7580
export function capitalize(str: string): string {
7681
return str.charAt(0).toUpperCase() + str.slice(1);
7782
}

0 commit comments

Comments
 (0)