Skip to content

Commit 5ae772f

Browse files
fix(contributor): circular icon hitbox (again) (#20)
* fix(contributors): social circles hitbox * solid sucks
1 parent 51a266d commit 5ae772f

File tree

2 files changed

+53
-32
lines changed

2 files changed

+53
-32
lines changed

src/components/contributors/Card.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -508,28 +508,28 @@ export const Card: ParentComponent<CardProps> = (props) => {
508508
{Object.entries(socials).map(([key, value], i) => {
509509
if (!value) return null;
510510
return (
511-
<CircularIcon size={30}>
512-
<a
513-
href={value}
514-
target="_blank"
515-
rel="noopener noreferrer"
516-
>
517-
{key === "github" && <GithubIcon size={20} />}
518-
{key === "twitter" && <TwitterIcon size={20} />}
519-
{key === "bluesky" && <BlueskyIcon size={18} />}
520-
{key === "instagram" && <InstagramIcon size={22} />}
521-
{key === "youtube" && <YoutubeIcon size={22} />}
522-
{key === "twitch" && (
523-
<TwitchIcon size={18} class="mt-[2px] mr-[2px]" />
524-
)}
525-
{key === "kofi" && <KofiIcon size={20} />}
526-
{key === "discord" && <DiscordIcon size={20} />}
527-
{key === "tiktok" && <TiktokIcon size={20} />}
528-
{key === "printables" && <PrintablesIcon size={18} />}
529-
{key === "steam" && <SteamIcon size={18} />}
530-
{key === "matrix" && <MatrixIcon size={16} />}
531-
{key === "website" && <WebsiteIcon size={20} />}
532-
</a>
511+
<CircularIcon
512+
size={30}
513+
element="a"
514+
href={value}
515+
target="_blank"
516+
rel="noopener noreferrer"
517+
>
518+
{key === "github" && <GithubIcon size={20} />}
519+
{key === "twitter" && <TwitterIcon size={20} />}
520+
{key === "bluesky" && <BlueskyIcon size={18} />}
521+
{key === "instagram" && <InstagramIcon size={22} />}
522+
{key === "youtube" && <YoutubeIcon size={22} />}
523+
{key === "twitch" && (
524+
<TwitchIcon size={18} class="mt-[2px] mr-[2px]" />
525+
)}
526+
{key === "kofi" && <KofiIcon size={20} />}
527+
{key === "discord" && <DiscordIcon size={20} />}
528+
{key === "tiktok" && <TiktokIcon size={20} />}
529+
{key === "printables" && <PrintablesIcon size={18} />}
530+
{key === "steam" && <SteamIcon size={18} />}
531+
{key === "matrix" && <MatrixIcon size={16} />}
532+
{key === "website" && <WebsiteIcon size={20} />}
533533
</CircularIcon>
534534
);
535535
})}
Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,42 @@
1-
import { JSX } from "solid-js";
1+
import { JSX, Match, Switch } from "solid-js";
22

33
type CircularIconProps = {
44
size: number;
55
children: JSX.Element;
66
class?: string;
7+
element?: "div" | "a";
8+
href?: string;
9+
target?: string;
10+
rel?: string;
711
};
812

913
export default function CircularIcon(props: CircularIconProps) {
14+
const BaseElement = props.element ?? "div";
15+
16+
const class_ = `bg-background-10 shadow-lg rounded-full flex items-center justify-center overflow-hidden ${props.class ?? ""}`;
17+
const style = {
18+
width: `${props.size}px`,
19+
height: `${props.size}px`,
20+
};
21+
1022
return (
11-
<div
12-
class={`bg-background-10 shadow-lg rounded-full flex items-center justify-center overflow-hidden ${props.class ? `${props.class}` : ""}`}
13-
style={{
14-
width: `${props.size}px`,
15-
height: `${props.size}px`,
16-
}}
17-
>
18-
{props.children}
19-
</div>
23+
<Switch>
24+
<Match when={BaseElement === "a"}>
25+
<a
26+
class={class_}
27+
style={style}
28+
href={props.href}
29+
target={props.target}
30+
rel={props.rel}
31+
>
32+
{props.children}
33+
</a>
34+
</Match>
35+
<Match when={BaseElement === "div"}>
36+
<div class={class_} style={style}>
37+
{props.children}
38+
</div>
39+
</Match>
40+
</Switch>
2041
);
2142
}

0 commit comments

Comments
 (0)