Skip to content

Commit 7ddd394

Browse files
committed
Add social icons and improve theme switching.
1 parent 45c5c3b commit 7ddd394

File tree

7 files changed

+88
-50
lines changed

7 files changed

+88
-50
lines changed

package-lock.json

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"@shoelace-style/shoelace": "^2.20.1",
1515
"astro": "^5.6.1",
1616
"sharp": "^0.34.2",
17+
"simple-icons": "^15.20.0",
18+
"solid-heroicons": "^3.2.4",
1719
"solid-js": "^1.9.10"
1820
},
1921
"devDependencies": {

src/components/SiteHeader.astro

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
---
2+
import SocialIcons from "@/components/SocialIcons.astro";
23
import ThemeSwitch from "@/components/ThemeSwitch.astro";
34
---
45

56
<header class="flex items-center justify-between h-14">
67
<div class="text-sm font-semibold tracking-tight">
7-
Rubinius
8+
<a href="/">Rubinius</a>
89
</div>
9-
<nav class="hidden md:flex gap-4 text-sm text-slate-200/80 items-end">
10-
<a href="/" class="text-black dark:text-white">Home</a>
11-
<a href="/blog" class="text-black dark:text-white">Blog</a>
12-
<a href="/docs" class="text-black dark:text-white">Docs</a>
10+
<nav class="hidden md:flex gap-4 text-sm items-end">
11+
<a href="/blog/">Blog</a>
12+
<a href="/docs/">Docs</a>
13+
14+
<SocialIcons />
1315
<ThemeSwitch />
1416
</nav>
1517
</header>

src/components/SocialIcons.astro

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
import { siBluesky, siGithub, siDiscord, siYoutube } from "simple-icons";
3+
4+
const icons = [
5+
{ icon: siBluesky, url: "https://bsky.app/profile/rubinius.com" },
6+
{ icon: siDiscord, url: "https://discord.gg/25GuZR4fBN" },
7+
// { icon: siYoutube, url: "" },
8+
{ icon: siGithub, url: "https://github.com/rubinius/" },
9+
];
10+
---
11+
12+
<div class="flex gap-2 items-end">
13+
{icons.map(({ icon, color, dark, url }) => (
14+
<a class="text-fg/60 rounded-sm hover:text-fg/100 hover:ring-1 hover:p-1 hover:ring-accent/60" href={url}>
15+
<svg fill="currentColor" viewBox="0 0 24 24" aria-label={icon.title} width="24" height="24">
16+
<path d={icon.path} />
17+
</svg>
18+
</a>
19+
))}
20+
</div>

src/components/ThemeBoot.astro

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@
3434

3535
// 4. Change theme on button press
3636
function selectTheme(theme) {
37+
const group = document.getElementById("theme-group");
38+
group.querySelectorAll('[aria-pressed]').forEach((btn) => {
39+
const isActive = btn.id === `theme-${theme}`;
40+
btn.setAttribute("aria-pressed", isActive ? "true" : "false");
41+
});
42+
3743
localStorage.setItem("theme", theme);
44+
3845
initTheme();
3946
}
4047

src/components/ThemeSwitch.astro

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
---
2+
import { createSignal, onMount } from "solid-js";
3+
import { Icon } from "solid-heroicons";
4+
import { sun, moon, computerDesktop } from "solid-heroicons/solid";
5+
26
const buttons = [
3-
{ id: "theme-light", value: "light", pressed: false },
4-
{ id: "theme-system", value: "system", pressed: false },
5-
{ id: "theme-dark", value: "dark", pressed: false },
7+
{ id: "theme-light", icon: sun, value: "light", pressed: false },
8+
{ id: "theme-system", icon: computerDesktop, value: "system", pressed: true },
9+
{ id: "theme-dark", icon: moon, value: "dark", pressed: false },
610
];
711
---
812

9-
<div class="flex gap-2" role="radiogroup">
10-
{buttons.map(({ id, value, pressed }) => (
11-
<button
12-
id={id}
13-
type="button"
14-
class="text-black border-black dark:text-white dark:border-white px-3 py-1.5 rounded-xl text-sm font-medium border"
15-
aria-pressed={pressed}
16-
>
17-
{value}
18-
</button>
13+
<div id="theme-group"
14+
class="flex gap-2 border border-fg/20 rounded-xl p-1 flex items-center" role="radiogroup">
15+
{buttons.map(({ id, icon, value, pressed }) => (
16+
<button
17+
id={id}
18+
type="button"
19+
class="inline-flex items-center justify-center text-fg/60 p-1 rounded-sm hover:text-fg/100 aria-[pressed=true]:ring-1 aria-[pressed=true]:ring-accent/60"
20+
aria-pressed={pressed}
21+
onclick={`selectTheme('${value}')`}
22+
>
23+
<Icon path={icon} class="h-5 w-5" />
24+
</button>
1925
))}
2026
</div>
21-
22-
<script is:inline>
23-
function attachThemeHandler(id, value) {
24-
const el = document.getElementById(id);
25-
if (el) el.addEventListener("click", () => selectTheme(value));
26-
}
27-
28-
attachThemeHandler("theme-light", "light");
29-
attachThemeHandler("theme-system", "system");
30-
attachThemeHandler("theme-dark", "dark");
31-
</script>

src/content/config.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,7 @@ const blog = defineCollection({
2222
}),
2323
});
2424

25-
const newsletters = defineCollection({
26-
type: "content",
27-
schema: z.object({
28-
issue: z.number().optional(),
29-
}),
30-
});
31-
32-
const papers = defineCollection({
33-
type: "content",
34-
schema: z.object({
35-
title: z.string(),
36-
subtitle: z.string().optional(),
37-
authors: z.array(z.string()),
38-
emails: z.array(z.string()),
39-
date: z.date(),
40-
tags: z.array(z.string()).optional(),
41-
}),
42-
});
43-
4425
export const collections = {
4526
blog: blog,
46-
newsletters: newsletters,
4727
docs: docs,
48-
papers: papers,
4928
};

0 commit comments

Comments
 (0)