mirror of
https://github.com/traberph/short.git
synced 2026-11-22 22:55:12 +00:00
Redesign the admin UI
Replaces the single-page dashboard with a structured app shell: sidebar on desktop, bottom tab bar on mobile (PWA), and separate screens for overview, short links, link pages, API tokens and administration. - detail view with tabs: content, appearance, analytics, QR code, settings - small component kit (buttons, form controls, cards, dialogs, toasts, tabs) built on semantic color tokens with light and dark mode following the system - native <dialog> modals for creating pages, editing blocks and confirmations instead of window.confirm - theme presets and a live preview of unsaved appearance changes - removed the v1 screenshots for now Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import { useSyncExternalStore, type MouseEvent } from "react";
|
||||
import type { PageKind } from "../shared/api-types.js";
|
||||
|
||||
// A tiny history-based router; the app only has a handful of screens under /~/.
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
export function navigate(to: string) {
|
||||
history.pushState(null, "", to);
|
||||
window.scrollTo({ top: 0 });
|
||||
listeners.forEach((l) => l());
|
||||
}
|
||||
|
||||
@@ -27,3 +29,35 @@ export function linkHandler(to: string) {
|
||||
navigate(to);
|
||||
};
|
||||
}
|
||||
|
||||
export type Route =
|
||||
| { name: "overview" }
|
||||
| { name: "list"; kind: PageKind }
|
||||
| { name: "detail"; kind: PageKind; id: number; tab: string | undefined }
|
||||
| { name: "tokens" }
|
||||
| { name: "admin" }
|
||||
| { name: "notFound" };
|
||||
|
||||
const KIND_SEGMENT: Record<string, PageKind> = { links: "redirect", pages: "linkpage" };
|
||||
|
||||
export function listPath(kind: PageKind): string {
|
||||
return kind === "redirect" ? "/~/links" : "/~/pages";
|
||||
}
|
||||
|
||||
export function detailPath(page: { id: number; kind: PageKind }, tab?: string): string {
|
||||
return `${listPath(page.kind)}/${page.id}${tab ? `/${tab}` : ""}`;
|
||||
}
|
||||
|
||||
export function parseRoute(path: string): Route {
|
||||
const p = path.replace(/\/+$/, "") || "/~";
|
||||
if (p === "/~") return { name: "overview" };
|
||||
if (p === "/~/tokens") return { name: "tokens" };
|
||||
if (p === "/~/admin") return { name: "admin" };
|
||||
const m = p.match(/^\/~\/(links|pages)(?:\/(\d+)(?:\/([a-z]+))?)?$/);
|
||||
if (m) {
|
||||
const kind = KIND_SEGMENT[m[1]!]!;
|
||||
if (!m[2]) return { name: "list", kind };
|
||||
return { name: "detail", kind, id: Number(m[2]), tab: m[3] };
|
||||
}
|
||||
return { name: "notFound" };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user