2026-08-17 14:01:53 +02:00
|
|
|
"use client";
|
|
|
|
|
|
2026-08-17 17:21:18 +02:00
|
|
|
import { Broadcast } from "@phosphor-icons/react/ssr";
|
2026-08-17 13:49:55 +02:00
|
|
|
import type { Config } from "@/lib/config/schema";
|
2026-08-17 17:21:18 +02:00
|
|
|
import { useConfigSubscription, useConnectionStatus } from "@/lib/ws/client";
|
2026-08-17 13:49:55 +02:00
|
|
|
import { GroupSection } from "./GroupSection";
|
2026-08-17 14:27:07 +02:00
|
|
|
import { ThemeToggle } from "./ThemeToggle";
|
|
|
|
|
import { PulseMark } from "./PulseMark";
|
2026-08-17 17:21:18 +02:00
|
|
|
import { ToastStack } from "./Toast";
|
|
|
|
|
|
|
|
|
|
function LiveIndicator() {
|
|
|
|
|
const status = useConnectionStatus();
|
|
|
|
|
const label = status === "connected" ? "live" : status === "reconnecting" ? "reconnecting…" : "connecting…";
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="pn-live-label flex items-center gap-1.5 text-xs text-fg-muted">
|
|
|
|
|
<Broadcast size={15} className={status === "connected" ? "text-accent" : "text-status-degraded"} aria-hidden />
|
|
|
|
|
<span>{label}</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-08-17 13:49:55 +02:00
|
|
|
|
2026-08-17 14:01:53 +02:00
|
|
|
export function Dashboard({ config: initialConfig }: { config: Config }) {
|
|
|
|
|
const config = useConfigSubscription(initialConfig);
|
|
|
|
|
|
2026-08-17 13:49:55 +02:00
|
|
|
return (
|
2026-08-17 17:21:18 +02:00
|
|
|
<div className="relative min-h-screen">
|
|
|
|
|
<div className="sticky top-0 z-20 border-b border-border bg-bg/70 backdrop-blur-lg">
|
|
|
|
|
<div className="mx-auto flex max-w-6xl items-center gap-4 px-6 py-3">
|
|
|
|
|
<div className="mr-auto flex items-center gap-2.5">
|
|
|
|
|
<PulseMark size={30} />
|
|
|
|
|
<span className="font-display text-lg font-semibold tracking-tight text-fg">
|
|
|
|
|
{config.settings.title}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<LiveIndicator />
|
|
|
|
|
<ThemeToggle />
|
2026-08-17 14:27:07 +02:00
|
|
|
</div>
|
2026-08-17 17:21:18 +02:00
|
|
|
</div>
|
|
|
|
|
<main className="mx-auto max-w-6xl px-6 pt-2 pb-20">
|
|
|
|
|
{config.groups.map((group, groupIndex) => (
|
|
|
|
|
<GroupSection key={group.name} group={group} groupIndex={groupIndex} />
|
|
|
|
|
))}
|
|
|
|
|
</main>
|
|
|
|
|
<ToastStack />
|
|
|
|
|
</div>
|
2026-08-17 13:49:55 +02:00
|
|
|
);
|
|
|
|
|
}
|