Skip to content

Commit 7c30d51

Browse files
authored
Merge pull request #34 from chingu-x/dev
fix: social button icon 404
2 parents 70de63b + 0776ee1 commit 7c30d51

File tree

4 files changed

+44
-38
lines changed

4 files changed

+44
-38
lines changed

public/discord.svg

Lines changed: 0 additions & 5 deletions
This file was deleted.

public/github.svg

Lines changed: 0 additions & 4 deletions
This file was deleted.

public/linkedin.svg

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/social-button/SocialButton.tsx

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,55 @@ type SocialButtonVariant = "github" | "linkedin" | "discord";
77
interface SocialButtonProps
88
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
99
variant: SocialButtonVariant;
10+
size?: number;
1011
}
1112

13+
const Icons = {
14+
github: ({ size = 24 }) => (
15+
<svg
16+
fill="#181717"
17+
role="img"
18+
viewBox="0 0 24 24"
19+
width={size}
20+
height={size}
21+
xmlns="http://www.w3.org/2000/svg"
22+
>
23+
<path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" />
24+
</svg>
25+
),
26+
linkedin: ({ size = 24 }) => (
27+
<svg
28+
fill="#0077B5"
29+
role="img"
30+
viewBox="0 0 24 24"
31+
width={size}
32+
height={size}
33+
xmlns="http://www.w3.org/2000/svg"
34+
>
35+
<path d="M22.23 0H1.77C.79 0 0 .78 0 1.75v20.5C0 23.22.79 24 1.77 24h20.46c.98 0 1.77-.78 1.77-1.75V1.75C24 .78 23.21 0 22.23 0zM7.06 20.5H3.56V9h3.5v11.5zM5.31 7.75c-1.12 0-2.02-.9-2.02-2s.91-2 2.02-2c1.12 0 2.02.9 2.02 2s-.91 2-2.02 2zM20.5 20.5h-3.5V14c0-1.55-.03-3.54-2.15-3.54-2.16 0-2.49 1.69-2.49 3.43v6.61h-3.5V9h3.36v1.58h.05c.47-.89 1.63-1.83 3.36-1.83 3.6 0 4.27 2.37 4.27 5.45v6.3z" />
36+
</svg>
37+
),
38+
discord: ({ size = 24 }) => (
39+
<svg
40+
fill="#5865F2"
41+
role="img"
42+
viewBox="0 0 24 24"
43+
width={size}
44+
height={size}
45+
xmlns="http://www.w3.org/2000/svg"
46+
>
47+
<path d="M20.317 4.3698A19.791 19.791 0 0 0 15.705 3c-.396.75-.848 1.815-1.153 2.682a18.971 18.971 0 0 0-5.104 0A13.162 13.162 0 0 0 8.296 3a19.792 19.792 0 0 0-4.612 1.369C1.191 8.106.501 11.735.825 15.306c1.942 1.53 3.813 2.458 5.675 3.081a14.978 14.978 0 0 0 1.227-1.962 12.292 12.292 0 0 1-1.938-.935c.162-.12.32-.246.473-.375 3.744 1.751 7.795 1.751 11.512 0 .153.129.311.255.473.375-.621.373-1.264.698-1.938.935a14.972 14.972 0 0 0 1.227 1.962c1.862-.623 3.733-1.551 5.675-3.081.39-4.014-.65-7.643-2.273-10.936zM8.02 14.76c-1.202 0-2.183-1.109-2.183-2.476 0-1.365.96-2.482 2.183-2.482 1.226 0 2.197 1.117 2.197 2.482 0 1.367-.971 2.476-2.197 2.476zm7.96 0c-1.202 0-2.183-1.109-2.183-2.476 0-1.365.96-2.482 2.183-2.482 1.226 0 2.197 1.117 2.197 2.482 0 1.367-.971 2.476-2.197 2.476z" />
48+
</svg>
49+
),
50+
};
51+
1252
export default function SocialButton({
1353
variant,
1454
className,
55+
size = 24,
1556
...props
1657
}: SocialButtonProps) {
17-
const getContent = (
18-
variant: SocialButtonVariant,
19-
): { icon: string; alt: string } => {
20-
if (variant === "github")
21-
return {
22-
icon: "/github.svg",
23-
alt: "github",
24-
};
25-
26-
if (variant === "linkedin")
27-
return {
28-
icon: "/linkedin.svg",
29-
alt: "linkedin",
30-
};
31-
else
32-
return {
33-
icon: "/discord.svg",
34-
alt: "discord",
35-
};
36-
};
37-
38-
const content = getContent(variant);
58+
const Icon = Icons[variant];
3959

4060
return (
4161
<button
@@ -44,11 +64,10 @@ export default function SocialButton({
4464
"flex h-[100px] w-[100px] flex-col items-center justify-center gap-x-2 gap-y-[5px] rounded-lg border-2 border-base-100 bg-base-200 text-sm font-medium capitalize text-base-300 hover:border-base-100 hover:bg-base-content focus:bg-base-content focus:text-black active:bg-base-content",
4565
className,
4666
)}
47-
aria-label={`sign in or sign up with ${content.alt}`}
67+
aria-label={`sign in or sign up with ${variant}`}
4868
{...props}
4969
>
50-
<img src={content.icon} alt={content.alt} />
51-
{content.alt}
70+
<Icon size={size} />
5271
</button>
5372
);
5473
}

0 commit comments

Comments
 (0)