Navigation: unfertige Bereiche ausblenden
Suche, Benachrichtigungen, Chats und Einstellungen sind noch Platzhalter und erscheinen vorerst nicht in Seitenleiste, TabBar und Kopfleiste. Die Routen bleiben bestehen; freigeschaltet wird über unfinished in Nav.tsx. 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
66ae3ab975
commit
0cddf2b00f
@@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Link, Outlet, useLocation } from "react-router";
|
import { Link, Outlet, useLocation } from "react-router";
|
||||||
import { Menu, Settings } from "lucide-react";
|
import { Menu, Settings } from "lucide-react";
|
||||||
import { Sidebar, TabBar } from "./Nav";
|
import { Sidebar, TabBar, isReady } from "./Nav";
|
||||||
|
|
||||||
// Tage ohne Datenverlust (fester Startpunkt, Kontinuität seit der alten
|
// Tage ohne Datenverlust (fester Startpunkt, Kontinuität seit der alten
|
||||||
// Version).
|
// Version).
|
||||||
@@ -46,9 +46,14 @@ export function Layout() {
|
|||||||
<Menu className="icon" />
|
<Menu className="icon" />
|
||||||
</button>
|
</button>
|
||||||
<Link to="/"><h1>Kontrollverlust</h1></Link>
|
<Link to="/"><h1>Kontrollverlust</h1></Link>
|
||||||
<Link className="icon-btn mobile-only" to="/settings" aria-label="Einstellungen">
|
{/* Ohne Einstellungsrad hält ein leerer Platzhalter den Titel mittig. */}
|
||||||
<Settings className="icon" />
|
{isReady("/settings") ? (
|
||||||
</Link>
|
<Link className="icon-btn mobile-only" to="/settings" aria-label="Einstellungen">
|
||||||
|
<Settings className="icon" />
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<span className="icon-btn mobile-only" aria-hidden="true"><span className="icon" /></span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{path === "/" && (
|
{path === "/" && (
|
||||||
<p id="stats" className="tagline">
|
<p id="stats" className="tagline">
|
||||||
|
|||||||
+10
-3
@@ -6,19 +6,26 @@ import { useAuthChanged, useMe } from "./auth";
|
|||||||
|
|
||||||
type Target = { title: string; icon?: ReactNode; to: string; end?: boolean };
|
type Target = { title: string; icon?: ReactNode; to: string; end?: boolean };
|
||||||
|
|
||||||
|
// Bereiche, die es noch nicht gibt: Route und Platzhalter-Seite bestehen,
|
||||||
|
// in der Navigation sind sie bis dahin ausgeblendet.
|
||||||
|
const unfinished = new Set(["/search", "/notifications", "/chats", "/settings"]);
|
||||||
|
|
||||||
|
export const isReady = (to: string) => !unfinished.has(to);
|
||||||
|
|
||||||
// useMainTargets liefert die fünf wichtigsten Ziele (TabBar, Kopf der
|
// useMainTargets liefert die fünf wichtigsten Ziele (TabBar, Kopf der
|
||||||
// Seitenleiste). Das Profil zeigt angemeldet aufs eigene Profil, sonst auf
|
// Seitenleiste). Das Profil zeigt angemeldet aufs eigene Profil, sonst auf
|
||||||
// /me mit dem Login.
|
// /me mit dem Login.
|
||||||
function useMainTargets(): Target[] {
|
function useMainTargets(): Target[] {
|
||||||
const me = useMe().data;
|
const me = useMe().data;
|
||||||
const profile = me ? `/u/${encodeURIComponent(me.username)}` : "/me";
|
const profile = me ? `/u/${encodeURIComponent(me.username)}` : "/me";
|
||||||
return [
|
const targets: Target[] = [
|
||||||
{ title: "Feed", icon: <House className="icon" />, to: "/", end: true },
|
{ title: "Feed", icon: <House className="icon" />, to: "/", end: true },
|
||||||
{ title: "Suche", icon: <Search className="icon" />, to: "/search" },
|
{ title: "Suche", icon: <Search className="icon" />, to: "/search" },
|
||||||
{ title: "Benachrichtigungen", icon: <Bell className="icon" />, to: "/notifications" },
|
{ title: "Benachrichtigungen", icon: <Bell className="icon" />, to: "/notifications" },
|
||||||
{ title: "Chats", icon: <MessageSquare className="icon" />, to: "/chats" },
|
{ title: "Chats", icon: <MessageSquare className="icon" />, to: "/chats" },
|
||||||
{ title: "Profil", icon: <User className="icon" />, to: profile },
|
{ title: "Profil", icon: <User className="icon" />, to: profile },
|
||||||
];
|
];
|
||||||
|
return targets.filter((t) => isReady(t.to));
|
||||||
}
|
}
|
||||||
|
|
||||||
const moreTargets: Target[] = [
|
const moreTargets: Target[] = [
|
||||||
@@ -39,7 +46,7 @@ export function Sidebar({ open, onNavigate }: { open: boolean; onNavigate: () =>
|
|||||||
const main = useMainTargets();
|
const main = useMainTargets();
|
||||||
return (
|
return (
|
||||||
<nav id="sidebar" className={open ? "open" : undefined} aria-label="Navigation">
|
<nav id="sidebar" className={open ? "open" : undefined} aria-label="Navigation">
|
||||||
<TargetList targets={[...main, ...moreTargets]} onNavigate={onNavigate} />
|
<TargetList targets={[...main, ...moreTargets.filter((t) => isReady(t.to))]} onNavigate={onNavigate} />
|
||||||
<TargetList targets={docs} onNavigate={onNavigate} />
|
<TargetList targets={docs} onNavigate={onNavigate} />
|
||||||
<Logout onDone={onNavigate} />
|
<Logout onDone={onNavigate} />
|
||||||
</nav>
|
</nav>
|
||||||
@@ -80,7 +87,7 @@ function Logout({ onDone }: { onDone: () => void }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TabBar: mobil unten die fünf wichtigsten Ziele, nur Icons.
|
// TabBar: mobil unten die (bis zu) fünf wichtigsten Ziele, nur Icons.
|
||||||
export function TabBar() {
|
export function TabBar() {
|
||||||
return (
|
return (
|
||||||
<nav id="tabbar" aria-label="Hauptnavigation">
|
<nav id="tabbar" aria-label="Hauptnavigation">
|
||||||
|
|||||||
+3
-1
@@ -61,7 +61,9 @@ auch in `pageRoutes()` (`internal/httpapi/server.go`) stehen, sonst liefert ein
|
|||||||
Ab 900 px Fensterbreite steht links die Seitenleiste mit allen Zielen (Icon +
|
Ab 900 px Fensterbreite steht links die Seitenleiste mit allen Zielen (Icon +
|
||||||
Titel). Darunter: Kopfleiste mit Menü, Titel und Einstellungsrad, unten die
|
Titel). Darunter: Kopfleiste mit Menü, Titel und Einstellungsrad, unten die
|
||||||
TabBar mit Feed, Suche, Benachrichtigungen, Chats und Profil; das Menü blendet
|
TabBar mit Feed, Suche, Benachrichtigungen, Chats und Profil; das Menü blendet
|
||||||
die Seitenleiste als Schublade ein. Umgeschaltet wird nur per CSS
|
die Seitenleiste als Schublade ein. Suche, Benachrichtigungen, Chats und
|
||||||
|
Einstellungen sind noch Platzhalter und deshalb ausgeblendet (`unfinished` in
|
||||||
|
`src/Nav.tsx`); ihre Routen bestehen weiter. Umgeschaltet wird nur per CSS
|
||||||
(`app.css`, Abschnitt Navigation).
|
(`app.css`, Abschnitt Navigation).
|
||||||
|
|
||||||
## Impressions
|
## Impressions
|
||||||
|
|||||||
Reference in New Issue
Block a user