recovered snapshot from suspended aaronjaworski710 (history unavailable)
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<title>GitHub Register</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<style>
|
||||
/* Tokens mirror DESIGN.md (Resend style reference): void-black canvas,
|
||||
hairline borders for layer separation, one blue action, violet for code. */
|
||||
:root {
|
||||
--color-void-black: #000000;
|
||||
--color-graphite-hairline: #292d30;
|
||||
--color-white: #ffffff;
|
||||
--color-bone-white: #f0f0f0;
|
||||
--color-ash-gray: #a1a4a5;
|
||||
--color-smoke-gray: #abafb4;
|
||||
--color-iron: #6e727a;
|
||||
--color-charcoal: #464a4d;
|
||||
--color-iris-violet: #9281f7;
|
||||
--color-iris-violet-glow: #baa7ff;
|
||||
--color-signal-blue: #3b9eff;
|
||||
--color-sky-blue: #70b8ff;
|
||||
--color-pulse-green: #3ad389;
|
||||
--color-alarm-red: #ff9592;
|
||||
--color-crimson: #ff6465;
|
||||
--color-amber: #ffca16;
|
||||
|
||||
/* Surfaces */
|
||||
--bg-primary: var(--color-void-black);
|
||||
--bg-secondary: var(--color-void-black);
|
||||
--bg-card: var(--color-void-black);
|
||||
--bg-card-hover: #0e1013;
|
||||
--bg-input: #000000;
|
||||
--border: var(--color-graphite-hairline);
|
||||
--border-strong: var(--color-iron);
|
||||
|
||||
/* Text */
|
||||
--text-primary: var(--color-white);
|
||||
--text-secondary: var(--color-bone-white);
|
||||
--text-muted: var(--color-ash-gray);
|
||||
--text-disabled: var(--color-iron);
|
||||
|
||||
/* One blue action, violet reserved for code identifiers */
|
||||
--accent: var(--color-signal-blue);
|
||||
--accent-rgb: 59, 158, 255;
|
||||
--accent-strong: var(--color-sky-blue);
|
||||
--accent-text: var(--color-sky-blue);
|
||||
--accent-soft: rgba(59, 158, 255, 0.14);
|
||||
--code-ident: var(--color-iris-violet);
|
||||
|
||||
/* Data / status only, never UI chrome */
|
||||
--success: var(--color-pulse-green);
|
||||
--success-rgb: 58, 211, 137;
|
||||
--danger: var(--color-alarm-red);
|
||||
--danger-rgb: 255, 149, 146;
|
||||
--danger-strong: var(--color-crimson);
|
||||
--warning: var(--color-amber);
|
||||
|
||||
/* Legacy aliases still referenced by panel inline styles */
|
||||
--bg: var(--bg-primary);
|
||||
--bg-raise: var(--bg-card);
|
||||
--text: var(--text-secondary);
|
||||
--ink: var(--text-primary);
|
||||
--muted: var(--text-muted);
|
||||
--ok: var(--success);
|
||||
--ok-rgb: var(--success-rgb);
|
||||
--glass-border: var(--border);
|
||||
--glass: var(--bg-card);
|
||||
--glass-strong: var(--bg-card-hover);
|
||||
--ring: 0 0 0 3px rgba(59, 158, 255, 0.28);
|
||||
|
||||
/* Two-value radius scale: 6px controls, 16px cards, 24px panels */
|
||||
--radius-control: 6px;
|
||||
--radius-card: 16px;
|
||||
--radius-panel: 24px;
|
||||
|
||||
--font-inter: 'Inter', ui-sans-serif, system-ui, -apple-system,
|
||||
BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
--font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo,
|
||||
Monaco, Consolas, monospace;
|
||||
|
||||
--page-max-width: 1200px;
|
||||
--bottom-nav-height: 60px;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
html { -webkit-text-size-adjust: 100%; }
|
||||
|
||||
html, body, #root { height: 100%; }
|
||||
|
||||
body {
|
||||
background: var(--bg-primary);
|
||||
color: var(--text-secondary);
|
||||
font-family: var(--font-inter);
|
||||
font-size: 16px;
|
||||
line-height: 1.5;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Mobile scrolls the document; desktop scrolls inside .app-main. */
|
||||
@media (max-width: 820px) {
|
||||
body { overflow: auto; }
|
||||
html, body, #root { height: auto; min-height: 100%; }
|
||||
}
|
||||
|
||||
::selection { background: rgba(59, 158, 255, 0.30); }
|
||||
|
||||
::-webkit-scrollbar { width: 8px; height: 8px; }
|
||||
::-webkit-scrollbar-thumb { background: var(--color-graphite-hairline); border-radius: 4px; }
|
||||
::-webkit-scrollbar-thumb:hover { background: var(--color-iron); }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
|
||||
code, pre, kbd, samp { font-family: var(--font-mono); }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*, *::before, *::after {
|
||||
animation-duration: 0.01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
Generated
+1738
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "github-regkit-frontend",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"verify:ui": "node verify-ui.cjs",
|
||||
"verify:clicks": "node verify-clicks.cjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"lucide-react": "^1.33.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"playwright": "^1.63.0",
|
||||
"vite": "^5.4.11"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,481 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
Activity,
|
||||
Boxes,
|
||||
ExternalLink,
|
||||
FolderGit2,
|
||||
Heart,
|
||||
LogOut,
|
||||
Menu,
|
||||
Octagon,
|
||||
PanelLeftClose,
|
||||
PanelLeftOpen,
|
||||
Plus,
|
||||
Settings,
|
||||
ShieldCheck,
|
||||
X,
|
||||
} from "lucide-react";
|
||||
import { api, getToken, setToken } from "./api.js";
|
||||
import StatusPanel from "./components/StatusPanel.jsx";
|
||||
import ConfigPanel from "./components/ConfigPanel.jsx";
|
||||
import AccountsPanel from "./components/AccountsPanel.jsx";
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
Card,
|
||||
Dialog,
|
||||
Input,
|
||||
Spinner,
|
||||
} from "./components/ui.jsx";
|
||||
|
||||
const NAV = [
|
||||
{ id: "status", label: "Status", icon: Activity },
|
||||
{ id: "config", label: "Config", icon: Settings },
|
||||
{ id: "accounts", label: "Accounts", icon: Boxes },
|
||||
];
|
||||
|
||||
export default function App() {
|
||||
const [auth, setAuth] = useState(null);
|
||||
const [tab, setTab] = useState("status");
|
||||
const [username, setUsername] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [running, setRunning] = useState(false);
|
||||
const [sidebarOpen, setSidebarOpen] = useState(true);
|
||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||
const [group, setGroup] = useState("");
|
||||
const [groups, setGroups] = useState([]);
|
||||
const [groupCreateOpen, setGroupCreateOpen] = useState(false);
|
||||
const [newGroupName, setNewGroupName] = useState("");
|
||||
const [groupBusy, setGroupBusy] = useState(false);
|
||||
const [groupDelete, setGroupDelete] = useState(null); // group name | null
|
||||
|
||||
useEffect(() => {
|
||||
api
|
||||
.get("/api/config")
|
||||
.then((d) => setAuth({ needs: d.needs_auth }))
|
||||
.catch(() => setAuth({ needs: true }));
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if (auth?.needs && !getToken()) return undefined;
|
||||
const timer = setInterval(
|
||||
() =>
|
||||
api
|
||||
.get("/api/status")
|
||||
.then((d) => setRunning(!!d.running))
|
||||
.catch(() => {}),
|
||||
2500,
|
||||
);
|
||||
return () => clearInterval(timer);
|
||||
}, [auth]);
|
||||
|
||||
function loadGroups() {
|
||||
api
|
||||
.get("/api/groups")
|
||||
.then((d) => setGroups(d.groups || []))
|
||||
.catch(() => {});
|
||||
}
|
||||
useEffect(() => {
|
||||
if (auth === null) return undefined;
|
||||
if (auth.needs && !getToken()) return undefined;
|
||||
loadGroups();
|
||||
const t = setInterval(loadGroups, 10000);
|
||||
return () => clearInterval(t);
|
||||
}, [auth]);
|
||||
|
||||
function selectGroup(name) {
|
||||
setGroup(name);
|
||||
setTab("accounts");
|
||||
setDrawerOpen(false);
|
||||
}
|
||||
|
||||
// Drawer is a mobile-only surface: close on Escape and when returning to desktop.
|
||||
useEffect(() => {
|
||||
if (!drawerOpen) return undefined;
|
||||
const onKeyDown = (e) => e.key === "Escape" && setDrawerOpen(false);
|
||||
const onResize = () => {
|
||||
if (window.innerWidth > 820) setDrawerOpen(false);
|
||||
};
|
||||
document.addEventListener("keydown", onKeyDown);
|
||||
window.addEventListener("resize", onResize);
|
||||
return () => {
|
||||
document.removeEventListener("keydown", onKeyDown);
|
||||
window.removeEventListener("resize", onResize);
|
||||
};
|
||||
}, [drawerOpen]);
|
||||
|
||||
async function doCreateGroup() {
|
||||
const name = newGroupName.trim();
|
||||
if (!name || groupBusy) return;
|
||||
setGroupBusy(true);
|
||||
try {
|
||||
await api.post("/api/groups", { name });
|
||||
setGroupCreateOpen(false);
|
||||
setNewGroupName("");
|
||||
setGroup(name);
|
||||
setTab("accounts");
|
||||
loadGroups();
|
||||
} catch (e) {
|
||||
alert(`Failed to create group: ${e.message}`);
|
||||
} finally {
|
||||
setGroupBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function doDeleteGroup() {
|
||||
const name = groupDelete;
|
||||
if (!name || groupBusy) return;
|
||||
setGroupBusy(true);
|
||||
try {
|
||||
await api.del(`/api/groups?name=${encodeURIComponent(name)}`);
|
||||
if (group === name) setGroup("");
|
||||
loadGroups();
|
||||
} catch (e) {
|
||||
alert(`Failed to delete group: ${e.message}`);
|
||||
} finally {
|
||||
setGroupBusy(false);
|
||||
setGroupDelete(null);
|
||||
}
|
||||
}
|
||||
|
||||
async function doLogin() {
|
||||
try {
|
||||
const data = await api.post("/api/auth", { username, password });
|
||||
setToken(data.token);
|
||||
setAuth({ needs: data.needs_auth });
|
||||
setUsername("");
|
||||
setPassword("");
|
||||
} catch (error) {
|
||||
alert(`Login failed: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (auth === null)
|
||||
return (
|
||||
<main className="app-loading">
|
||||
<Spinner />
|
||||
<span>Loading application</span>
|
||||
</main>
|
||||
);
|
||||
if (auth.needs && !getToken())
|
||||
return (
|
||||
<main className="app-login">
|
||||
<Card className="app-login-card">
|
||||
<div className="app-login-mark">
|
||||
<ShieldCheck size={26} />
|
||||
</div>
|
||||
<h1>GitHub Register</h1>
|
||||
<p>Enter your username and password to open the console.</p>
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="Username"
|
||||
autoComplete="username"
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && doLogin()}
|
||||
/>
|
||||
<Input
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
autoComplete="current-password"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && doLogin()}
|
||||
/>
|
||||
<Button variant="primary" size="lg" onClick={doLogin}>
|
||||
Sign in
|
||||
</Button>
|
||||
</Card>
|
||||
</main>
|
||||
);
|
||||
|
||||
const ActivePanel = {
|
||||
status: StatusPanel,
|
||||
config: ConfigPanel,
|
||||
accounts: AccountsPanel,
|
||||
}[tab];
|
||||
return (
|
||||
<div
|
||||
className={`${sidebarOpen ? "app-shell" : "app-shell app-shell-collapsed"}${drawerOpen ? " app-drawer-open" : ""}`}
|
||||
>
|
||||
{/* Mobile top bar: brand + job status + labeled menu (not a bare hamburger). */}
|
||||
<header className="app-topbar">
|
||||
<div className="app-topbar-brand">
|
||||
<div className="app-brand-icon">
|
||||
<Octagon size={18} />
|
||||
</div>
|
||||
<strong>GitHub Register</strong>
|
||||
</div>
|
||||
<div className="app-topbar-right">
|
||||
<Badge tone={running ? "success" : "muted"}>
|
||||
{running && <span className="pulse-dot" />}
|
||||
{running ? "Running" : "Idle"}
|
||||
</Badge>
|
||||
<Button
|
||||
variant="outline"
|
||||
className="app-menu-btn"
|
||||
onClick={() => setDrawerOpen(true)}
|
||||
aria-label="Open menu"
|
||||
aria-expanded={drawerOpen}
|
||||
>
|
||||
<Menu size={17} />
|
||||
<span>Menu</span>
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
<div
|
||||
className="app-drawer-scrim"
|
||||
onClick={() => setDrawerOpen(false)}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<aside
|
||||
className={
|
||||
sidebarOpen ? "app-sidebar" : "app-sidebar app-sidebar-collapsed"
|
||||
}
|
||||
>
|
||||
<div className="app-sidebar-top">
|
||||
<div className="app-brand">
|
||||
<div className="app-brand-icon">
|
||||
<Octagon size={20} />
|
||||
</div>
|
||||
<div className="app-brand-copy">
|
||||
<strong>GitHub Register</strong>
|
||||
<a
|
||||
className="app-brand-link"
|
||||
href="https://t.me/alstack"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
@alstack
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="app-drawer-close"
|
||||
onClick={() => setDrawerOpen(false)}
|
||||
aria-label="Close menu"
|
||||
>
|
||||
<X size={18} />
|
||||
</button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="app-sidebar-toggle"
|
||||
onClick={() => setSidebarOpen((open) => !open)}
|
||||
aria-label={sidebarOpen ? "Collapse sidebar" : "Expand sidebar"}
|
||||
title={sidebarOpen ? "Collapse sidebar" : "Expand sidebar"}
|
||||
>
|
||||
{sidebarOpen ? (
|
||||
<PanelLeftClose size={17} />
|
||||
) : (
|
||||
<PanelLeftOpen size={17} />
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
<nav className="app-nav">
|
||||
{NAV.map(({ id, label, icon: Icon }) => (
|
||||
<button
|
||||
key={id}
|
||||
className={tab === id ? "app-nav-item active" : "app-nav-item"}
|
||||
onClick={() => {
|
||||
setTab(id);
|
||||
setDrawerOpen(false);
|
||||
if (id === "accounts") setGroup("");
|
||||
}}
|
||||
title={label}
|
||||
>
|
||||
<Icon size={17} />
|
||||
<span>{label}</span>
|
||||
</button>
|
||||
))}
|
||||
<div className="app-nav-groups">
|
||||
<div className="app-nav-label">
|
||||
<span>Groups</span>
|
||||
<button
|
||||
type="button"
|
||||
className="app-nav-add"
|
||||
onClick={() => {
|
||||
setNewGroupName("");
|
||||
setGroupCreateOpen(true);
|
||||
}}
|
||||
title="New group"
|
||||
aria-label="New group"
|
||||
>
|
||||
<Plus size={14} />
|
||||
</button>
|
||||
</div>
|
||||
{groups.map((g) => (
|
||||
<div key={g.name} className="app-group-row">
|
||||
<button
|
||||
type="button"
|
||||
className={
|
||||
tab === "accounts" && group === g.name
|
||||
? "app-nav-item active"
|
||||
: "app-nav-item"
|
||||
}
|
||||
onClick={() => selectGroup(g.name)}
|
||||
title={`${g.name} · ${g.count} accounts`}
|
||||
>
|
||||
<FolderGit2 size={16} />
|
||||
<span className="app-group-name">{g.name}</span>
|
||||
<span className="app-group-count">{g.count}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="app-group-del"
|
||||
onClick={() => setGroupDelete(g.name)}
|
||||
title={`Delete group ${g.name}`}
|
||||
aria-label={`Delete group ${g.name}`}
|
||||
>
|
||||
<X size={12} />
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
{groups.length === 0 && (
|
||||
<div className="app-nav-empty">No groups yet</div>
|
||||
)}
|
||||
</div>
|
||||
</nav>
|
||||
<div className="app-sidebar-footer">
|
||||
<Badge tone={running ? "success" : "muted"}>
|
||||
{running && <span className="pulse-dot" />}
|
||||
{running ? "Job running" : "Idle"}
|
||||
</Badge>
|
||||
{auth.needs && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={async () => {
|
||||
try {
|
||||
await api.post("/api/logout", {});
|
||||
} catch {
|
||||
/* expired token = already logged out, just clear local state */
|
||||
}
|
||||
setToken("");
|
||||
window.location.reload();
|
||||
}}
|
||||
>
|
||||
<LogOut size={14} /> <span>Sign out</span>
|
||||
</Button>
|
||||
)}
|
||||
<a
|
||||
className="app-support"
|
||||
href="https://t.me/alstack"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
title="@alstack"
|
||||
>
|
||||
<Heart size={12} />
|
||||
<span>Telegram</span>
|
||||
</a>
|
||||
<a
|
||||
className="app-credit"
|
||||
href="https://github.com/gbonnet65923/gh-regkit-prime"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
title="gbonnet65923/gh-regkit-prime"
|
||||
>
|
||||
<ExternalLink size={12} />
|
||||
<span>gh-regkit-prime</span>
|
||||
</a>
|
||||
</div>
|
||||
</aside>
|
||||
<main className="app-main" key={tab}>
|
||||
<ActivePanel
|
||||
onGotoAccounts={() => {
|
||||
setTab("accounts");
|
||||
setGroup("");
|
||||
}}
|
||||
onGotoStatus={() => {
|
||||
setTab("status");
|
||||
}}
|
||||
group={group}
|
||||
onClearGroup={() => setGroup("")}
|
||||
onGroupsChanged={loadGroups}
|
||||
/>
|
||||
</main>
|
||||
|
||||
{/* Mobile bottom nav: the three primary destinations, one thumb away. */}
|
||||
<nav className="app-bottomnav" aria-label="Primary">
|
||||
{NAV.map(({ id, label, icon: Icon }) => (
|
||||
<button
|
||||
key={id}
|
||||
type="button"
|
||||
className={
|
||||
tab === id
|
||||
? "app-bottomnav-item active"
|
||||
: "app-bottomnav-item"
|
||||
}
|
||||
onClick={() => {
|
||||
setTab(id);
|
||||
if (id === "accounts") setGroup("");
|
||||
}}
|
||||
aria-current={tab === id ? "page" : undefined}
|
||||
>
|
||||
<Icon size={19} />
|
||||
<span>{label}</span>
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
<Dialog
|
||||
open={groupCreateOpen}
|
||||
onClose={() => !groupBusy && setGroupCreateOpen(false)}
|
||||
title="New group"
|
||||
footer={
|
||||
<>
|
||||
<Button
|
||||
onClick={() => setGroupCreateOpen(false)}
|
||||
disabled={groupBusy}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
variant="primary"
|
||||
onClick={doCreateGroup}
|
||||
disabled={groupBusy || !newGroupName.trim()}
|
||||
>
|
||||
<Plus size={15} /> Create
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<div style={{ display: "grid", gap: 10 }}>
|
||||
<Input
|
||||
autoFocus
|
||||
value={newGroupName}
|
||||
onChange={(e) => setNewGroupName(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && doCreateGroup()}
|
||||
placeholder="Group name, e.g. Github"
|
||||
disabled={groupBusy}
|
||||
/>
|
||||
<div style={{ fontSize: 12, color: "var(--text-muted)" }}>
|
||||
Only letters, digits, <code>-</code>, <code>_</code>, and{" "}
|
||||
<code>.</code> (maks 60 karakter).
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
|
||||
<Dialog
|
||||
open={!!groupDelete}
|
||||
onClose={() => setGroupDelete(null)}
|
||||
title="Delete this group?"
|
||||
footer={
|
||||
<>
|
||||
<Button onClick={() => setGroupDelete(null)}>Cancel</Button>
|
||||
<Button
|
||||
variant="destructive"
|
||||
onClick={doDeleteGroup}
|
||||
disabled={groupBusy}
|
||||
>
|
||||
<X size={15} /> Delete
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
Group <strong>{groupDelete}</strong> will be deleted. Accounts inside
|
||||
are kept, only removed from the group.
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
const TOKEN_KEY = 'github-regkit-token'
|
||||
|
||||
export function getToken() {
|
||||
return localStorage.getItem(TOKEN_KEY) || ''
|
||||
}
|
||||
|
||||
export function setToken(token) {
|
||||
if (token) localStorage.setItem(TOKEN_KEY, token)
|
||||
else localStorage.removeItem(TOKEN_KEY)
|
||||
}
|
||||
|
||||
let _reloading = false
|
||||
function authFailed(url) {
|
||||
// Login/logout endpoints report credential errors themselves. Anything
|
||||
// else with 401/403 means the stored token is dead (e.g. server restarted
|
||||
// and wiped in-memory sessions): drop it and force a fresh login.
|
||||
// No stored token + 401/403 is just the logged-out probe (e.g. the initial
|
||||
// /api/config check) never reload or the login screen loops forever.
|
||||
if (url.includes('/api/auth') || url.includes('/api/logout')) return false
|
||||
if (!getToken()) return false
|
||||
setToken('')
|
||||
if (!_reloading) {
|
||||
_reloading = true
|
||||
window.location.reload()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async function request(method, url, body) {
|
||||
const headers = { 'Content-Type': 'application/json' }
|
||||
const token = getToken()
|
||||
if (token) headers['X-Access-Key'] = token
|
||||
const resp = await fetch(url, {
|
||||
method,
|
||||
headers,
|
||||
body: body === undefined ? undefined : JSON.stringify(body),
|
||||
})
|
||||
if (resp.status === 401 || resp.status === 403) {
|
||||
if (authFailed(url)) throw new Error('Session expired. Please log in again.')
|
||||
throw new Error('unauthorized')
|
||||
}
|
||||
const data = await resp.json().catch(() => ({}))
|
||||
if (!resp.ok || data.ok === false) {
|
||||
throw new Error(data.detail || data.message || `HTTP ${resp.status}`)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
async function uploadFile(url, file) {
|
||||
const headers = { 'Content-Type': 'text/plain' }
|
||||
const token = getToken()
|
||||
if (token) headers['X-Access-Key'] = token
|
||||
const resp = await fetch(url, { method: 'POST', headers, body: file })
|
||||
if (resp.status === 401 || resp.status === 403) {
|
||||
if (authFailed(url)) throw new Error('Session expired. Please log in again.')
|
||||
throw new Error('unauthorized')
|
||||
}
|
||||
const data = await resp.json().catch(() => ({}))
|
||||
if (!resp.ok || data.ok === false) throw new Error(data.detail || data.message || `HTTP ${resp.status}`)
|
||||
return data
|
||||
}
|
||||
|
||||
export const api = {
|
||||
get: (url) => request('GET', url),
|
||||
post: (url, body) => request('POST', url, body),
|
||||
put: (url, body) => request('PUT', url, body),
|
||||
del: (url, body) => request('DELETE', url, body),
|
||||
upload: uploadFile,
|
||||
}
|
||||
|
||||
export async function subscribeLogs(after, onLine) {
|
||||
const token = getToken()
|
||||
const headers = {}
|
||||
if (token) headers['X-Access-Key'] = token
|
||||
const resp = await fetch('/api/logs?after=' + after, { headers })
|
||||
if (!resp.ok) {
|
||||
if (resp.status === 401 || resp.status === 403) authFailed('/api/logs')
|
||||
throw new Error('log stream failed')
|
||||
}
|
||||
const reader = resp.body.getReader()
|
||||
const decoder = new TextDecoder()
|
||||
let buf = ''
|
||||
let closed = false
|
||||
|
||||
const read = async () => {
|
||||
while (!closed) {
|
||||
const { done, value } = await reader.read()
|
||||
if (done) break
|
||||
buf += decoder.decode(value, { stream: true })
|
||||
let idx
|
||||
while ((idx = buf.indexOf('\n\n')) !== -1) {
|
||||
const chunk = buf.slice(0, idx)
|
||||
buf = buf.slice(idx + 2)
|
||||
for (const line of chunk.split('\n')) {
|
||||
if (line.startsWith('data: ')) onLine(line.slice(6))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
read().catch(() => {})
|
||||
return () => {
|
||||
closed = true
|
||||
reader.cancel().catch(() => {})
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,35 @@
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import { ListEnd, Radio, Trash2 } from 'lucide-react'
|
||||
import { api, subscribeLogs } from '../api.js'
|
||||
import { Badge, Button, Card, EmptyState } from './ui.jsx'
|
||||
|
||||
export default function LogViewer() {
|
||||
const [lines, setLines] = useState([])
|
||||
const [follow, setFollow] = useState(true)
|
||||
const [live, setLive] = useState(false)
|
||||
const [loadError, setLoadError] = useState('')
|
||||
const boxRef = useRef(null)
|
||||
useEffect(() => {
|
||||
let closed = false; let unsubscribe = () => {}
|
||||
api.get('/api/logs/snapshot?limit=500').then((data) => {
|
||||
if (closed) return
|
||||
setLines(data.lines || []); setLive(true)
|
||||
setLoadError('')
|
||||
subscribeLogs(data.seq || 0, (line) => !closed && setLines((prev) => [...prev.slice(-1499), line])).then((unsub) => { if (!closed) unsubscribe = unsub }).catch(() => {})
|
||||
}).catch((error) => {
|
||||
if (!closed) setLoadError(error.message || 'Logs could not be loaded')
|
||||
})
|
||||
return () => { closed = true; unsubscribe(); setLive(false) }
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
const el = boxRef.current
|
||||
if (!follow || !el) return
|
||||
// Keep the newest event visible while the stream is active.
|
||||
el.scrollTop = el.scrollHeight
|
||||
}, [lines, follow])
|
||||
const color = (line) => line.includes('[+]') ? 'success' : line.includes('[-]') || line.includes('[!]') ? 'danger' : line.includes('[*]') ? 'accent' : ''
|
||||
return <div className="log-layout">
|
||||
<Card className="log-toolbar"><div className="log-toolbar-group"><Badge tone={live ? 'success' : 'muted'}><Radio size={12} />{live ? 'Streaming' : 'Connecting'}</Badge><span>{lines.length} lines</span></div><div className="log-toolbar-group"><label className="log-follow"><input type="checkbox" checked={follow} onChange={(e) => setFollow(e.target.checked)} /> Auto-scroll</label><Button size="sm" onClick={() => setLines([])}><Trash2 size={14} /> Clear</Button></div></Card>
|
||||
<Card className="log-terminal" ref={boxRef}>{loadError ? <div className="panel-state panel-state-error"><strong>Unable to load logs</strong><span>{loadError}</span><Button onClick={() => window.location.reload()}>Retry</Button></div> : lines.length === 0 ? <EmptyState icon={ListEnd} title="No logs yet" description="Start a job from the Status page to view events in real time." /> : lines.map((line, index) => <div key={index} className={`log-line ${color(line)}`}>{line}</div>)}</Card>
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,434 @@
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import {
|
||||
AlertTriangle,
|
||||
CheckCircle2,
|
||||
Clock3,
|
||||
FileText,
|
||||
ListChecks,
|
||||
Play,
|
||||
Square,
|
||||
Target,
|
||||
XCircle,
|
||||
} from "lucide-react";
|
||||
import { api } from "../api.js";
|
||||
import { Badge, Button, Card, Input, Spinner } from "./ui.jsx";
|
||||
import LogViewer from "./LogViewer.jsx";
|
||||
|
||||
const fmtTime = (ts) =>
|
||||
ts ? new Date(ts * 1000).toLocaleTimeString("en-US", { hour12: false }) : "-";
|
||||
|
||||
const fmtDuration = (sec) => {
|
||||
if (!Number.isFinite(sec) || sec < 0) return "-";
|
||||
const s = Math.floor(sec);
|
||||
const h = Math.floor(s / 3600);
|
||||
const m = Math.floor((s % 3600) / 60);
|
||||
const r = s % 60;
|
||||
const pad = (n) => String(n).padStart(2, "0");
|
||||
return h > 0 ? `${pad(h)}.${pad(m)}.${pad(r)}` : `${pad(m)}.${pad(r)}`;
|
||||
};
|
||||
|
||||
export default function StatusPanel({ onGotoAccounts }) {
|
||||
const [state, setState] = useState(null);
|
||||
const [count, setCount] = useState(1);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [loadError, setLoadError] = useState("");
|
||||
const [now, setNow] = useState(Date.now());
|
||||
const timer = useRef(null);
|
||||
const tickTimer = useRef(null);
|
||||
|
||||
const refresh = useCallback(() => {
|
||||
api
|
||||
.get("/api/status")
|
||||
.then((data) => {
|
||||
setState(data);
|
||||
setLoadError("");
|
||||
})
|
||||
.catch((error) => setLoadError(error.message || "Status could not be loaded"));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
refresh();
|
||||
timer.current = setInterval(refresh, 1500);
|
||||
tickTimer.current = setInterval(() => setNow(Date.now()), 1000);
|
||||
return () => {
|
||||
clearInterval(timer.current);
|
||||
clearInterval(tickTimer.current);
|
||||
};
|
||||
}, [refresh]);
|
||||
|
||||
const running = !!state?.running;
|
||||
const target = state?.target ?? 0;
|
||||
const success = state?.success ?? 0;
|
||||
const failed = state?.fail ?? 0;
|
||||
const done = success + failed;
|
||||
|
||||
// progress: only meaningful when target > 0
|
||||
const progress =
|
||||
target > 0 ? Math.min(100, Math.round((done / target) * 100)) : 0;
|
||||
|
||||
// elapsed live counter
|
||||
const elapsedSec = useMemo(() => {
|
||||
if (!state?.started_at) return 0;
|
||||
const end = state?.finished_at ? state.finished_at * 1000 : now;
|
||||
return Math.max(0, (end - state.started_at * 1000) / 1000);
|
||||
}, [state?.started_at, state?.finished_at, now]);
|
||||
|
||||
// status label + tone
|
||||
const statusInfo = useMemo(() => {
|
||||
if (running)
|
||||
return { label: "Running", tone: "ok", title: "Creating accounts" };
|
||||
if (state?.error)
|
||||
return { label: "Error", tone: "bad", title: "Job failed" };
|
||||
if (state?.finished_at) {
|
||||
if (target > 0 && done >= target && failed === 0)
|
||||
return {
|
||||
label: "Completed",
|
||||
tone: "ok",
|
||||
title: "All accounts were created",
|
||||
};
|
||||
if (target > 0 && done < target)
|
||||
return {
|
||||
label: "Stopped",
|
||||
tone: "muted",
|
||||
title: "Job stopped before completion",
|
||||
};
|
||||
if (failed > 0 && success === 0)
|
||||
return {
|
||||
label: "All failed",
|
||||
tone: "bad",
|
||||
title: "No accounts were created",
|
||||
};
|
||||
return { label: "Completed", tone: "ok", title: "Job completed" };
|
||||
}
|
||||
return { label: "Ready", tone: "muted", title: "Ready to register" };
|
||||
}, [
|
||||
running,
|
||||
state?.error,
|
||||
state?.finished_at,
|
||||
target,
|
||||
done,
|
||||
failed,
|
||||
success,
|
||||
]);
|
||||
|
||||
const progressTone = statusInfo.tone;
|
||||
|
||||
async function start() {
|
||||
setBusy(true);
|
||||
try {
|
||||
await api.post("/api/start", { count });
|
||||
refresh();
|
||||
} catch (e) {
|
||||
alert(e.message);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function stop() {
|
||||
setBusy(true);
|
||||
try {
|
||||
await api.post("/api/stop");
|
||||
refresh();
|
||||
} catch (e) {
|
||||
alert(e.message);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={styles.wrap}>
|
||||
{/* hero */}
|
||||
<Card style={styles.hero}>
|
||||
<div style={styles.heroText}>
|
||||
<div style={styles.eyebrow}>GITHUB ACCOUNT REGISTRATION</div>
|
||||
<h1 style={styles.heroTitle}>{statusInfo.title}</h1>
|
||||
</div>
|
||||
<Badge
|
||||
tone={
|
||||
statusInfo.tone === "ok"
|
||||
? "success"
|
||||
: statusInfo.tone === "bad"
|
||||
? "danger"
|
||||
: "muted"
|
||||
}
|
||||
className="status-hero-badge"
|
||||
>
|
||||
{running && <span className="pulse-dot" />}
|
||||
{statusInfo.label}
|
||||
</Badge>
|
||||
</Card>
|
||||
|
||||
{/* Metrics share one surface with hairline dividers so they read as a
|
||||
single summary, not six separate boxes. */}
|
||||
<Card style={styles.metricsCard}>
|
||||
<div className="status-metrics">
|
||||
<Stat label="Target" value={target} icon={Target} />
|
||||
<Stat label="Success" value={success} tone="ok" icon={CheckCircle2} />
|
||||
<Stat label="Failed" value={failed} tone="bad" icon={XCircle} />
|
||||
<Stat
|
||||
label="Progress"
|
||||
value={target > 0 ? `${done}/${target}` : "-"}
|
||||
hint={target > 0 ? `${progress}%` : null}
|
||||
icon={ListChecks}
|
||||
/>
|
||||
<Stat
|
||||
label="Started"
|
||||
value={fmtTime(state?.started_at)}
|
||||
icon={Play}
|
||||
small
|
||||
/>
|
||||
<Stat
|
||||
label={running ? "Elapsed" : "Duration"}
|
||||
value={fmtDuration(elapsedSec)}
|
||||
icon={running ? Clock3 : Square}
|
||||
small
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{/* Show progress only after the server has a target. */}
|
||||
{target > 0 && (
|
||||
<Card style={styles.progressCard}>
|
||||
<div style={styles.progressHead}>
|
||||
<span style={{ color: "var(--muted)", fontWeight: 600 }}>
|
||||
Progress
|
||||
</span>
|
||||
<span style={{ fontWeight: 700 }}>
|
||||
{done} / {target}{" "}
|
||||
<span style={{ color: "var(--muted)", fontWeight: 500 }}>
|
||||
({progress}%)
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div style={styles.progressTrack}>
|
||||
<div
|
||||
style={{
|
||||
...styles.progressFill,
|
||||
width: `${progress}%`,
|
||||
background: progressFillColor(progressTone, running),
|
||||
boxShadow: progressGlow(progressTone),
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{(success > 0 || failed > 0) && (
|
||||
<div style={styles.progressLegend}>
|
||||
<span style={{ color: "var(--ok)" }}>● {success} success</span>
|
||||
<span style={{ color: "var(--danger)" }}>● {failed} failed</span>
|
||||
{running && target - done > 0 && (
|
||||
<span style={{ color: "var(--muted)" }}>
|
||||
● {target - done} pending
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{state?.error && (
|
||||
<Card style={styles.errorCard}>
|
||||
<span
|
||||
style={{ color: "var(--danger)", fontSize: 13, fontWeight: 600 }}
|
||||
>
|
||||
<AlertTriangle
|
||||
size={15}
|
||||
style={{ verticalAlign: "text-bottom", marginRight: 6 }}
|
||||
/>
|
||||
{state.error}
|
||||
</span>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* controls: one grouped surface, one clear action area */}
|
||||
<Card className="status-controls">
|
||||
<div className="status-control-block">
|
||||
<span className="status-control-label">Account count</span>
|
||||
<div className="status-stepper">
|
||||
<button
|
||||
type="button"
|
||||
className="status-stepper-btn"
|
||||
onClick={() => setCount((c) => Math.max(1, c - 1))}
|
||||
disabled={running || count <= 1}
|
||||
aria-label="Decrease count"
|
||||
>
|
||||
−
|
||||
</button>
|
||||
<Input
|
||||
type="number"
|
||||
min="1"
|
||||
max="1000"
|
||||
value={count}
|
||||
className="status-count-input"
|
||||
onChange={(e) =>
|
||||
setCount(
|
||||
Math.max(1, Math.min(1000, Number(e.target.value) || 1)),
|
||||
)
|
||||
}
|
||||
disabled={running}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
className="status-stepper-btn"
|
||||
onClick={() => setCount((c) => Math.min(1000, c + 1))}
|
||||
disabled={running || count >= 1000}
|
||||
aria-label="Increase count"
|
||||
>
|
||||
+
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="status-actions">
|
||||
<Button
|
||||
variant="primary"
|
||||
className="status-action-primary"
|
||||
onClick={start}
|
||||
disabled={running || busy}
|
||||
>
|
||||
<Play size={16} /> Start
|
||||
</Button>
|
||||
<Button
|
||||
variant="destructive"
|
||||
className="status-action-stop"
|
||||
onClick={stop}
|
||||
disabled={!running || busy}
|
||||
>
|
||||
<Square size={15} /> Stop
|
||||
</Button>
|
||||
<Button className="status-action-nav" onClick={onGotoAccounts}>
|
||||
<FileText size={16} /> Accounts
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{state === null && !loadError && (
|
||||
<Card className="status-state-card">
|
||||
<Spinner />
|
||||
<span>Loading job status</span>
|
||||
</Card>
|
||||
)}
|
||||
{loadError && (
|
||||
<Card className="status-state-card status-state-error">
|
||||
<strong>Unable to load job status</strong>
|
||||
<span>{loadError}</span>
|
||||
<Button onClick={refresh}>Retry</Button>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
<LogViewer />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Stat({ label, value, tone, small, icon: Icon, hint }) {
|
||||
const color =
|
||||
tone === "ok"
|
||||
? "var(--ok)"
|
||||
: tone === "bad"
|
||||
? "var(--danger)"
|
||||
: "var(--text)";
|
||||
return (
|
||||
<div className="status-stat">
|
||||
<div className="status-stat-head">
|
||||
<Icon size={14} className="status-stat-icon" style={{ color }} />
|
||||
<span className="status-stat-label">{label}</span>
|
||||
</div>
|
||||
<div
|
||||
className={small ? "status-stat-value is-small" : "status-stat-value"}
|
||||
style={{ color }}
|
||||
>
|
||||
{value}
|
||||
</div>
|
||||
{hint && <div className="status-stat-hint">{hint}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// helper: progress bar gradient depending on state
|
||||
function progressFillColor(tone, running) {
|
||||
if (tone === "bad") return "var(--danger)";
|
||||
if (tone === "muted" && !running) return "var(--border-strong)";
|
||||
return "var(--accent)";
|
||||
}
|
||||
function progressGlow(tone) {
|
||||
return "none";
|
||||
}
|
||||
|
||||
const styles = {
|
||||
wrap: {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: 14,
|
||||
maxWidth: 980,
|
||||
width: "100%",
|
||||
margin: "0 auto",
|
||||
},
|
||||
hero: {
|
||||
padding: "clamp(18px, 3vw, 26px)",
|
||||
display: "flex",
|
||||
gap: 16,
|
||||
alignItems: "flex-start",
|
||||
justifyContent: "space-between",
|
||||
flexWrap: "wrap",
|
||||
background:
|
||||
"var(--bg-card)",
|
||||
},
|
||||
heroText: { flex: "1 1 260px", minWidth: 0 },
|
||||
eyebrow: {
|
||||
fontSize: 11.5,
|
||||
color: "var(--muted)",
|
||||
fontWeight: 700,
|
||||
letterSpacing: 0.6,
|
||||
marginBottom: 6,
|
||||
},
|
||||
heroTitle: {
|
||||
fontSize: "clamp(20px, 4.5vw, 26px)",
|
||||
fontWeight: 800,
|
||||
letterSpacing: -0.4,
|
||||
lineHeight: 1.2,
|
||||
color: "var(--text-primary)",
|
||||
},
|
||||
|
||||
metricsCard: { padding: 0, overflow: "hidden" },
|
||||
progressCard: { padding: "16px 20px" },
|
||||
progressHead: {
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "baseline",
|
||||
fontSize: 12.5,
|
||||
marginBottom: 10,
|
||||
flexWrap: "wrap",
|
||||
gap: 8,
|
||||
},
|
||||
progressTrack: {
|
||||
height: 10,
|
||||
borderRadius: 4,
|
||||
background: "var(--bg-input)",
|
||||
overflow: "hidden",
|
||||
},
|
||||
progressFill: {
|
||||
height: "100%",
|
||||
borderRadius: 4,
|
||||
transition: "width 0.5s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s",
|
||||
},
|
||||
progressLegend: {
|
||||
display: "flex",
|
||||
gap: 14,
|
||||
flexWrap: "wrap",
|
||||
marginTop: 10,
|
||||
fontSize: 12,
|
||||
fontWeight: 600,
|
||||
},
|
||||
|
||||
errorCard: {
|
||||
padding: "14px 18px",
|
||||
borderColor: "rgba(var(--danger-rgb),0.4)",
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,68 @@
|
||||
import React, { useEffect, useRef } from 'react'
|
||||
|
||||
const cx = (...classes) => classes.filter(Boolean).join(' ')
|
||||
|
||||
export const Card = React.forwardRef(function Card({ className, children, ...props }, ref) {
|
||||
return <section ref={ref} className={cx('ui-card', className)} {...props}>{children}</section>
|
||||
})
|
||||
|
||||
export function Button({ className, variant = 'outline', size = 'default', children, ...props }) {
|
||||
return (
|
||||
<button className={cx('ui-button', `ui-button-${variant}`, `ui-button-${size}`, className)} {...props}>
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
export function Input({ className, ...props }) {
|
||||
return <input className={cx('ui-input', className)} {...props} />
|
||||
}
|
||||
|
||||
export function Badge({ tone = 'muted', children, className }) {
|
||||
return <span className={cx('ui-badge', `ui-badge-${tone}`, className)}>{children}</span>
|
||||
}
|
||||
|
||||
export function Dialog({ open, onClose, title, children, footer }) {
|
||||
const dialogRef = useRef(null)
|
||||
const onCloseRef = useRef(onClose)
|
||||
|
||||
useEffect(() => {
|
||||
onCloseRef.current = onClose
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return undefined
|
||||
if (document.activeElement === document.body) dialogRef.current?.focus()
|
||||
const onKeyDown = (event) => {
|
||||
if (event.key === 'Escape') onCloseRef.current()
|
||||
}
|
||||
document.addEventListener('keydown', onKeyDown)
|
||||
return () => document.removeEventListener('keydown', onKeyDown)
|
||||
}, [open])
|
||||
|
||||
if (!open) return null
|
||||
return (
|
||||
<div className="ui-dialog-backdrop" role="presentation" onMouseDown={onClose}>
|
||||
<section ref={dialogRef} tabIndex="-1" className="ui-dialog" role="dialog" aria-modal="true" aria-label={title} onMouseDown={(e) => e.stopPropagation()}>
|
||||
{title && <header className="ui-dialog-header"><h2>{title}</h2><button type="button" className="ui-dialog-close" onClick={onClose} aria-label="Close dialog">×</button></header>}
|
||||
<div className="ui-dialog-body">{children}</div>
|
||||
{footer && <footer className="ui-dialog-footer">{footer}</footer>}
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function Spinner({ className }) {
|
||||
return <span className={cx('ui-spinner', className)} aria-label="Loading" />
|
||||
}
|
||||
|
||||
export function EmptyState({ icon: Icon, title, description, action }) {
|
||||
return (
|
||||
<div className="ui-empty-state">
|
||||
{Icon && <Icon size={28} strokeWidth={1.7} />}
|
||||
<strong>{title}</strong>
|
||||
{description && <p>{description}</p>}
|
||||
{action}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/* Shared styles for the zone modal and account notifications. */
|
||||
|
||||
.glass {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-card);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.glass-strong { background: var(--bg-card-hover); }
|
||||
|
||||
.glass-btn {
|
||||
display: inline-flex; align-items: center; justify-content: center; gap: 8px;
|
||||
min-height: 44px;
|
||||
border: 1px solid var(--border);
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
border-radius: var(--radius-control);
|
||||
padding: 9px 16px;
|
||||
font-family: inherit; font-size: 13px; font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: border-color 150ms ease-out, background 150ms ease-out, color 150ms ease-out;
|
||||
user-select: none;
|
||||
}
|
||||
.glass-btn:hover:not(:disabled) {
|
||||
border-color: var(--color-smoke-gray);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.glass-btn:disabled { opacity: 0.42; cursor: not-allowed; }
|
||||
.glass-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
||||
|
||||
.glass-btn.primary {
|
||||
background: var(--accent);
|
||||
border-color: transparent;
|
||||
color: var(--color-void-black);
|
||||
font-weight: 600;
|
||||
}
|
||||
.glass-btn.primary:hover:not(:disabled) { background: var(--accent-strong); }
|
||||
|
||||
.glass-btn.danger {
|
||||
border-color: rgba(var(--danger-rgb), 0.40);
|
||||
color: var(--danger);
|
||||
}
|
||||
.glass-btn.danger:hover:not(:disabled) {
|
||||
background: rgba(var(--danger-rgb), 0.12);
|
||||
border-color: rgba(var(--danger-rgb), 0.60);
|
||||
}
|
||||
|
||||
.glass-input {
|
||||
width: 100%;
|
||||
min-height: 44px;
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text-primary);
|
||||
border-radius: var(--radius-control);
|
||||
padding: 10px 14px;
|
||||
font-family: inherit; font-size: 13.5px;
|
||||
transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
|
||||
}
|
||||
.glass-input:focus {
|
||||
border-color: rgba(var(--accent-rgb), 0.70);
|
||||
box-shadow: var(--ring);
|
||||
outline: none;
|
||||
}
|
||||
.glass-input::placeholder { color: var(--text-muted); }
|
||||
|
||||
.glass-input.number {
|
||||
width: 86px; text-align: center;
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
.glass-input.number::-webkit-inner-spin-button { display: none; }
|
||||
|
||||
.glass-segmented {
|
||||
display: inline-flex; gap: 4px; padding: 4px;
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-control);
|
||||
}
|
||||
.glass-segmented button {
|
||||
border: none; background: transparent; color: var(--text-muted);
|
||||
font-family: inherit; font-size: 13px; font-weight: 500;
|
||||
min-height: 36px;
|
||||
padding: 8px 16px; border-radius: var(--radius-control); cursor: pointer;
|
||||
transition: background 150ms ease-out, color 150ms ease-out;
|
||||
display: inline-flex; align-items: center; gap: 7px;
|
||||
}
|
||||
.glass-segmented button.active {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.badge {
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
font-size: 11px; font-weight: 600;
|
||||
padding: 5px 11px; border-radius: var(--radius-control);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
.badge.ok { color: var(--success); border-color: rgba(var(--success-rgb), 0.35); }
|
||||
.badge.bad { color: var(--danger); border-color: rgba(var(--danger-rgb), 0.40); }
|
||||
.badge.accent { color: var(--accent-text); border-color: rgba(var(--accent-rgb), 0.35); }
|
||||
.badge.muted { color: var(--text-muted); }
|
||||
|
||||
.pulse-dot {
|
||||
width: 8px; height: 8px; border-radius: 50%;
|
||||
background: var(--success);
|
||||
animation: none;
|
||||
}
|
||||
|
||||
.fade-in { animation: fadeIn 0.25s ease-out; }
|
||||
|
||||
.toast {
|
||||
position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
|
||||
z-index: 999; padding: 12px 22px;
|
||||
max-width: calc(100vw - 32px);
|
||||
color: var(--text-primary);
|
||||
animation: toastIn 0.22s ease-out;
|
||||
}
|
||||
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
|
||||
|
||||
/* Keep toasts above the mobile bottom nav. */
|
||||
@media (max-width: 820px) {
|
||||
.toast { bottom: calc(var(--bottom-nav-height) + 16px + env(safe-area-inset-bottom)); }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import App from './App.jsx'
|
||||
import './glass.css'
|
||||
import './ui.css'
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
)
|
||||
+1051
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,153 @@
|
||||
const { chromium } = require('playwright')
|
||||
const BASE = process.env.BASE || 'http://127.0.0.1:8093'
|
||||
|
||||
const log = []
|
||||
const step = (ok, msg) => { log.push(`${ok ? 'PASS' : 'FAIL'} ${msg}`); return ok }
|
||||
|
||||
async function clickTab(page, label) {
|
||||
await page.evaluate((lbl) => {
|
||||
const nodes = [...document.querySelectorAll('.app-bottomnav-item, .app-nav-item')]
|
||||
for (const el of nodes) { const r = el.getBoundingClientRect(); if ((el.textContent || '').trim() === lbl && r.width > 0 && r.left >= -1 && r.right <= window.innerWidth + 1) { el.click(); return } }
|
||||
}, label)
|
||||
await page.waitForTimeout(500)
|
||||
}
|
||||
|
||||
;(async () => {
|
||||
const browser = await chromium.launch()
|
||||
const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } })
|
||||
const page = await ctx.newPage()
|
||||
const errs = []
|
||||
page.on('console', (m) => m.type() === 'error' && errs.push(m.text()))
|
||||
page.on('pageerror', (e) => errs.push('pageerror: ' + e.message))
|
||||
|
||||
await page.goto(BASE, { waitUntil: 'domcontentloaded' })
|
||||
await page.waitForTimeout(900)
|
||||
|
||||
// 1. Status tab: count stepper +/-, Start/Stop buttons exist and are wired.
|
||||
step(await page.locator('.status-stepper-btn').first().isVisible(), 'Status: count stepper visible')
|
||||
const before = await page.locator('.status-count-input').inputValue()
|
||||
await page.locator('.status-stepper-btn').last().click()
|
||||
await page.waitForTimeout(150)
|
||||
const after = await page.locator('.status-count-input').inputValue()
|
||||
step(Number(after) === Number(before) + 1, `Status: "+" increments count (${before} -> ${after})`)
|
||||
await page.locator('.status-stepper-btn').first().click()
|
||||
await page.waitForTimeout(150)
|
||||
step((await page.locator('.status-count-input').inputValue()) === before, 'Status: "-" decrements count')
|
||||
|
||||
// 2. Log terminal: Clear button empties lines.
|
||||
const linesBefore = await page.locator('.log-line').count()
|
||||
await page.locator('.log-toolbar .ui-button').click()
|
||||
await page.waitForTimeout(300)
|
||||
const linesAfter = await page.locator('.log-line').count()
|
||||
step(linesAfter === 0, `Log: Clear empties terminal (${linesBefore} -> ${linesAfter})`)
|
||||
step(await page.locator('.log-terminal .ui-empty-state').isVisible(), 'Log: empty state shown after clear')
|
||||
|
||||
// 3. Auto-scroll checkbox toggles.
|
||||
await page.locator('.log-follow input[type=checkbox]').click()
|
||||
await page.waitForTimeout(100)
|
||||
step(!(await page.locator('.log-follow input[type=checkbox]').isChecked()), 'Log: auto-scroll checkbox toggles')
|
||||
|
||||
// 4. Accounts tab.
|
||||
await clickTab(page, 'Accounts')
|
||||
step(await page.locator('.accounts-head').isVisible(), 'Accounts: header renders')
|
||||
const exportBtn = page.locator('.export-wrap .ui-button')
|
||||
step(await exportBtn.isVisible(), 'Accounts: Export button visible')
|
||||
await exportBtn.click()
|
||||
await page.waitForTimeout(250)
|
||||
step(await page.locator('.action-menu-inline').isVisible(), 'Accounts: Export menu opens')
|
||||
await page.keyboard.press('Escape')
|
||||
await page.waitForTimeout(200)
|
||||
step(!(await page.locator('.action-menu-inline').isVisible()), 'Accounts: Export menu closes on Escape')
|
||||
|
||||
// 5. Config tab: provider radios switch fields.
|
||||
await clickTab(page, 'Config')
|
||||
step(await page.locator('.cfg-columns').isVisible(), 'Config: layout renders')
|
||||
const litensi = page.locator('label:has-text("Litensi")').first()
|
||||
await litensi.click()
|
||||
await page.waitForTimeout(300)
|
||||
step(await page.locator('text=Litensi API ID').isVisible(), 'Config: switching to Litensi shows its fields')
|
||||
await page.locator('label:has-text("Mail.cx")').first().click()
|
||||
await page.waitForTimeout(300)
|
||||
step(await page.locator('text=Mail.cx Domain').first().isVisible(), 'Config: switching back to Mail.cx shows its fields')
|
||||
|
||||
// 6. Zones modal (uses the design-system modal) opens + closes.
|
||||
await page.locator('label:has-text("Litensi")').first().click()
|
||||
await page.waitForTimeout(250)
|
||||
const zonesBtn = page.locator('button:has-text("Zones")').first()
|
||||
if (await zonesBtn.isVisible()) {
|
||||
await zonesBtn.click()
|
||||
await page.waitForTimeout(1200)
|
||||
const modalOpen = await page.locator('.glass').first().isVisible()
|
||||
step(modalOpen, 'Config: Zones modal opens')
|
||||
if (modalOpen) {
|
||||
await page.locator('.glass button:has-text("Close")').click()
|
||||
await page.waitForTimeout(300)
|
||||
step(!(await page.locator('.glass').first().isVisible()), 'Config: Zones modal closes')
|
||||
}
|
||||
}
|
||||
|
||||
// 7. New group dialog: open, type, cancel.
|
||||
await page.locator('.app-nav-add').click()
|
||||
await page.waitForTimeout(300)
|
||||
step(await page.locator('.ui-dialog').isVisible(), 'Group: New group dialog opens')
|
||||
await page.locator('.ui-dialog input').fill('TestGroup')
|
||||
await page.waitForTimeout(100)
|
||||
await page.keyboard.press('Escape')
|
||||
await page.waitForTimeout(300)
|
||||
step(!(await page.locator('.ui-dialog').isVisible()), 'Group: dialog closes on Escape')
|
||||
|
||||
// 8. Sidebar collapse toggle (desktop).
|
||||
await page.locator('.app-sidebar-toggle').click()
|
||||
await page.waitForTimeout(300)
|
||||
const collapsed = await page.locator('.app-shell-collapsed').count()
|
||||
step(collapsed > 0, 'Sidebar: collapse toggle works')
|
||||
await page.locator('.app-sidebar-toggle').click()
|
||||
await page.waitForTimeout(300)
|
||||
|
||||
// 9. Keyboard: Tab reaches a focusable control with visible focus.
|
||||
await page.keyboard.press('Tab')
|
||||
const focused = await page.evaluate(() => document.activeElement?.tagName)
|
||||
step(['BUTTON', 'A', 'INPUT'].includes(focused), `Keyboard: Tab focuses a control (${focused})`)
|
||||
|
||||
await ctx.close()
|
||||
|
||||
// Mobile pass: drawer open/close, bottom nav switches.
|
||||
const mctx = await browser.newContext({ viewport: { width: 390, height: 844 }, hasTouch: true, isMobile: true })
|
||||
const mp = await mctx.newPage()
|
||||
mp.on('console', (m) => m.type() === 'error' && errs.push('[mobile] ' + m.text()))
|
||||
mp.on('pageerror', (e) => errs.push('[mobile] pageerror: ' + e.message))
|
||||
await mp.goto(BASE, { waitUntil: 'domcontentloaded' })
|
||||
await mp.waitForTimeout(900)
|
||||
|
||||
await mp.locator('.app-menu-btn').click()
|
||||
await mp.waitForTimeout(350)
|
||||
step(await mp.locator('.app-sidebar').isVisible(), 'Mobile: Menu opens drawer')
|
||||
await mp.locator('.app-drawer-scrim').click({ position: { x: 380, y: 400 } })
|
||||
await mp.waitForTimeout(350)
|
||||
const drawerGone = await mp.locator('.app-sidebar').evaluate((el) => el.getBoundingClientRect().right <= 0)
|
||||
step(drawerGone, 'Mobile: scrim click closes drawer')
|
||||
await clickTab(mp, 'Accounts')
|
||||
step(await mp.locator('.accounts-head').isVisible(), 'Mobile: bottom nav switches to Accounts')
|
||||
await clickTab(mp, 'Status')
|
||||
step(await mp.locator('.status-metrics').isVisible(), 'Mobile: bottom nav switches back to Status')
|
||||
|
||||
// Bottom nav must be fixed and content must clear it.
|
||||
const clear = await mp.evaluate(() => {
|
||||
const nav = document.querySelector('.app-bottomnav')
|
||||
const main = document.querySelector('.app-main')
|
||||
const navR = nav.getBoundingClientRect()
|
||||
const pad = parseFloat(getComputedStyle(main).paddingBottom)
|
||||
return { navTop: Math.round(navR.top), viewportH: window.innerHeight, pad: Math.round(pad), navH: Math.round(navR.height) }
|
||||
})
|
||||
step(clear.pad >= clear.navH, `Mobile: content padding (${clear.pad}) >= bottom nav height (${clear.navH})`)
|
||||
await mctx.close()
|
||||
await browser.close()
|
||||
|
||||
console.log('=== CLICK-THROUGH ===')
|
||||
log.forEach((l) => console.log(' ' + l))
|
||||
console.log('\n=== CONSOLE ERRORS ===')
|
||||
console.log(errs.length ? errs.join('\n') : '(none)')
|
||||
const fails = log.filter((l) => l.startsWith('FAIL')).length
|
||||
console.log(`\nFailures: ${fails}, console errors: ${errs.length}`)
|
||||
process.exit(fails || errs.length ? 1 : 0)
|
||||
})().catch((e) => { console.error('FATAL', e); process.exit(1) })
|
||||
@@ -0,0 +1,196 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* UI verification for the GitHub Register console.
|
||||
*
|
||||
* Checks the redesign against the hard requirements it must hold at every
|
||||
* screen width: no horizontal overflow, no clipped controls, 44px tap targets,
|
||||
* WCAG AA text contrast, and working navigation / dialogs.
|
||||
*
|
||||
* Usage: node verify-ui.cjs [baseUrl]
|
||||
* Requires a running server (default http://127.0.0.1:8093) serving the build.
|
||||
*/
|
||||
const { chromium } = require('playwright')
|
||||
|
||||
const BASE = process.argv[2] || process.env.BASE || 'http://127.0.0.1:8093'
|
||||
const log = []
|
||||
const step = (ok, msg) => { log.push(`${ok ? 'PASS' : 'FAIL'} ${msg}`); return ok }
|
||||
|
||||
// ---- WCAG contrast helpers ----
|
||||
const lum = ([r, g, b]) => {
|
||||
const a = [r, g, b].map((v) => { v /= 255; return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4) })
|
||||
return 0.2126 * a[0] + 0.7152 * a[1] + 0.0722 * a[2]
|
||||
}
|
||||
const contrast = (f, b) => { const L1 = lum(f), L2 = lum(b); const [hi, lo] = L1 > L2 ? [L1, L2] : [L2, L1]; return (hi + 0.05) / (lo + 0.05) }
|
||||
const rgba = (s) => { const m = s.match(/rgba?\(([^)]+)\)/); if (!m) return null; const p = m[1].split(',').map(Number); return [p[0], p[1], p[2], p[3] === undefined ? 1 : p[3]] }
|
||||
|
||||
const clickTab = (page, label) => page.evaluate((lbl) => {
|
||||
const nodes = [...document.querySelectorAll('.app-bottomnav-item, .app-nav-item')]
|
||||
for (const el of nodes) {
|
||||
const r = el.getBoundingClientRect()
|
||||
if ((el.textContent || '').trim() === lbl && r.width > 0 && r.left >= -1 && r.right <= window.innerWidth + 1) { el.click(); return true }
|
||||
}
|
||||
return false
|
||||
}, label)
|
||||
|
||||
// Page-level overflow, ignoring the intentionally off-canvas mobile drawer.
|
||||
const pageOverflow = (page) => page.evaluate(() => {
|
||||
const de = document.documentElement
|
||||
return de.scrollWidth > de.clientWidth + 1 ? { s: de.scrollWidth, c: de.clientWidth } : null
|
||||
})
|
||||
|
||||
async function auditWidth(browser, width, height) {
|
||||
const ctx = await browser.newContext({ viewport: { width, height }, hasTouch: width <= 820, isMobile: width <= 820 })
|
||||
const page = await ctx.newPage()
|
||||
const errs = []
|
||||
page.on('pageerror', (e) => errs.push(e.message))
|
||||
await page.goto(BASE, { waitUntil: 'domcontentloaded' })
|
||||
await page.waitForTimeout(700)
|
||||
|
||||
const results = {}
|
||||
for (const tab of ['Status', 'Config', 'Accounts']) {
|
||||
await clickTab(page, tab)
|
||||
await page.waitForTimeout(600)
|
||||
results[tab] = {
|
||||
overflow: await pageOverflow(page),
|
||||
clipped: await page.evaluate(() => {
|
||||
const vw = window.innerWidth
|
||||
const drawer = document.querySelector('.app-sidebar')
|
||||
const open = !!document.querySelector('.app-drawer-open')
|
||||
const inScroller = (el) => {
|
||||
let a = el.parentElement
|
||||
while (a) {
|
||||
const ox = getComputedStyle(a).overflowX
|
||||
if (ox === 'auto' || ox === 'scroll') return true
|
||||
a = a.parentElement
|
||||
}
|
||||
return false
|
||||
}
|
||||
const out = []
|
||||
document.querySelectorAll('button, a[href], input, select').forEach((el) => {
|
||||
const r = el.getBoundingClientRect()
|
||||
const s = getComputedStyle(el)
|
||||
if (s.display === 'none' || s.visibility === 'hidden' || r.width === 0 || r.height === 0) return
|
||||
if (!open && drawer && drawer.contains(el)) return
|
||||
// A contained horizontal scroll region (e.g. the accounts table) is
|
||||
// the sanctioned way to keep a wide table usable; its children may
|
||||
// legitimately extend past the viewport.
|
||||
if (inScroller(el)) return
|
||||
if (r.right > vw + 1 || r.left < -1) out.push(String(el.className).slice(0, 40))
|
||||
})
|
||||
return out
|
||||
}),
|
||||
smallTargets: await page.evaluate(() => {
|
||||
const out = []
|
||||
const afterArea = (el) => {
|
||||
// Buttons may expand their hit area with an ::after overlay.
|
||||
const a = getComputedStyle(el, '::after')
|
||||
if (a && a.content && a.content !== 'none' && a.position === 'absolute') {
|
||||
const inset = parseFloat(a.top)
|
||||
if (Number.isFinite(inset)) return inset < 0 ? -inset * 2 : 0
|
||||
}
|
||||
return 0
|
||||
}
|
||||
document.querySelectorAll('button, a[href], input:not([type=hidden]), select, [role=menuitem]').forEach((el) => {
|
||||
const r = el.getBoundingClientRect()
|
||||
const s = getComputedStyle(el)
|
||||
if (s.display === 'none' || s.visibility === 'hidden' || r.width === 0 || r.height === 0) return
|
||||
if (el.tagName === 'A' && s.display.includes('inline') && !s.display.includes('flex')) return
|
||||
const label = el.closest('label')
|
||||
const grow = afterArea(el)
|
||||
const effH = Math.max(r.height + grow, label ? label.getBoundingClientRect().height : 0)
|
||||
const effW = Math.max(r.width + grow, label ? label.getBoundingClientRect().width : 0)
|
||||
if (effH < 44 || effW < 24) out.push({ cls: String(el.className).slice(0, 40), h: Math.round(effH), w: Math.round(effW) })
|
||||
})
|
||||
return out
|
||||
}),
|
||||
contrastFails: await page.evaluate(() => {
|
||||
const out = []
|
||||
const w = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT)
|
||||
let n
|
||||
while ((n = w.nextNode())) {
|
||||
const t = n.textContent.trim(); if (!t) continue
|
||||
const el = n.parentElement; if (!el) continue
|
||||
const r = el.getBoundingClientRect(); if (!r.width || !r.height) continue
|
||||
const s = getComputedStyle(el); if (s.visibility === 'hidden' || s.display === 'none') continue
|
||||
let bgEl = el, bg = 'rgba(0, 0, 0, 0)'
|
||||
while (bgEl && (bg === 'rgba(0, 0, 0, 0)' || bg === 'transparent')) { bg = getComputedStyle(bgEl).backgroundColor; bgEl = bgEl.parentElement }
|
||||
out.push({ t: t.slice(0, 24), fg: s.color, bg, size: parseFloat(s.fontSize), weight: s.fontWeight })
|
||||
}
|
||||
return out
|
||||
}),
|
||||
}
|
||||
}
|
||||
await ctx.close()
|
||||
return { results, errs }
|
||||
}
|
||||
|
||||
;(async () => {
|
||||
const browser = await chromium.launch()
|
||||
|
||||
// 1. Overflow + clipped + tap targets across the full width range.
|
||||
const widths = [320, 390, 560, 760, 820, 900, 1024, 1100, 1440, 1920]
|
||||
let overflowBad = 0, clipBad = 0, targetBad = 0
|
||||
for (const w of widths) {
|
||||
const { results } = await auditWidth(browser, w, 900)
|
||||
for (const [tab, r] of Object.entries(results)) {
|
||||
if (r.overflow) { overflowBad++; log.push(`FAIL ${w}/${tab} horizontal overflow ${r.overflow.s}>${r.overflow.c}`) }
|
||||
if (r.clipped.length) { clipBad++; log.push(`FAIL ${w}/${tab} clipped: ${r.clipped.join(', ')}`) }
|
||||
if (r.smallTargets.length) { targetBad++; log.push(`FAIL ${w}/${tab} small targets: ${JSON.stringify(r.smallTargets)}`) }
|
||||
}
|
||||
}
|
||||
step(overflowBad === 0, `no horizontal overflow at any width (${widths.length} widths x 3 tabs)`)
|
||||
step(clipBad === 0, 'no control clipped off-screen at any width')
|
||||
step(targetBad === 0, 'all interactive targets >= 44px (labels counted for checkboxes)')
|
||||
|
||||
// 2. Contrast on desktop and mobile.
|
||||
let contrastBad = 0
|
||||
for (const [w, h] of [[1440, 900], [390, 844]]) {
|
||||
const { results } = await auditWidth(browser, w, h)
|
||||
const seen = new Set()
|
||||
for (const [tab, r] of Object.entries(results)) {
|
||||
for (const c of r.contrastFails) {
|
||||
const fg = rgba(c.fg), bg = rgba(c.bg)
|
||||
if (!fg || !bg || bg[3] < 1) continue
|
||||
const key = `${c.fg}|${c.bg}|${Math.round(c.size)}`
|
||||
if (seen.has(key)) continue
|
||||
seen.add(key)
|
||||
const large = c.size >= 18 || (c.size >= 14 && Number(c.weight) >= 700)
|
||||
const ratio = contrast(fg, bg)
|
||||
if (ratio < (large ? 3.0 : 4.5)) { contrastBad++; log.push(`FAIL ${w}/${tab} contrast "${c.t}" ${ratio.toFixed(2)}:1`) }
|
||||
}
|
||||
}
|
||||
}
|
||||
step(contrastBad === 0, 'all text meets WCAG AA contrast (desktop + mobile)')
|
||||
|
||||
// 3. Mobile navigation + drawer behaviour.
|
||||
const mctx = await browser.newContext({ viewport: { width: 390, height: 844 }, hasTouch: true, isMobile: true })
|
||||
const mp = await mctx.newPage()
|
||||
const merrs = []
|
||||
mp.on('pageerror', (e) => merrs.push(e.message))
|
||||
await mp.goto(BASE, { waitUntil: 'domcontentloaded' })
|
||||
await mp.waitForTimeout(800)
|
||||
await mp.locator('.app-menu-btn').click()
|
||||
await mp.waitForTimeout(350)
|
||||
step(await mp.locator('.app-sidebar').isVisible(), 'mobile: Menu opens the drawer')
|
||||
await mp.locator('.app-drawer-scrim').click({ position: { x: 380, y: 400 } })
|
||||
await mp.waitForTimeout(350)
|
||||
step(await mp.locator('.app-sidebar').evaluate((el) => el.getBoundingClientRect().right <= 0), 'mobile: scrim closes the drawer')
|
||||
await clickTab(mp, 'Accounts')
|
||||
await mp.waitForTimeout(500)
|
||||
step(await mp.locator('.accounts-head').isVisible(), 'mobile: bottom nav switches panels')
|
||||
const pad = await mp.evaluate(() => {
|
||||
const main = document.querySelector('.app-main')
|
||||
const nav = document.querySelector('.app-bottomnav').getBoundingClientRect()
|
||||
return { pad: parseFloat(getComputedStyle(main).paddingBottom), navH: nav.height }
|
||||
})
|
||||
step(pad.pad >= pad.navH, `mobile: content clears the bottom nav (${Math.round(pad.pad)} >= ${Math.round(pad.navH)})`)
|
||||
await mctx.close()
|
||||
|
||||
await browser.close()
|
||||
|
||||
console.log('=== UI VERIFICATION ===')
|
||||
log.forEach((l) => console.log(' ' + l))
|
||||
const fails = log.filter((l) => l.startsWith('FAIL')).length
|
||||
console.log(`\n${fails === 0 ? 'ALL CHECKS PASSED' : fails + ' FAILURE(S)'}`)
|
||||
process.exit(fails ? 1 : 0)
|
||||
})().catch((e) => { console.error('FATAL', e); process.exit(1) })
|
||||
@@ -0,0 +1,12 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
server: {
|
||||
port: 5173,
|
||||
proxy: {
|
||||
'/api': 'http://127.0.0.1:8093',
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user