Skip to content

Commit 98d78a4

Browse files
feat: update tag count display
1 parent a8d180f commit 98d78a4

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

app/share/page.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ export default function Share() {
3737
<h1>Share</h1>
3838
<div className="tag-bar">
3939
{sortedTags.map((tagItem, index) => (
40-
<Tag tag={tagItem.tag} key={index}>
41-
{`${tagItem.tag} (${tagItem.frequency.toString()})`}
42-
</Tag>
40+
<Tag tag={tagItem.tag} tagCount={tagItem.frequency} key={index} />
4341
))}
4442
</div>
4543
<TagFilteredList>

components/Tag.tsx

+11-7
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import { Suspense } from "react";
55

66
interface TagProps {
77
tag: string;
8+
tagCount: number;
89
disabled?: boolean;
9-
children?: string;
1010
}
1111

1212
/**
1313
* A tag component that can be used to filter content by tag.
1414
* If no children are provided, the tag string will be displayed.
1515
*/
16-
function SuspenseTag({ tag, disabled, children }: TagProps) {
16+
function SuspenseTag({ tag, tagCount, disabled }: TagProps) {
1717
const searchParams = useSearchParams();
1818
const pathname = usePathname();
1919
const { replace } = useRouter();
@@ -53,17 +53,21 @@ function SuspenseTag({ tag, disabled, children }: TagProps) {
5353
disabled ? "" : "enabled-tag"
5454
}`}
5555
>
56-
{children || tag}
56+
<span>{tag}</span>
57+
{tagCount > 1 ? (
58+
<>
59+
<span className="median-dot">·</span>
60+
<span className="tag-count">{tagCount}</span>
61+
</>
62+
) : null}
5763
</button>
5864
);
5965
}
6066

61-
export default function Tag({ tag, disabled, children }: TagProps) {
67+
export default function Tag({ tag, tagCount, disabled }: TagProps) {
6268
return (
6369
<Suspense>
64-
<SuspenseTag tag={tag} disabled={disabled}>
65-
{children}
66-
</SuspenseTag>
70+
<SuspenseTag tag={tag} tagCount={tagCount} disabled={disabled} />
6771
</Suspense>
6872
);
6973
}

styles/components/_tag.scss

+11-1
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,23 @@
2121
.tag {
2222
font-family: $font-bold;
2323
font-size: 0.8rem;
24-
display: inline-block;
2524
padding: 0.15em 0.6em;
2625
border: 1.6px solid transparent;
2726
border-radius: 0.7em;
2827
background-color: var(--collapsible-bg);
2928
color: inherit;
3029

30+
display: flex;
31+
gap: 0.4rem;
32+
align-items: baseline;
33+
34+
.tag-count,
35+
.median-dot {
36+
font-size: 0.7rem;
37+
font-family: $font-medium;
38+
color: var(--secondary-text-color);
39+
}
40+
3141
&.enabled-tag {
3242
cursor: pointer;
3343

0 commit comments

Comments
 (0)