Skip to content

Commit df6a831

Browse files
refactor: extract GitHub link into reusable GithubLink component and remove Icon usage (#112)
1 parent 3f89eb4 commit df6a831

4 files changed

Lines changed: 30 additions & 40 deletions

File tree

components/app-footer.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
import { useTranslation } from "@/components/language-provider";
44
import { cn } from "@/lib/utils";
5-
import { Icon } from "./ui/button";
6-
import { FaGithub } from "react-icons/fa";
5+
import { GithubLink } from "./github-link";
76

87
export function AppFooter() {
98
const { t, dir } = useTranslation();
@@ -57,19 +56,7 @@ export function AppFooter() {
5756
>
5857
{t("footer.note")}
5958
</p>
60-
<a href="https://github.com/O2sa/DevImpact"
61-
target="_blank"
62-
rel="noopener noreferrer"
63-
aria-label="GitHub Repository">
64-
<Icon
65-
type="button"
66-
variant="ghost"
67-
size="sm"
68-
className="flex items-center gap-2"
69-
>
70-
<FaGithub className="text-black dark:text-white" />
71-
</Icon>
72-
</a>
59+
<GithubLink />
7360
</div>
7461
</div>
7562

components/github-link.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"use client";
2+
3+
import { Button } from "./ui/button";
4+
import { FaGithub } from "react-icons/fa";
5+
6+
export function GithubLink() {
7+
return (
8+
<a
9+
href="https://github.com/O2sa/DevImpact"
10+
target="_blank"
11+
rel="noopener noreferrer"
12+
aria-label="GitHub Repository"
13+
>
14+
<Button
15+
type="button"
16+
variant="ghost"
17+
size="sm"
18+
className="flex items-center gap-2"
19+
>
20+
<FaGithub className="text-black dark:text-white" />
21+
</Button>
22+
</a>
23+
);
24+
}

components/theme-toggle.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import { Moon, Sun } from "lucide-react";
44
import { useTheme } from "next-themes";
5-
import { Button, Icon } from "./ui/button";
65
import { useSyncExternalStore } from "react";
76
import { useTranslation } from "./language-provider";
8-
import { FaGithub } from "react-icons/fa";
7+
import { Button } from "./ui/button";
8+
import { GithubLink } from "./github-link";
99

1010
const emptySubscribe = () => () => { };
1111

@@ -44,19 +44,7 @@ export function ThemeToggle() {
4444
>
4545
{mounted && current === "dark" ? <Sun size={16} /> : <Moon size={16} />}
4646
</Button>
47-
<a href="https://github.com/O2sa/DevImpact"
48-
target="_blank"
49-
rel="noopener noreferrer"
50-
aria-label="GitHub Repository">
51-
<Icon
52-
type="button"
53-
variant="ghost"
54-
size="sm"
55-
className="flex items-center gap-2"
56-
>
57-
<FaGithub className="text-black dark:text-white" />
58-
</Icon>
59-
</a>
47+
<GithubLink />
6048

6149

6250
</div>

components/ui/button.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,4 @@ export function Button({ className, variant, size, ...props }: ButtonProps) {
3737
{...props}
3838
/>
3939
);
40-
}
41-
42-
export function Icon({ className, variant, size, ...props }: ButtonProps) {
43-
return (
44-
<button
45-
className={cn(buttonVariants({ variant, size }), className)}
46-
{...props}
47-
/>
48-
);
49-
}
40+
}

0 commit comments

Comments
 (0)