Restyle the admin panel to match AtomCMS's Filament housekeeping look
The admin pages used bare inline-styled tables on the default page
background. Rebuilt the admin shell + added a scoped .admin CSS layer so
the whole panel matches the original AtomCMS Filament look:
- Dark #2d2d44 sidebar (the AtomCMS admin navbar colour) with the nav
grouped into Overview / Content / Users & access / Economy / Radio /
System (mirrors the Filament resource groups), an avatar + rank badge
header, and amber active-link highlighting via a client AdminNavLink
(usePathname).
- A topbar ("Housekeeping" + signed-in user) over a light content area.
- Carded tables (surface bg, rounded, shadow, tinted header, row hover)
and a page-title treatment, applied globally so every admin page is
styled without per-page edits.
Verified in a real authenticated admin session (production server,
amx_test): sidebar renders #2d2d44 sticky, active link amber on dark
text, /admin/users table carded with 7 real rows; dev server serves the
admin rules after a cache refresh. tsc 0, vitest 49/49, next build 0.
This commit is contained in:
1 parent
61a5fab0d9
commit
f4e0924e71
3 files changed
+307
-42
No files matched your search
+101
-42
@@ -1,12 +1,79 @@
|
|||||||
import Link from "next/link";
|
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
|
import { AdminNavLink } from "@/components/admin/admin-nav-link";
|
||||||
import { requireStaff } from "@/lib/admin/guard";
|
import { requireStaff } from "@/lib/admin/guard";
|
||||||
import { prisma } from "@/lib/prisma";
|
import { prisma } from "@/lib/prisma";
|
||||||
import { siteSettings } from "@/lib/services/site-settings";
|
import { siteSettings } from "@/lib/services/site-settings";
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
|
// Sidebar layout grouped like the original AtomCMS Filament panel (Content,
|
||||||
|
// Users & access, Economy, Radio, System) instead of one flat list.
|
||||||
|
const NAV_GROUPS: { label: string; items: { href: string; label: string }[] }[] = [
|
||||||
|
{
|
||||||
|
label: "Overview",
|
||||||
|
items: [{ href: "/admin", label: "Dashboard" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Content",
|
||||||
|
items: [
|
||||||
|
{ href: "/admin/articles", label: "Articles" },
|
||||||
|
{ href: "/admin/tags", label: "Tags" },
|
||||||
|
{ href: "/admin/navigation", label: "Navigator" },
|
||||||
|
{ href: "/admin/help-questions", label: "Help center" },
|
||||||
|
{ href: "/admin/ads", label: "Advertisements" },
|
||||||
|
{ href: "/admin/photos", label: "Photos" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Users & access",
|
||||||
|
items: [
|
||||||
|
{ href: "/admin/users", label: "Users" },
|
||||||
|
{ href: "/admin/bans", label: "Bans" },
|
||||||
|
{ href: "/admin/ip", label: "IP management" },
|
||||||
|
{ href: "/admin/applications", label: "Applications" },
|
||||||
|
{ href: "/admin/teams", label: "Teams" },
|
||||||
|
{ href: "/admin/permissions", label: "Permissions" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Economy",
|
||||||
|
items: [
|
||||||
|
{ href: "/admin/catalog", label: "Catalog" },
|
||||||
|
{ href: "/admin/shop", label: "Shop" },
|
||||||
|
{ href: "/admin/transactions", label: "Transactions" },
|
||||||
|
{ href: "/admin/vouchers", label: "Vouchers" },
|
||||||
|
{ href: "/admin/subscriptions", label: "Subscriptions" },
|
||||||
|
{ href: "/admin/rare-values", label: "Rare values" },
|
||||||
|
{ href: "/admin/badges", label: "Badges" },
|
||||||
|
{ href: "/admin/achievements", label: "Achievements" },
|
||||||
|
{ href: "/admin/calendar", label: "Calendar" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Radio",
|
||||||
|
items: [
|
||||||
|
{ href: "/admin/radio", label: "Radio" },
|
||||||
|
{ href: "/admin/radio/history", label: "Radio history" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "System",
|
||||||
|
items: [
|
||||||
|
{ href: "/admin/commandocentrum", label: "Commandocentrum" },
|
||||||
|
{ href: "/admin/emulator", label: "Emulator" },
|
||||||
|
{ href: "/admin/alerts", label: "Alerts" },
|
||||||
|
{ href: "/admin/logs", label: "Logs" },
|
||||||
|
{ href: "/admin/wordfilter", label: "Word filter" },
|
||||||
|
{ href: "/admin/maintenance", label: "Maintenance" },
|
||||||
|
{ href: "/admin/housekeeping", label: "Housekeeping" },
|
||||||
|
{ href: "/admin/rooms", label: "Rooms" },
|
||||||
|
{ href: "/admin/email-templates", label: "Email" },
|
||||||
|
{ href: "/admin/settings", label: "Settings" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export default async function AdminLayout({ children }: { children: ReactNode }) {
|
export default async function AdminLayout({ children }: { children: ReactNode }) {
|
||||||
const staff = await requireStaff();
|
const staff = await requireStaff();
|
||||||
|
|
||||||
@@ -18,50 +85,42 @@ export default async function AdminLayout({ children }: { children: ReactNode })
|
|||||||
if (!u?.twoFactorConfirmedAt) redirect("/settings/2fa?error=staffrequired");
|
if (!u?.twoFactorConfirmedAt) redirect("/settings/2fa?error=staffrequired");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const initial = staff.username.charAt(0).toUpperCase();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ display: "grid", gridTemplateColumns: "190px 1fr", gap: "1.5rem" }}>
|
<div className="admin">
|
||||||
<aside className="card" style={{ height: "fit-content" }}>
|
<aside className="admin-sidebar">
|
||||||
<p className="muted" style={{ marginTop: 0 }}>
|
<div className="admin-sidebar-head">
|
||||||
Staff · {staff.username} (rank {staff.rank})
|
<span className="admin-avatar" aria-hidden>
|
||||||
</p>
|
{initial}
|
||||||
<nav style={{ display: "grid", gap: "0.45rem" }}>
|
</span>
|
||||||
<Link href="/admin">Dashboard</Link>
|
<div style={{ minWidth: 0 }}>
|
||||||
<Link href="/admin/users">Users</Link>
|
<div className="admin-sidebar-name">{staff.username}</div>
|
||||||
<Link href="/admin/rooms">Rooms</Link>
|
<span className="admin-rank-badge">rank {staff.rank}</span>
|
||||||
<Link href="/admin/articles">Articles</Link>
|
</div>
|
||||||
<Link href="/admin/tags">Tags</Link>
|
</div>
|
||||||
<Link href="/admin/catalog">Catalog</Link>
|
|
||||||
<Link href="/admin/shop">Shop</Link>
|
<nav className="admin-nav">
|
||||||
<Link href="/admin/transactions">Transactions</Link>
|
{NAV_GROUPS.map((group) => (
|
||||||
<Link href="/admin/vouchers">Vouchers</Link>
|
<div key={group.label} className="admin-nav-group">
|
||||||
<Link href="/admin/badges">Badges</Link>
|
<span className="admin-nav-group-label">{group.label}</span>
|
||||||
<Link href="/admin/radio">Radio</Link>
|
{group.items.map((item) => (
|
||||||
<Link href="/admin/radio/history">Radio History</Link>
|
<AdminNavLink key={item.href} href={item.href} label={item.label} />
|
||||||
<Link href="/admin/achievements">Achievements</Link>
|
))}
|
||||||
<Link href="/admin/subscriptions">Subscriptions</Link>
|
</div>
|
||||||
<Link href="/admin/calendar">Calendar</Link>
|
))}
|
||||||
<Link href="/admin/rare-values">Rare Values</Link>
|
|
||||||
<Link href="/admin/photos">Photos</Link>
|
|
||||||
<Link href="/admin/bans">Bans</Link>
|
|
||||||
<Link href="/admin/applications">Applications</Link>
|
|
||||||
<Link href="/admin/help-questions">Help Center</Link>
|
|
||||||
<Link href="/admin/ads">Advertisements</Link>
|
|
||||||
<Link href="/admin/wordfilter">Word Filter</Link>
|
|
||||||
<Link href="/admin/ip">IP Management</Link>
|
|
||||||
<Link href="/admin/logs">Logs</Link>
|
|
||||||
<Link href="/admin/alerts">Alerts</Link>
|
|
||||||
<Link href="/admin/maintenance">Maintenance</Link>
|
|
||||||
<Link href="/admin/navigation">Navigator</Link>
|
|
||||||
<Link href="/admin/teams">Teams</Link>
|
|
||||||
<Link href="/admin/housekeeping">Housekeeping</Link>
|
|
||||||
<Link href="/admin/permissions">Permissions</Link>
|
|
||||||
<Link href="/admin/emulator">Emulator</Link>
|
|
||||||
<Link href="/admin/commandocentrum">Commandocentrum</Link>
|
|
||||||
<Link href="/admin/email-templates">Email</Link>
|
|
||||||
<Link href="/admin/settings">Settings</Link>
|
|
||||||
</nav>
|
</nav>
|
||||||
</aside>
|
</aside>
|
||||||
<section>{children}</section>
|
|
||||||
|
<div className="admin-content">
|
||||||
|
<header className="admin-topbar">
|
||||||
|
<h2>Housekeeping</h2>
|
||||||
|
<span className="muted" style={{ fontSize: "0.8rem" }}>
|
||||||
|
Signed in as <strong>{staff.username}</strong>
|
||||||
|
</span>
|
||||||
|
</header>
|
||||||
|
<section className="admin-page">{children}</section>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -379,3 +379,188 @@ td {
|
|||||||
.coin.diamonds {
|
.coin.diamonds {
|
||||||
background: #4bc0d9;
|
background: #4bc0d9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ── Admin panel (Housekeeping) ─────────────────────────────────
|
||||||
|
Faithful to AtomCMS's Filament panel: dark #2d2d44 sidebar with
|
||||||
|
grouped nav + amber active state, a topbar, and a light content
|
||||||
|
area with carded tables. Scoped under .admin so it never leaks
|
||||||
|
into the public site. */
|
||||||
|
.admin {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 232px minmax(0, 1fr);
|
||||||
|
gap: 1.25rem;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
@media (max-width: 860px) {
|
||||||
|
.admin {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-sidebar {
|
||||||
|
position: sticky;
|
||||||
|
top: 1rem;
|
||||||
|
align-self: start;
|
||||||
|
background: #2d2d44;
|
||||||
|
color: #e7e9f3;
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 0.85rem 0.7rem;
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
max-height: calc(100vh - 2rem);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
.admin-sidebar-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.6rem;
|
||||||
|
padding: 0.3rem 0.45rem 0.85rem;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.09);
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
.admin-avatar {
|
||||||
|
flex: none;
|
||||||
|
width: 38px;
|
||||||
|
height: 38px;
|
||||||
|
border-radius: 10px;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
font-weight: 800;
|
||||||
|
color: #1a1a2e;
|
||||||
|
background: var(--color-primary, #eeb425);
|
||||||
|
}
|
||||||
|
.admin-sidebar-name {
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 0.92rem;
|
||||||
|
line-height: 1.1;
|
||||||
|
color: #fff;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.admin-rank-badge {
|
||||||
|
display: inline-block;
|
||||||
|
margin-top: 0.2rem;
|
||||||
|
font-size: 0.66rem;
|
||||||
|
font-weight: 700;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
color: #1a1a2e;
|
||||||
|
background: var(--color-primary, #eeb425);
|
||||||
|
border-radius: 999px;
|
||||||
|
padding: 0.05rem 0.5rem;
|
||||||
|
}
|
||||||
|
.admin-nav {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.1rem;
|
||||||
|
}
|
||||||
|
.admin-nav-group {
|
||||||
|
margin-top: 0.55rem;
|
||||||
|
}
|
||||||
|
.admin-nav-group-label {
|
||||||
|
display: block;
|
||||||
|
font-size: 0.64rem;
|
||||||
|
font-weight: 700;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.09em;
|
||||||
|
color: rgba(231, 233, 243, 0.42);
|
||||||
|
padding: 0.3rem 0.55rem 0.25rem;
|
||||||
|
}
|
||||||
|
.admin-nav-link {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.55rem;
|
||||||
|
padding: 0.43rem 0.6rem;
|
||||||
|
border-radius: 9px;
|
||||||
|
color: #c8cbe0;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
font-weight: 600;
|
||||||
|
text-decoration: none;
|
||||||
|
transition: background 0.15s ease, color 0.15s ease;
|
||||||
|
}
|
||||||
|
.admin-nav-link:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.07);
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.admin-nav-link.active {
|
||||||
|
background: var(--color-primary, #eeb425);
|
||||||
|
color: #1a1a2e;
|
||||||
|
box-shadow: 0 2px 8px rgba(238, 180, 37, 0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-content {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
.admin-topbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 1rem;
|
||||||
|
background: var(--color-surface);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 0.7rem 1.15rem;
|
||||||
|
margin-bottom: 1.1rem;
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
}
|
||||||
|
.admin-topbar h2 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 1.05rem;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Page content inside the admin panel */
|
||||||
|
.admin-page main > h1:first-child,
|
||||||
|
.admin-page > h1:first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
.admin-page h1 {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
border-bottom: 2px solid var(--border);
|
||||||
|
margin-bottom: 0.85rem;
|
||||||
|
}
|
||||||
|
/* Carded tables — give the bare admin tables a surface + frame. */
|
||||||
|
.admin-page table {
|
||||||
|
background: var(--color-surface);
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.admin-page thead th {
|
||||||
|
background: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface));
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.admin-page th,
|
||||||
|
.admin-page td {
|
||||||
|
padding: 0.6rem 0.8rem;
|
||||||
|
}
|
||||||
|
.admin-page tbody tr {
|
||||||
|
transition: background 0.12s ease;
|
||||||
|
}
|
||||||
|
.admin-page tbody tr:hover {
|
||||||
|
background: color-mix(in srgb, var(--color-primary) 7%, transparent);
|
||||||
|
}
|
||||||
|
.admin-page tbody td {
|
||||||
|
border-top: 1px solid color-mix(in srgb, var(--color-text-muted) 12%, transparent);
|
||||||
|
}
|
||||||
|
/* status pill used by some admin lists */
|
||||||
|
.admin-badge {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 0.72rem;
|
||||||
|
font-weight: 700;
|
||||||
|
padding: 0.1rem 0.55rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: color-mix(in srgb, var(--color-primary) 18%, transparent);
|
||||||
|
color: var(--color-text);
|
||||||
|
}
|
||||||
|
.admin-badge.ok {
|
||||||
|
background: color-mix(in srgb, #16a34a 20%, transparent);
|
||||||
|
}
|
||||||
|
.admin-badge.danger {
|
||||||
|
background: color-mix(in srgb, #ef4444 22%, transparent);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import Link from "next/link";
|
||||||
|
import { usePathname } from "next/navigation";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sidebar link that highlights when its route is active. "/admin" matches
|
||||||
|
* exactly; every other entry also matches its sub-routes (e.g. /admin/radio is
|
||||||
|
* active on /admin/radio/history) so the current section stays lit.
|
||||||
|
*/
|
||||||
|
export function AdminNavLink({ href, label }: { href: string; label: string }) {
|
||||||
|
const pathname = usePathname() ?? "";
|
||||||
|
const active =
|
||||||
|
href === "/admin" ? pathname === "/admin" : pathname === href || pathname.startsWith(`${href}/`);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Link href={href} className={`admin-nav-link${active ? " active" : ""}`}>
|
||||||
|
{label}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user