Skip to content

Commit 949ece1

Browse files
committed
Add GitHub ribbon component with star count and animation
1 parent 8f044f8 commit 949ece1

3 files changed

Lines changed: 68 additions & 0 deletions

File tree

src/components/GithubRibbon.tsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { createResource } from "solid-js";
2+
3+
export default function GithubRibbon() {
4+
const [stars] = createResource(async () => {
5+
const res = await fetch(
6+
"https://api.github.com/repos/Segfault-Club/segfault-club.github.io",
7+
);
8+
const data = await res.json();
9+
return data.stargazers_count;
10+
});
11+
12+
return (
13+
<a
14+
href="https://github.com/Segfault-Club/segfault-club.github.io"
15+
target="_blank"
16+
class="group absolute top-0 right-0"
17+
aria-label="View source on GitHub"
18+
>
19+
<div class="absolute top-1/2 -left-6 flex scale-0 items-center gap-1 rounded bg-black p-1 text-white transition group-hover:scale-100">
20+
<svg
21+
xmlns="http://www.w3.org/2000/svg"
22+
viewBox="0 0 24 24"
23+
stroke="currentColor"
24+
class="inline size-5"
25+
>
26+
<path d="M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.562.562 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.562.562 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z" />
27+
</svg>
28+
{stars() ? stars() : "Star us"}
29+
</div>
30+
<svg
31+
width="80"
32+
height="80"
33+
viewBox="0 0 250 250"
34+
class="group fill-slate-200 text-slate-950 transition hover:fill-white"
35+
aria-hidden="true"
36+
>
37+
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z" />
38+
<path
39+
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
40+
fill="currentColor"
41+
class="group-hover:animate-wave [transform-origin:130px_106px]"
42+
/>
43+
<path
44+
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
45+
fill="currentColor"
46+
/>
47+
</svg>
48+
</a>
49+
);
50+
}

src/index.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
@theme {
44
--font-logo: "Asimovian", sans-serif;
5+
--animate-wave: wave 560ms ease-in-out;
6+
7+
@keyframes wave {
8+
0%,
9+
100% {
10+
transform: rotate(0);
11+
}
12+
20%,
13+
60% {
14+
transform: rotate(-25deg);
15+
}
16+
40%,
17+
80% {
18+
transform: rotate(10deg);
19+
}
20+
}
521
}
622

723
@layer base {

src/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import { render } from "solid-js/web";
22
import "./index.css";
33

44
import Background from "./components/Background";
5+
import GithubRibbon from "./components/GithubRibbon";
56
import Main from "./sections/Main";
67
import Members from "./sections/Members";
78

89
const App = () => (
910
<>
1011
<Background src="/assets/Linux-user-Room.webp" />
12+
<GithubRibbon />
1113
<Main className="h-[80vh]" />
1214
<Members />
1315
</>

0 commit comments

Comments
 (0)