Skip to content

Commit c198c8a

Browse files
committed
feat(header): add showText option to GitHub button with 'Stars on GitHub' text
1 parent c2644c6 commit c198c8a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

components/business/app-header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export default function AppHeader() {
7777
</div>
7878
<div className="flex items-center gap-x-2 md:gap-x-5">
7979
<div className="hidden md:flex items-center gap-x-2 md:gap-x-5">
80-
<LinkGitHub className="group inline-flex" />
80+
<LinkGitHub showText={true} className="group inline-flex" />
8181
<LinkTwitter className="group inline-flex" />
8282
<ThemeToggle />
8383
</div>

components/business/buttons/link-github.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const CACHE_MS = 60 * 60 * 5000; // 5 hour
1010
let cachedStars: number | null = null;
1111
let cachedAt = 0;
1212

13-
export default function LinkGitHub({ className }: { className?: string }) {
13+
export default function LinkGitHub({ className, showText = false }: { className?: string; showText?: boolean }) {
1414
const [stars, setStars] = useState<number | null>(() => {
1515
if (cachedStars !== null && Date.now() - cachedAt < CACHE_MS) {
1616
return cachedStars;
@@ -72,16 +72,22 @@ export default function LinkGitHub({ className }: { className?: string }) {
7272
href={`https://github.com/${REPO}`}
7373
target="_blank"
7474
rel="noreferrer"
75-
title="View on GitHub"
75+
title="Stars on GitHub"
7676
className={cn(
7777
"inline-flex h-8 items-center gap-2 rounded-md px-3 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground shadow-none",
7878
className
7979
)}
8080
>
8181
<GitHubIcon className="h-4 w-4" />
82-
<span className="text-xs text-muted-foreground tabular-nums min-w-[2.5rem]" aria-live="polite">
83-
{renderStars()}
84-
</span>
82+
{showText ? (
83+
<span className="text-xs text-muted-foreground" aria-live="polite">
84+
Stars on GitHub
85+
</span>
86+
) : (
87+
<span className="text-xs text-muted-foreground tabular-nums min-w-[2.5rem]" aria-live="polite">
88+
{renderStars()}
89+
</span>
90+
)}
8591
</Link>
8692
);
8793
}

0 commit comments

Comments
 (0)