1
0
Fork 0
polaris-task-force/src/components/frontend/dashboard/tactical.tsx
Z8MB1E 8fb97fdd1c feat(dashboard): demo tactical dossier styling on hero widgets
- New shared TacticalFrame/ReadoutFooter primitives (classification strip,
  corner brackets, faint grid texture, mono readout bar) following the
  campaign-card recipe; each piece separable per widget
- ProfileSummary: full frame + service-record readout footer (XP/level/rank/assignments)
- MissionBriefing: frame + codename line, inner MissionCard kept conventional
- QuickStats: hairline-separated situation-report readout bar
- Dense widgets (events, tickets, notifications, wallet, negotiations) stay
  shadcn so the tactical surfaces stand out
2026-10-12 13:26:21 -04:00

118 lines
4.3 KiB
TypeScript

import type { ReactNode } from "react";
import { cn } from "@/lib/utils";
/**
* Shared tactical "dossier" primitives for dashboard hero widgets, following
* the recipe in src/components/frontend/AGENTS.md (reference implementation:
* CampaignCard). Each piece is separable: frames can take just the strip, or
* brackets, or a readout footer. Dense widgets stay conventional shadcn so
* these surfaces stand out.
*/
/** Deterministic 3-digit reference code derived from a seed (id, username...). */
export function refCodeFrom(seed: string | number): string {
const value = String(seed);
let hash = 5381;
for (let i = 0; i < value.length; i += 1) {
hash = ((hash << 5) + hash + value.charCodeAt(i)) >>> 0;
}
return String(hash % 1000).padStart(3, "0");
}
interface TacticalFrameProps {
/** Left classification-strip label, e.g. "Personnel // Service Record". */
classification: string;
/** Right strip label, e.g. "REF 042". Omit to hide. */
refCode?: string;
children: ReactNode;
/** Optional permanent readout bar pinned to the bottom edge. */
footer?: ReactNode;
/** Corner brackets, default on. Turn off for bar-shaped surfaces. */
brackets?: boolean;
className?: string;
}
export function TacticalFrame({
classification,
refCode,
children,
footer,
brackets = true,
className,
}: TacticalFrameProps) {
return (
<div
className={cn(
"group relative flex min-w-0 flex-col overflow-hidden rounded-none border border-border/70 bg-card transition-colors duration-300 hover:border-foreground/30",
className,
)}
>
{/* Faint grid texture: constant opacity, never brightens on hover. */}
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 opacity-[0.04]"
style={{
backgroundImage:
"linear-gradient(to right, white 1px, transparent 1px), linear-gradient(to bottom, white 1px, transparent 1px)",
backgroundSize: "28px 28px",
}}
/>
<div
aria-hidden="true"
className="relative z-20 flex items-center justify-between gap-2 border-b border-white/15 bg-black/50 px-4 py-1.5 backdrop-blur-sm"
>
<span className="truncate font-mono text-[9px] uppercase tracking-widest text-white/60">
{classification}
</span>
{refCode ? (
<span className="shrink-0 font-mono text-[9px] uppercase tracking-widest text-white/60">
{refCode}
</span>
) : null}
</div>
{brackets ? (
<div aria-hidden="true" className="pointer-events-none absolute inset-2 z-30">
<span className="absolute left-0 top-0 size-3 border-l border-t border-white/25 transition-colors duration-300 group-hover:border-white/60" />
<span className="absolute right-0 top-0 size-3 border-r border-t border-white/25 transition-colors duration-300 group-hover:border-white/60" />
<span className="absolute bottom-0 left-0 size-3 border-b border-l border-white/25 transition-colors duration-300 group-hover:border-white/60" />
<span className="absolute bottom-0 right-0 size-3 border-b border-r border-white/25 transition-colors duration-300 group-hover:border-white/60" />
</div>
) : null}
<div className="relative z-10 flex min-w-0 flex-1 flex-col">{children}</div>
{footer ? <div className="relative z-20 mt-auto">{footer}</div> : null}
</div>
);
}
export interface ReadoutCell {
label: string;
value: string;
}
/** Permanent single-line readout bar (hairline-separated mono cells). */
export function ReadoutFooter({ cells }: { cells: ReadoutCell[] }) {
return (
<div className="flex items-stretch border-t border-white/15 bg-black/60 px-2 py-1.5 backdrop-blur-sm">
{cells.map((cell, index) => (
<div
key={cell.label}
className={cn(
"flex min-w-0 flex-1 items-center justify-center gap-1.5 px-1",
index < cells.length - 1 && "border-r border-white/15",
)}
>
<span className="truncate font-mono text-xs tabular-nums text-white/80">
{cell.value}
</span>
<span className="shrink-0 text-[9px] uppercase tracking-wider text-white/50">
{cell.label}
</span>
</div>
))}
</div>
);
}