diff --git a/frontend/index.html b/frontend/index.html
index ddf21f9..f9e4be9 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -3,7 +3,7 @@
-
+
Art IoT
diff --git a/frontend/src/pages/Account.tsx b/frontend/src/pages/Account.tsx
index 96ae57c..3571f92 100644
--- a/frontend/src/pages/Account.tsx
+++ b/frontend/src/pages/Account.tsx
@@ -61,6 +61,31 @@ function MyPermissions() {
);
}
+function AppearanceSection() {
+ const theme = useApp((s) => s.theme);
+ const setTheme = useApp((s) => s.setTheme);
+ return (
+
+ );
+}
+
export default function Account() {
const me = useApp((s) => s.me)!;
const toast = useApp((s) => s.toast);
@@ -91,6 +116,7 @@ export default function Account() {
return (
<>
+
diff --git a/frontend/src/store.ts b/frontend/src/store.ts
index 7d6d277..ab08ad7 100644
--- a/frontend/src/store.ts
+++ b/frontend/src/store.ts
@@ -1,11 +1,29 @@
import { create } from "zustand";
import type { Me } from "./types";
+export type Theme = "light" | "dark";
+
+const THEME_KEY = "artiot-theme";
+
+function applyTheme(theme: Theme) {
+ document.documentElement.dataset.theme = theme;
+ document
+ .querySelector('meta[name="theme-color"]')
+ ?.setAttribute("content", theme === "dark" ? "#1b211f" : "#f9faf9");
+}
+
+// Light unless the user chose dark before; applied at module load, before
+// the first render, so the login screen is themed too.
+const initialTheme: Theme = localStorage.getItem(THEME_KEY) === "dark" ? "dark" : "light";
+applyTheme(initialTheme);
+
/** Auth + app-shell state (zustand). Server data lives in TanStack Query. */
interface AppState {
me: Me | null;
authChecked: boolean; // finished the initial /api/me probe
setMe: (me: Me | null) => void;
+ theme: Theme;
+ setTheme: (theme: Theme) => void;
toasts: { id: number; text: string; tone: "info" | "error" }[];
toast: (text: string, tone?: "info" | "error") => void;
dismissToast: (id: number) => void;
@@ -17,6 +35,12 @@ export const useApp = create((set) => ({
me: null,
authChecked: false,
setMe: (me) => set({ me, authChecked: true }),
+ theme: initialTheme,
+ setTheme: (theme) => {
+ localStorage.setItem(THEME_KEY, theme);
+ applyTheme(theme);
+ set({ theme });
+ },
toasts: [],
toast: (text, tone = "info") => {
const id = ++toastId;
diff --git a/frontend/src/styles.css b/frontend/src/styles.css
index dcb25ba..bb6fa53 100644
--- a/frontend/src/styles.css
+++ b/frontend/src/styles.css
@@ -32,29 +32,30 @@
--label-track: 0.11em;
}
-@media (prefers-color-scheme: dark) {
- :root {
- --paper: #131816;
- --panel: #1b211f;
- --panel-inset: #161c1a;
- --ink: #e4e9e7;
- --ink-dim: #93a09b;
- --line: #2c3531;
- --copper: #d07a3e;
- --copper-deep: #b25c28;
- --live: #2fae7c;
- --blue: #4f8ee8;
- --amber: #d99a1b;
- --red: #d8503f;
- --lamp-off: #39433f;
- --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 18px rgb(0 0 0 / 0.35);
- --dropshadow: drop-shadow(0 1px 2px rgb(0 0 0 / 0.45)) drop-shadow(0 4px 10px rgb(0 0 0 / 0.35));
- }
+/* Dark is opt-in via the Account switch (persisted in localStorage);
+ light is the default regardless of the OS preference. */
+:root[data-theme="dark"] {
+ --paper: #131816;
+ --panel: #1b211f;
+ --panel-inset: #161c1a;
+ --ink: #e4e9e7;
+ --ink-dim: #93a09b;
+ --line: #2c3531;
+ --copper: #d07a3e;
+ --copper-deep: #b25c28;
+ --live: #2fae7c;
+ --blue: #4f8ee8;
+ --amber: #d99a1b;
+ --red: #d8503f;
+ --lamp-off: #39433f;
+ --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 18px rgb(0 0 0 / 0.35);
+ --dropshadow: drop-shadow(0 1px 2px rgb(0 0 0 / 0.45)) drop-shadow(0 4px 10px rgb(0 0 0 / 0.35));
}
* { box-sizing: border-box; margin: 0; }
-html { color-scheme: light dark; }
+html { color-scheme: light; }
+html[data-theme="dark"] { color-scheme: dark; }
body {
background: var(--paper);
@@ -391,6 +392,33 @@ button, input, select { font: inherit; color: inherit; border-radius: 0; }
.formrow { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); margin-bottom: 12px; }
+/* Slide switch, squared like everything else — a slider on the panel face. */
+.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; cursor: pointer; }
+.switch__label { font-weight: 500; }
+.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
+.switch__track {
+ width: 42px; height: 22px; flex: none;
+ border: 1px solid var(--line);
+ background: var(--panel-inset);
+ padding: 2px;
+ display: inline-flex;
+ transition: background 0.15s, border-color 0.15s;
+}
+.switch__thumb {
+ width: 16px; height: 16px;
+ background: var(--ink-dim);
+ transition: transform 0.15s, background 0.15s;
+}
+.switch input:checked + .switch__track {
+ background: color-mix(in srgb, var(--copper) 15%, transparent);
+ border-color: var(--copper);
+}
+.switch input:checked + .switch__track .switch__thumb {
+ transform: translateX(20px);
+ background: var(--copper);
+}
+.switch input:focus-visible + .switch__track { outline: 2px solid var(--copper); outline-offset: 2px; }
+
.check { display: flex; align-items: center; gap: 9px; padding: 4px 0; cursor: pointer; }
.check input { accent-color: var(--copper); width: 16px; height: 16px; flex: none; }
.check--strong { font-weight: 600; }