Navigation: Seitenleiste auf dem Desktop, Kopf- und TabBar mobil
Desktop: feste Seitenleiste mit allen Zielen (Icon + Titel). Mobil: Kopfleiste mit Menü, Titel und Einstellungen, unten die TabBar mit Feed, Suche, Benachrichtigungen, Chats und Profil; das Menü blendet die Seitenleiste als Schublade ein. Suche, Benachrichtigungen, Chats und Einstellungen sind Platzhalter, /me leitet aufs eigene Profil bzw. zum Login. 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
f84ba061a8
commit
15b0bfc69c
+38
-36
@@ -1,6 +1,7 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
import { Link, Outlet, useLocation } from "react-router";
|
import { Link, Outlet, useLocation } from "react-router";
|
||||||
import { api } from "./api";
|
import { MenuIcon, SettingsIcon } from "./icons";
|
||||||
import { useAuthChanged, useMe } from "./auth";
|
import { Sidebar, TabBar } from "./Nav";
|
||||||
|
|
||||||
// Tage ohne Datenverlust (fester Startpunkt, Kontinuität seit der alten
|
// Tage ohne Datenverlust (fester Startpunkt, Kontinuität seit der alten
|
||||||
// Version).
|
// Version).
|
||||||
@@ -10,32 +11,49 @@ function plural(n: number, one: string, many: string) {
|
|||||||
return `${n} ${n === 1 ? one : many}`;
|
return `${n} ${n === 1 ? one : many}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layout ist der gemeinsame Seitenrahmen: die Startseite hat Tagline und
|
// Layout ist der gemeinsame Seitenrahmen. Desktop: Seitenleiste links mit
|
||||||
// Headerbar, alle anderen Seiten den "zurück zum Feed"-Knopf.
|
// allen Zielen. Mobil: Kopfleiste (Menü, Titel, Einstellungen), unten die
|
||||||
|
// TabBar mit den fünf wichtigsten Zielen; das Menü blendet dieselbe
|
||||||
|
// Seitenleiste als Schublade ein. Umgeschaltet wird nur per CSS (app.css).
|
||||||
export function Layout() {
|
export function Layout() {
|
||||||
const path = useLocation().pathname;
|
const path = useLocation().pathname;
|
||||||
const isHome = path === "/";
|
const [menuOpen, setMenuOpen] = useState(false);
|
||||||
const days = Math.floor((Date.now() - dataLossStart) / 86400000);
|
const days = Math.floor((Date.now() - dataLossStart) / 86400000);
|
||||||
|
const close = () => setMenuOpen(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!menuOpen) return;
|
||||||
|
const onKey = (e: KeyboardEvent) => e.key === "Escape" && setMenuOpen(false);
|
||||||
|
window.addEventListener("keydown", onKey);
|
||||||
|
return () => window.removeEventListener("keydown", onKey);
|
||||||
|
}, [menuOpen]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="shell">
|
||||||
|
<Sidebar open={menuOpen} onNavigate={close} />
|
||||||
|
{menuOpen && <div className="backdrop" onClick={close} />}
|
||||||
|
|
||||||
|
<div className="page">
|
||||||
<header>
|
<header>
|
||||||
<nav id="legal">
|
<div id="topbar">
|
||||||
<a href="/static/docs/impressum.html">Impressum</a> -{" "}
|
<button
|
||||||
<a href="/static/docs/datenschutz.html">Datenschutz</a> -{" "}
|
className="icon-btn mobile-only"
|
||||||
<a href="/static/docs/beitragsordnung.html">Beitragsordnung</a> -{" "}
|
aria-label="Menü"
|
||||||
<Link to="/stats">Statistik</Link>
|
aria-expanded={menuOpen}
|
||||||
</nav>
|
aria-controls="sidebar"
|
||||||
|
onClick={() => setMenuOpen(!menuOpen)}
|
||||||
|
>
|
||||||
|
<MenuIcon />
|
||||||
|
</button>
|
||||||
<Link to="/"><h1>Kontrollverlust</h1></Link>
|
<Link to="/"><h1>Kontrollverlust</h1></Link>
|
||||||
{isHome ? (
|
<Link className="icon-btn mobile-only" to="/settings" aria-label="Einstellungen">
|
||||||
<>
|
<SettingsIcon />
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
{path === "/" && (
|
||||||
<p id="stats" className="tagline">
|
<p id="stats" className="tagline">
|
||||||
Ohne Datenverlust seit {plural(days, "Tag", "Tagen")}
|
Ohne Datenverlust seit {plural(days, "Tag", "Tagen")}
|
||||||
</p>
|
</p>
|
||||||
<Headerbar />
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<div id="headerbar"><Link className="button" to="/">zurück zum Feed</Link></div>
|
|
||||||
)}
|
)}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@@ -43,25 +61,9 @@ export function Layout() {
|
|||||||
<main className={path === "/stats" ? "wide" : undefined}>
|
<main className={path === "/stats" ? "wide" : undefined}>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</main>
|
</main>
|
||||||
</>
|
</div>
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Headerbar der Startseite: angemeldet Profil-Link und Logout, sonst leer.
|
<TabBar />
|
||||||
function Headerbar() {
|
|
||||||
const me = useMe().data;
|
|
||||||
const authChanged = useAuthChanged();
|
|
||||||
if (!me) return <div id="headerbar"></div>;
|
|
||||||
|
|
||||||
// POST statt GET: als GET wäre Logout per fremdem Link auslösbar (CSRF).
|
|
||||||
const logout = async () => {
|
|
||||||
await api.post("/auth/logout").catch(() => undefined);
|
|
||||||
await authChanged();
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div id="headerbar">
|
|
||||||
<Link className="button" to={`/u/${encodeURIComponent(me.username)}`}>mein Profil</Link>{" "}
|
|
||||||
<button id="logout-btn" onClick={logout}>Logout</button>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
import type { ReactNode } from "react";
|
||||||
|
import { NavLink } from "react-router";
|
||||||
|
import { api } from "./api";
|
||||||
|
import { useAuthChanged, useMe } from "./auth";
|
||||||
|
import {
|
||||||
|
BellIcon, ChatIcon, FeedIcon, ImprintIcon, LogoutIcon, PrivacyIcon,
|
||||||
|
ProfileIcon, RulesIcon, SearchIcon, SettingsIcon, StatsIcon,
|
||||||
|
} from "./icons";
|
||||||
|
|
||||||
|
type Target = { title: string; icon: ReactNode; to: string; end?: boolean };
|
||||||
|
|
||||||
|
// useMainTargets liefert die fünf wichtigsten Ziele (TabBar, Kopf der
|
||||||
|
// Seitenleiste). Das Profil zeigt angemeldet aufs eigene Profil, sonst auf
|
||||||
|
// /me mit dem Login.
|
||||||
|
function useMainTargets(): Target[] {
|
||||||
|
const me = useMe().data;
|
||||||
|
const profile = me ? `/u/${encodeURIComponent(me.username)}` : "/me";
|
||||||
|
return [
|
||||||
|
{ title: "Feed", icon: <FeedIcon />, to: "/", end: true },
|
||||||
|
{ title: "Suche", icon: <SearchIcon />, to: "/search" },
|
||||||
|
{ title: "Benachrichtigungen", icon: <BellIcon />, to: "/notifications" },
|
||||||
|
{ title: "Chats", icon: <ChatIcon />, to: "/chats" },
|
||||||
|
{ title: "Profil", icon: <ProfileIcon />, to: profile },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
const moreTargets: Target[] = [
|
||||||
|
{ title: "Einstellungen", icon: <SettingsIcon />, to: "/settings" },
|
||||||
|
{ title: "Statistik", icon: <StatsIcon />, to: "/stats" },
|
||||||
|
];
|
||||||
|
|
||||||
|
// Die Rechtstexte sind statische Seiten außerhalb der App (kein Client-Routing).
|
||||||
|
const docs: Target[] = [
|
||||||
|
{ title: "Datenschutz", icon: <PrivacyIcon />, to: "/static/docs/datenschutz.html" },
|
||||||
|
{ title: "Beitragsordnung", icon: <RulesIcon />, to: "/static/docs/beitragsordnung.html" },
|
||||||
|
{ title: "Impressum", icon: <ImprintIcon />, to: "/static/docs/impressum.html" },
|
||||||
|
];
|
||||||
|
|
||||||
|
// Sidebar: alle Ziele mit Icon und Titel. Auf dem Desktop immer sichtbar,
|
||||||
|
// mobil die Schublade hinter dem Menü (open).
|
||||||
|
export function Sidebar({ open, onNavigate }: { open: boolean; onNavigate: () => void }) {
|
||||||
|
const main = useMainTargets();
|
||||||
|
return (
|
||||||
|
<nav id="sidebar" className={open ? "open" : undefined} aria-label="Navigation">
|
||||||
|
<ul>
|
||||||
|
{[...main, ...moreTargets].map((t) => (
|
||||||
|
<li key={t.title}>
|
||||||
|
<NavLink to={t.to} end={t.end} onClick={onNavigate}>
|
||||||
|
{t.icon}<span>{t.title}</span>
|
||||||
|
</NavLink>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
{docs.map((t) => (
|
||||||
|
<li key={t.title}>
|
||||||
|
<a href={t.to}>{t.icon}<span>{t.title}</span></a>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
<Logout onDone={onNavigate} />
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logout steht nur angemeldet unten in der Seitenleiste. POST statt GET: als
|
||||||
|
// GET wäre Logout per fremdem Link auslösbar (CSRF).
|
||||||
|
function Logout({ onDone }: { onDone: () => void }) {
|
||||||
|
const me = useMe().data;
|
||||||
|
const authChanged = useAuthChanged();
|
||||||
|
if (!me) return null;
|
||||||
|
const logout = async () => {
|
||||||
|
await api.post("/auth/logout").catch(() => undefined);
|
||||||
|
await authChanged();
|
||||||
|
onDone();
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<button id="logout-btn" onClick={logout}><LogoutIcon /><span>Logout</span></button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TabBar: mobil unten die fünf wichtigsten Ziele, nur Icons.
|
||||||
|
export function TabBar() {
|
||||||
|
return (
|
||||||
|
<nav id="tabbar" aria-label="Hauptnavigation">
|
||||||
|
{useMainTargets().map((t) => (
|
||||||
|
<NavLink key={t.title} to={t.to} end={t.end} aria-label={t.title} title={t.title}>
|
||||||
|
{t.icon}
|
||||||
|
</NavLink>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
+148
-6
@@ -52,7 +52,8 @@ header {
|
|||||||
padding: 0.5rem 0;
|
padding: 0.5rem 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Rechtliche Links über der Überschrift. */
|
/* Rechtliche Links über der Überschrift (nur noch die statischen Rechtstexte,
|
||||||
|
die App hat die Seitenleiste). */
|
||||||
#legal {
|
#legal {
|
||||||
margin-bottom: 0.3rem;
|
margin-bottom: 0.3rem;
|
||||||
}
|
}
|
||||||
@@ -62,7 +63,8 @@ header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Klick auf die Überschrift führt zurück zum Feed. */
|
/* Klick auf die Überschrift führt zurück zum Feed. */
|
||||||
header > a {
|
header > a,
|
||||||
|
#topbar > a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,13 +104,153 @@ h2 {
|
|||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#headerbar {
|
/* --- Navigation ---
|
||||||
background-color: white;
|
Desktop (ab 900 px): Seitenleiste fest links, Inhalt rechts daneben.
|
||||||
text-align: center;
|
Mobil: Kopfleiste oben (Menü, Titel, Einstellungen), TabBar unten, die
|
||||||
|
Seitenleiste ist eine Schublade hinter dem Menü. */
|
||||||
|
.icon {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
#headerbar a {
|
#topbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
padding: 0.4rem;
|
||||||
|
margin: 0;
|
||||||
|
border: none;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 30;
|
||||||
|
width: 15rem;
|
||||||
|
overflow-y: auto;
|
||||||
|
background-color: white;
|
||||||
|
border-right: 1px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar ul {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0.5rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar ul + ul {
|
||||||
|
border-top: 1px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar a,
|
||||||
|
#sidebar button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.6rem;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0.4rem 1rem;
|
||||||
|
border: none;
|
||||||
|
text-align: left;
|
||||||
|
text-decoration: none;
|
||||||
|
color: black;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar button span {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar a:hover,
|
||||||
|
#sidebar button:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Aktuelles Ziel invertiert (NavLink setzt .active). */
|
||||||
|
#sidebar a.active,
|
||||||
|
#tabbar a.active {
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tabbar {
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 20;
|
||||||
|
display: flex;
|
||||||
|
background-color: white;
|
||||||
|
border-top: 1px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tabbar a {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 0.6rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.backdrop {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 25;
|
||||||
|
background-color: rgba(0, 0, 0, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 899px) {
|
||||||
|
header {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 10;
|
||||||
|
padding: 0;
|
||||||
|
border-bottom: 1px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
#topbar {
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
#topbar h1 {
|
||||||
|
font-size: 1.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Geschlossen: aus dem Bild und aus der Tab-Reihenfolge. */
|
||||||
|
#sidebar {
|
||||||
|
visibility: hidden;
|
||||||
|
transform: translateX(-100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar.open {
|
||||||
|
visibility: visible;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Platz für die TabBar, damit das Seitenende nicht darunter liegt. */
|
||||||
|
.page {
|
||||||
|
padding-bottom: 3.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 900px) {
|
||||||
|
.page {
|
||||||
|
margin-left: 15rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-only,
|
||||||
|
#tabbar,
|
||||||
|
.backdrop {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --- Inhaltsspalte --- */
|
/* --- Inhaltsspalte --- */
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
// Strichicons als Inline-SVG (keine Icon-Bibliothek): 24er Raster, schwarze
|
||||||
|
// Linie, eckige Enden -- passend zur rohen Optik.
|
||||||
|
function Svg({ children }: { children: ReactNode }) {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
className="icon"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="square"
|
||||||
|
strokeLinejoin="miter"
|
||||||
|
aria-hidden="true"
|
||||||
|
focusable="false"
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const FeedIcon = () => (
|
||||||
|
<Svg>
|
||||||
|
<path d="M3 11l9-8 9 8M5 9v12h14V9M10 21v-6h4v6" />
|
||||||
|
</Svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const SearchIcon = () => (
|
||||||
|
<Svg>
|
||||||
|
<circle cx="10" cy="10" r="6" />
|
||||||
|
<path d="M15 15l5 5" />
|
||||||
|
</Svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const BellIcon = () => (
|
||||||
|
<Svg>
|
||||||
|
<path d="M6 17V10a6 6 0 0 1 12 0v7M4 17h16M10 21h4" />
|
||||||
|
</Svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const ChatIcon = () => (
|
||||||
|
<Svg>
|
||||||
|
<path d="M4 4h16v12H10l-4 4v-4H4z" />
|
||||||
|
</Svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const ProfileIcon = () => (
|
||||||
|
<Svg>
|
||||||
|
<circle cx="12" cy="8" r="4" />
|
||||||
|
<path d="M4 21c0-4 4-6 8-6s8 2 8 6" />
|
||||||
|
</Svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const StatsIcon = () => (
|
||||||
|
<Svg>
|
||||||
|
<path d="M4 20h16M7 20v-6M12 20V6M17 20v-10" />
|
||||||
|
</Svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const PrivacyIcon = () => (
|
||||||
|
<Svg>
|
||||||
|
<rect x="5" y="11" width="14" height="10" />
|
||||||
|
<path d="M8 11V7a4 4 0 0 1 8 0v4" />
|
||||||
|
</Svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const RulesIcon = () => (
|
||||||
|
<Svg>
|
||||||
|
<path d="M6 3h12v18H6zM9 8h6M9 12h6M9 16h4" />
|
||||||
|
</Svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const ImprintIcon = () => (
|
||||||
|
<Svg>
|
||||||
|
<circle cx="12" cy="12" r="9" />
|
||||||
|
<path d="M12 11v6M12 7v1" />
|
||||||
|
</Svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const SettingsIcon = () => (
|
||||||
|
<Svg>
|
||||||
|
<circle cx="12" cy="12" r="6" />
|
||||||
|
<circle cx="12" cy="12" r="2" />
|
||||||
|
{/* Zähne: kurze, dicke Striche direkt am Ring (sonst sieht es nach Sonne aus). */}
|
||||||
|
<path
|
||||||
|
d="M12 2.5v4M12 17.5v4M2.5 12h4M17.5 12h4M5.3 5.3l2.8 2.8M15.9 15.9l2.8 2.8M5.3 18.7l2.8-2.8M15.9 8.1l2.8-2.8"
|
||||||
|
strokeWidth="3.5"
|
||||||
|
strokeLinecap="butt"
|
||||||
|
/>
|
||||||
|
</Svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const LogoutIcon = () => (
|
||||||
|
<Svg>
|
||||||
|
<path d="M10 4H4v16h6M14 8l4 4-4 4M18 12H9" />
|
||||||
|
</Svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const MenuIcon = () => (
|
||||||
|
<Svg>
|
||||||
|
<path d="M3 6h18M3 12h18M3 18h18" />
|
||||||
|
</Svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const CloseIcon = () => (
|
||||||
|
<Svg>
|
||||||
|
<path d="M5 5l14 14M19 5L5 19" />
|
||||||
|
</Svg>
|
||||||
|
);
|
||||||
@@ -9,6 +9,7 @@ import { EntryPage } from "./pages/EntryPage";
|
|||||||
import { UserPage } from "./pages/UserPage";
|
import { UserPage } from "./pages/UserPage";
|
||||||
import { StatsPage } from "./pages/StatsPage";
|
import { StatsPage } from "./pages/StatsPage";
|
||||||
import { ResetPage } from "./pages/ResetPage";
|
import { ResetPage } from "./pages/ResetPage";
|
||||||
|
import { MePage, Placeholder } from "./pages/Placeholder";
|
||||||
import "./app.css";
|
import "./app.css";
|
||||||
|
|
||||||
const queryClient = new QueryClient({
|
const queryClient = new QueryClient({
|
||||||
@@ -33,6 +34,11 @@ const router = createBrowserRouter([
|
|||||||
{ path: "/u/:username", element: <UserPage /> },
|
{ path: "/u/:username", element: <UserPage /> },
|
||||||
{ path: "/stats", element: <StatsPage /> },
|
{ path: "/stats", element: <StatsPage /> },
|
||||||
{ path: "/reset", element: <ResetPage /> },
|
{ path: "/reset", element: <ResetPage /> },
|
||||||
|
{ path: "/me", element: <MePage /> },
|
||||||
|
{ path: "/search", element: <Placeholder title="Suche" /> },
|
||||||
|
{ path: "/notifications", element: <Placeholder title="Benachrichtigungen" /> },
|
||||||
|
{ path: "/chats", element: <Placeholder title="Chats" /> },
|
||||||
|
{ path: "/settings", element: <Placeholder title="Einstellungen" /> },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { Navigate } from "react-router";
|
||||||
|
import { useMe } from "../auth";
|
||||||
|
import { AuthBox } from "../components/AuthBox";
|
||||||
|
|
||||||
|
// Placeholder steht für Bereiche, die noch eigene Projekte sind (Suche,
|
||||||
|
// Benachrichtigungen, Chats, Einstellungen).
|
||||||
|
export function Placeholder({ title }: { title: string }) {
|
||||||
|
return (
|
||||||
|
<section>
|
||||||
|
<h2>{title}</h2>
|
||||||
|
<p className="muted">Kommt noch.</p>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// MePage ist das Profil-Ziel der Navigation: angemeldet weiter zum eigenen
|
||||||
|
// Profil, sonst der Login.
|
||||||
|
export function MePage() {
|
||||||
|
const me = useMe();
|
||||||
|
if (!me.isSuccess) return null;
|
||||||
|
if (me.data) return <Navigate to={`/u/${encodeURIComponent(me.data.username)}`} replace />;
|
||||||
|
return <AuthBox />;
|
||||||
|
}
|
||||||
@@ -129,6 +129,10 @@ func (s *Server) pageRoutes(r chi.Router) {
|
|||||||
// Das Reset-Token steht im Fragment (#...) und erreicht den Server über
|
// Das Reset-Token steht im Fragment (#...) und erreicht den Server über
|
||||||
// diese Route nie, siehe account/reset.go.
|
// diese Route nie, siehe account/reset.go.
|
||||||
r.Get("/reset", serveApp)
|
r.Get("/reset", serveApp)
|
||||||
|
// Navigationsziele: Profil-Weiche und Platzhalter für kommende Bereiche.
|
||||||
|
for _, p := range []string{"/me", "/search", "/notifications", "/chats", "/settings"} {
|
||||||
|
r.Get(p, serveApp)
|
||||||
|
}
|
||||||
// Alte Adresse der Statistik-Seite (Lesezeichen, Links von außen).
|
// Alte Adresse der Statistik-Seite (Lesezeichen, Links von außen).
|
||||||
r.Get("/stats.html", func(w http.ResponseWriter, r *http.Request) {
|
r.Get("/stats.html", func(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Redirect(w, r, "/stats", http.StatusMovedPermanently)
|
http.Redirect(w, r, "/stats", http.StatusMovedPermanently)
|
||||||
|
|||||||
+15
-3
@@ -44,13 +44,25 @@ githooks` läuft das nach jedem Commit automatisch im Hintergrund (Log:
|
|||||||
| `src/types.ts` | Typen der API-Antworten (Referenz: `notes/api.md`) |
|
| `src/types.ts` | Typen der API-Antworten (Referenz: `notes/api.md`) |
|
||||||
| `src/auth.ts` | `useMe()` (eigenes Konto oder `null`), `useAuthChanged()` |
|
| `src/auth.ts` | `useMe()` (eigenes Konto oder `null`), `useAuthChanged()` |
|
||||||
| `src/main.tsx` | Router, QueryClient |
|
| `src/main.tsx` | Router, QueryClient |
|
||||||
| `src/Layout.tsx` | Header, Headerbar |
|
| `src/Layout.tsx` | Seitenrahmen: Kopf (mobil mit Menü und Einstellungen), Schublade |
|
||||||
| `src/pages/*` | Startseite, Thread, Profil, Statistik |
|
| `src/Nav.tsx` | Seitenleiste (alle Ziele) und mobile TabBar (fünf wichtigste) |
|
||||||
|
| `src/icons.tsx` | Strichicons als Inline-SVG (keine Icon-Bibliothek) |
|
||||||
|
| `src/pages/*` | Startseite, Thread, Profil, Statistik; `Placeholder.tsx` für Suche, Benachrichtigungen, Chats, Einstellungen und die Profil-Weiche `/me` |
|
||||||
| `src/components/*` | Feed, Beitragskarte, Votes, Repost, Login, Beitrag verfassen |
|
| `src/components/*` | Feed, Beitragskarte, Votes, Repost, Login, Beitrag verfassen |
|
||||||
|
|
||||||
Seitenrouten des Clients (`/`, `/e/:pid`, `/u/:username`, `/stats`) müssen
|
Seitenrouten des Clients (`/`, `/e/:pid`, `/u/:username`, `/stats`, `/reset`,
|
||||||
|
`/me`, `/search`, `/notifications`, `/chats`, `/settings`) müssen
|
||||||
auch in `pageRoutes()` (`internal/httpapi/server.go`) stehen, sonst liefert ein direkter Aufruf 404.
|
auch in `pageRoutes()` (`internal/httpapi/server.go`) stehen, sonst liefert ein direkter Aufruf 404.
|
||||||
|
|
||||||
|
## Navigation
|
||||||
|
|
||||||
|
Ab 900 px Fensterbreite steht links die Seitenleiste mit allen Zielen (Icon +
|
||||||
|
Titel). Darunter: Kopfleiste mit Menü, Titel und Einstellungsrad, unten die
|
||||||
|
TabBar mit Feed, Suche, Benachrichtigungen, Chats und Profil; das Menü blendet
|
||||||
|
die Seitenleiste als Schublade ein. Umgeschaltet wird nur per CSS
|
||||||
|
(`app.css`, Abschnitt Navigation). Die Rechtstexte sind statische Seiten
|
||||||
|
ohne JS und behalten ihre Linkzeile (`#legal`).
|
||||||
|
|
||||||
## Impressions
|
## Impressions
|
||||||
|
|
||||||
Das Backend zählt Seitenaufrufe beim Ausliefern der `index.html`. Navigation
|
Das Backend zählt Seitenaufrufe beim Ausliefern der `index.html`. Navigation
|
||||||
|
|||||||
Reference in New Issue
Block a user