Darstellung: Dark Mode mit Schalter in den Einstellungen
Alle Farben in app.css sind Variablen (--ink, --paper, ...); dunkel folgt dem System oder dem Schalter (theme.ts, localStorage). Hintergrund im Dunkeln: Asphalt-Textur unter leichtem Schleier. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TiXsPUqw7oeomZ8wZrQW5q
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
20c17cbf81
commit
74f3ed6e31
@@ -1,19 +1,55 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useAuthChanged, useMe } from "../auth";
|
||||
import { useFormAction } from "../useFormAction";
|
||||
import { AuthBox } from "../components/AuthBox";
|
||||
import { loadTheme, saveTheme, type Theme } from "../theme";
|
||||
|
||||
// SettingsPage: Kontoeinstellungen (Name, Passwort, Löschen). Profilbild, Header und
|
||||
// Beschreibung bearbeitet man auf dem eigenen Profil.
|
||||
// SettingsPage: Darstellung (auch ohne Konto) und Kontoeinstellungen (Name,
|
||||
// Passwort, Löschen). Profilbild, Header und Beschreibung bearbeitet man auf
|
||||
// dem eigenen Profil.
|
||||
export function SettingsPage() {
|
||||
const me = useMe();
|
||||
if (!me.isSuccess) return null;
|
||||
if (!me.data) return <AuthBox />;
|
||||
return <Settings />;
|
||||
return (
|
||||
<>
|
||||
<section id="settings">
|
||||
<h2>Einstellungen</h2>
|
||||
<Appearance />
|
||||
{me.data && <AccountSettings />}
|
||||
</section>
|
||||
{me.isSuccess && !me.data && <AuthBox />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Settings() {
|
||||
const themes: { value: Theme; label: string }[] = [
|
||||
{ value: "system", label: "Wie das System" },
|
||||
{ value: "light", label: "Hell" },
|
||||
{ value: "dark", label: "Dunkel" },
|
||||
];
|
||||
|
||||
function Appearance() {
|
||||
const [theme, setTheme] = useState(loadTheme);
|
||||
const pick = (t: Theme) => {
|
||||
saveTheme(t);
|
||||
setTheme(t);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<h3>Darstellung</h3>
|
||||
<div className="row" role="group" aria-label="Darstellung">
|
||||
{themes.map((t) => (
|
||||
<button key={t.value} aria-pressed={theme === t.value} onClick={() => pick(t.value)}>
|
||||
{t.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function AccountSettings() {
|
||||
const qc = useQueryClient();
|
||||
const navigate = useNavigate();
|
||||
const authChanged = useAuthChanged();
|
||||
@@ -38,9 +74,7 @@ function Settings() {
|
||||
});
|
||||
|
||||
return (
|
||||
<section id="settings">
|
||||
<h2>Einstellungen</h2>
|
||||
|
||||
<>
|
||||
<h3>Name ändern</h3>
|
||||
<form id="rename-form" onSubmit={rename.onSubmit}>
|
||||
<input name="user" type="text" placeholder="Neuer Nutzername" autoComplete="username" />{" "}
|
||||
@@ -72,6 +106,6 @@ function Settings() {
|
||||
<button type="submit" disabled={del.busy}>Konto endgültig löschen</button>
|
||||
</form>
|
||||
<p className="msg" id="delete-msg">{del.msg}</p>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user