Extended the same design-system treatment to the public site, faithful to AtomCMS's "atom" theme. New src/components/public/ui.tsx provides the signature atom building blocks + a scoped CSS layer: - ContentCard: surface card with a primary-tinted header (icon circle + title + subtitle) and padded body — the atom content-card, used as every page's header and section wrapper. - StatBlock / stat-grid, EmptyState, OnlineBadge (online/offline pill), RankBadge (medals for the top 3), and responsive .card-grid helpers. Swept ~45 public pages (home/community/rankings hand-built as the reference; the rest via parallel agents that read the schema and preserved every query, server action, auth gate and field name): heroes → ContentCard headers, lists → card-grids in ContentCards, "no X" → EmptyState, status → OnlineBadge/RankBadge. The leaderboard gained Credits/Diamonds/Duckets tabs (usersCurrency). Behaviour unchanged. Verified on the prod server against amx_test: 15+ public pages render the content-cards/grids with real data, no errors; computed styles confirm the tinted header, icon circle, medal + online pills. Fixed an undefined --color-golden ref. tsc 0, vitest 49/49, next build 0.
104 lines
2.9 KiB
TypeScript
104 lines
2.9 KiB
TypeScript
import type { ReactNode } from "react";
|
|
|
|
/**
|
|
* Public-site design system, faithful to AtomCMS's "atom" theme. The signature
|
|
* element is the content-card: a surface card with a primary-tinted header
|
|
* (icon circle + title + subtitle) and a padded body. These mirror the atom
|
|
* Blade components (content-card, stat blocks, empty states) so every public
|
|
* page shares one consistent, themeable look.
|
|
*/
|
|
|
|
export function ContentCard({
|
|
icon,
|
|
title,
|
|
subtitle,
|
|
action,
|
|
children,
|
|
className,
|
|
padded = true,
|
|
}: {
|
|
icon?: string;
|
|
title?: ReactNode;
|
|
subtitle?: ReactNode;
|
|
action?: ReactNode;
|
|
children?: ReactNode;
|
|
className?: string;
|
|
padded?: boolean;
|
|
}) {
|
|
const hasHead = title != null || icon != null || subtitle != null || action != null;
|
|
return (
|
|
<div className={`content-card${className ? ` ${className}` : ""}`}>
|
|
{hasHead ? (
|
|
<div className="content-card-head">
|
|
{icon ? (
|
|
<span className="content-card-icon" aria-hidden>
|
|
{icon}
|
|
</span>
|
|
) : null}
|
|
<div className="content-card-head-text">
|
|
{title != null ? <p className="content-card-title">{title}</p> : null}
|
|
{subtitle != null ? <p className="content-card-subtitle">{subtitle}</p> : null}
|
|
</div>
|
|
{action ? <div className="content-card-action">{action}</div> : null}
|
|
</div>
|
|
) : null}
|
|
<div className={padded ? "content-card-body" : undefined}>{children}</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/** A value + label tile (profile stats, rare-value summaries, …). */
|
|
export function StatBlock({
|
|
value,
|
|
label,
|
|
icon,
|
|
}: {
|
|
value: ReactNode;
|
|
label: string;
|
|
icon?: string;
|
|
}) {
|
|
return (
|
|
<div className="stat-block">
|
|
<div className="stat-block-value">
|
|
{icon ? <span aria-hidden>{icon} </span> : null}
|
|
{value}
|
|
</div>
|
|
<div className="stat-block-label">{label}</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/** Friendly empty state with an icon and a muted line. */
|
|
export function EmptyState({ icon = "📭", children }: { icon?: string; children: ReactNode }) {
|
|
return (
|
|
<div className="empty-state">
|
|
<div className="empty-state-icon" aria-hidden>
|
|
{icon}
|
|
</div>
|
|
<p className="muted" style={{ margin: 0 }}>
|
|
{children}
|
|
</p>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/** Online / offline pill with a status dot. */
|
|
export function OnlineBadge({ online }: { online: boolean }) {
|
|
return (
|
|
<span className={`online-badge${online ? " online" : ""}`}>
|
|
<span className="online-dot" aria-hidden />
|
|
{online ? "Online" : "Offline"}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
/** Leaderboard rank chip — medals for the top three, number otherwise. */
|
|
export function RankBadge({ position }: { position: number }) {
|
|
const medal = position === 1 ? "🥇" : position === 2 ? "🥈" : position === 3 ? "🥉" : null;
|
|
return (
|
|
<span className={`rank-badge rank-${position <= 3 ? position : "n"}`}>
|
|
{medal ?? `#${position}`}
|
|
</span>
|
|
);
|
|
}
|