xonecas.io
8058
Ir

irvc / commit 8b200cc

feat: light theme for flashbang enjoyers

xonecas2026-10-11 8b200ccfb5ec1e17415f7c01bc30ac3365ccece1 parent c14ee79

4 files changed

web/index.html+11−2
@@ -1,9 +1,18 @@
11 <!doctype html>
2-<html lang="en" class="dark">
2+<html lang="en">
33 <head>
44 <meta charset="UTF-8" />
55 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6- <meta name="color-scheme" content="dark" />
6+ <meta name="color-scheme" content="light dark" />
7+ <script>
8+ (function () {
9+ var t = localStorage.getItem("theme");
10+ if (t !== "light" && t !== "dark") {
11+ t = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
12+ }
13+ document.documentElement.classList.toggle("dark", t === "dark");
14+ })();
15+ </script>
716 <link
817 rel="icon"
918 href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' fill='%230a0806'/><circle cx='16' cy='16' r='5' fill='%23ffcc55'/></svg>"
web/src/index.css+50−8
@@ -5,10 +5,6 @@
55 @custom-variant dark (&:is(.dark *));
66
77 @theme {
8- --color-bg: #0a0806;
9- --color-panel: #120d09;
10- --color-sepia: #c39a63;
11- --color-gold: #ffcc55;
128 --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", monospace;
139 }
1410
@@ -20,8 +16,8 @@ body,
2016
2117 body {
2218 margin: 0;
23- background: var(--color-bg);
24- color: var(--color-sepia);
19+ background: var(--bg);
20+ color: var(--sepia);
2521 font-family: var(--font-mono);
2622 -webkit-font-smoothing: antialiased;
2723 }
@@ -30,13 +26,17 @@ body {
3026 width: 10px;
3127 }
3228 ::-webkit-scrollbar-thumb {
33- background: color-mix(in srgb, var(--color-sepia) 25%, transparent);
29+ background: color-mix(in srgb, var(--sepia) 25%, transparent);
3430 border-radius: 5px;
3531 }
3632
3733 @theme inline {
3834 --font-heading: var(--font-sans);
3935 --font-sans: ui-monospace, SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", monospace;
36+ --color-bg: var(--bg);
37+ --color-panel: var(--panel);
38+ --color-sepia: var(--sepia);
39+ --color-gold: var(--gold);
4040 --color-sidebar-ring: var(--sidebar-ring);
4141 --color-sidebar-border: var(--sidebar-border);
4242 --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
@@ -78,6 +78,49 @@ body {
7878 }
7979
8080 :root {
81+ --bg: #f4ecdf;
82+ --panel: #ebe1cf;
83+ --sepia: #6b4e2e;
84+ --gold: #a9791f;
85+ --background: #f4ecdf;
86+ --foreground: #6b4e2e;
87+ --card: #ebe1cf;
88+ --card-foreground: #6b4e2e;
89+ --popover: #ebe1cf;
90+ --popover-foreground: #6b4e2e;
91+ --primary: #a9791f;
92+ --primary-foreground: #f4ecdf;
93+ --secondary: #e3d8c4;
94+ --secondary-foreground: #6b4e2e;
95+ --muted: #e3d8c4;
96+ --muted-foreground: #8a6f4a;
97+ --accent: #ddd0b8;
98+ --accent-foreground: #5c4326;
99+ --destructive: #c0503c;
100+ --border: #d5c7ae;
101+ --input: #d5c7ae;
102+ --ring: #a9791f;
103+ --chart-1: #a9791f;
104+ --chart-2: #8a6f4a;
105+ --chart-3: #6b4e2e;
106+ --chart-4: #b8a582;
107+ --chart-5: #ddd0b8;
108+ --radius: 0.375rem;
109+ --sidebar: #efe6d7;
110+ --sidebar-foreground: #6b4e2e;
111+ --sidebar-primary: #a9791f;
112+ --sidebar-primary-foreground: #f4ecdf;
113+ --sidebar-accent: #e3d8c4;
114+ --sidebar-accent-foreground: #6b4e2e;
115+ --sidebar-border: #d5c7ae;
116+ --sidebar-ring: #a9791f;
117+}
118+
119+.dark {
120+ --bg: #0a0806;
121+ --panel: #120d09;
122+ --sepia: #c39a63;
123+ --gold: #ffcc55;
81124 --background: #0a0806;
82125 --foreground: #c39a63;
83126 --card: #120d09;
@@ -101,7 +144,6 @@ body {
101144 --chart-3: #8a6f4a;
102145 --chart-4: #4e3520;
103146 --chart-5: #241a10;
104- --radius: 0.375rem;
105147 --sidebar: #0e0a07;
106148 --sidebar-foreground: #c39a63;
107149 --sidebar-primary: #ffcc55;
web/src/lib/theme.ts+23−0
@@ -0,0 +1,23 @@
1+import { useCallback, useEffect, useState } from "react";
2+
3+export type Theme = "light" | "dark";
4+
5+function initial(): Theme {
6+ const saved = localStorage.getItem("theme");
7+ if (saved === "light" || saved === "dark") return saved;
8+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
9+}
10+
11+// useTheme keeps the `dark` class on <html> in sync, seeding from the OS on
12+// first visit. index.html applies the same choice before paint.
13+export function useTheme() {
14+ const [theme, setTheme] = useState<Theme>(initial);
15+
16+ useEffect(() => {
17+ document.documentElement.classList.toggle("dark", theme === "dark");
18+ localStorage.setItem("theme", theme);
19+ }, [theme]);
20+
21+ const toggle = useCallback(() => setTheme((t) => (t === "dark" ? "light" : "dark")), []);
22+ return { theme, toggle };
23+}
web/src/views/Chat.tsx+17−5
@@ -1,7 +1,8 @@
11 import { useEffect, useRef, useState } from "react";
2-import { LogOut, PanelRight, PanelRightClose } from "lucide-react";
2+import { Hash, LogOut, Moon, PanelRight, PanelRightClose, Sun, Volume2 } from "lucide-react";
33 import { Button } from "@/components/ui/button";
44 import { api } from "../lib/api";
5+import { useTheme } from "../lib/theme";
56 import { useVoice } from "../lib/voice";
67 import type { Channel, Message, User, UserSummary, WSEvent } from "../lib/types";
78 import ChatPane from "../components/ChatPane";
@@ -18,6 +19,7 @@ export default function Chat({ user, onLogout }: { user: User; onLogout: () => v
1819 const [showUsers, setShowUsers] = useState(true);
1920 const selectedId = useRef<number | null>(null);
2021 const voice = useVoice();
22+ const { theme, toggle } = useTheme();
2123
2224 useEffect(() => {
2325 selectedId.current = selected?.id ?? null;
@@ -69,16 +71,26 @@ export default function Chat({ user, onLogout }: { user: User; onLogout: () => v
6971 <Sidebar channels={channels} selected={selected} onSelect={setSelected} voice={voice} />
7072 <main className="flex min-w-0 flex-1 flex-col">
7173 <header className="flex items-center justify-between border-b border-sepia/15 px-4 py-2">
72- <span className="text-sm text-sepia/70">
73- {selected ? `${selected.type === "text" ? "#" : "🔊"} ${selected.name}` : ""}
74+ <span className="flex items-center gap-1.5 text-sm text-sepia/70">
75+ {selected && (selected.type === "text" ? <Hash size={14} /> : <Volume2 size={14} />)}
76+ {selected?.name}
7477 </span>
7578 <div className="flex items-center gap-1">
7679 {voice.channel && (
77- <span className="pr-2 text-xs text-sepia/50">
78- 🔊 {voice.channel.name}
80+ <span className="flex items-center gap-1 pr-2 text-xs text-sepia/50">
81+ <Volume2 size={12} />
82+ {voice.channel.name}
7983 {voice.muted ? " · muted" : ""}
8084 </span>
8185 )}
86+ <Button
87+ variant="ghost"
88+ size="icon-sm"
89+ onClick={toggle}
90+ title={theme === "dark" ? "light mode" : "dark mode"}
91+ >
92+ {theme === "dark" ? <Sun /> : <Moon />}
93+ </Button>
8294 <Button
8395 variant="ghost"
8496 size="icon-sm"