DataArtifact primitive (table/map/schema/chart/grid); Filosofi, Katalog (#katalog), Motorn (#motorn, dark), Visualiseringsgalleri, Täckning (#tackning), Editorial, Bevis, Priser (#priser), Footer — all on mono tokens + useReveal scroll-reveal, provenance signature, single red. Removed all template photography/scroll-image machinery. next build green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
95 lines
4.5 KiB
TypeScript
95 lines
4.5 KiB
TypeScript
"use client";
|
|
|
|
import { useReveal } from "@/hooks/use-reveal";
|
|
|
|
type Variant = "table" | "map" | "schema" | "chart" | "grid";
|
|
|
|
const PROV = ["var(--prov-0)", "var(--prov-1)", "var(--prov-2)", "var(--prov-3)"];
|
|
|
|
const TABLE_ROWS: [string, string, 0 | 1 | 2 | 3][] = [
|
|
["Volvo Group", "GLEIF", 3],
|
|
["Equinor ASA", "Brreg", 3],
|
|
["Maersk A/S", "CVR", 2],
|
|
["Nokia Oyj", "PRH", 2],
|
|
["E-post (FI)", "licens", 0],
|
|
];
|
|
const MAP_CELLS: [string, number][] = [
|
|
["SE", 98], ["NO", 96], ["DK", 94], ["FI", 89],
|
|
["IS", 0], ["NL", 0], ["DE", 0], ["FR", 0],
|
|
];
|
|
const CHART_BARS = [42, 61, 38, 74, 55, 88];
|
|
|
|
/**
|
|
* The generative, photo-free visual primitive. Every "image" surface uses it.
|
|
* Animates on scroll-into-view; settles to a complete static state under
|
|
* prefers-reduced-motion. Color discipline: mono + provenance squares + ONE red.
|
|
*/
|
|
export function DataArtifact({ variant, className = "" }: { variant: Variant; className?: string }) {
|
|
const ref = useReveal<HTMLDivElement>();
|
|
return (
|
|
<div ref={ref} className={`grain-overlay relative overflow-hidden border border-border bg-background ${className}`}>
|
|
{variant === "table" ? (
|
|
<div>
|
|
<div className="flex items-center justify-between border-b border-border px-3 py-2">
|
|
<span className="font-mono text-[10px] uppercase tracking-[0.12em] text-muted-foreground">dim_company</span>
|
|
<span className="font-mono text-[10px] uppercase tracking-[0.12em] text-muted-foreground">härkomst</span>
|
|
</div>
|
|
{TABLE_ROWS.map((r, i) => (
|
|
<div key={i} className={`reveal delay-${i + 1} flex items-center justify-between border-b border-border px-3 py-2.5 last:border-b-0`}>
|
|
<span className="truncate text-sm">{r[0]}</span>
|
|
<span className="ml-3 inline-flex items-center gap-1.5 font-mono text-[10px] uppercase text-muted-foreground">
|
|
<span className="inline-block h-[7px] w-[7px]" style={{ backgroundColor: r[2] === 0 ? "transparent" : PROV[r[2]], border: r[2] === 0 ? `1px solid ${PROV[0]}` : "none" }} />
|
|
{r[1]}
|
|
</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
) : null}
|
|
|
|
{variant === "map" ? (
|
|
<div className="grid grid-cols-4 gap-px bg-border">
|
|
{MAP_CELLS.map((c, i) => (
|
|
<div key={c[0]} className={`reveal-scale delay-${(i % 6) + 1} bg-background p-3`}>
|
|
<p className="font-mono text-sm font-semibold">{c[0]}</p>
|
|
<p className="font-mono text-[10px] text-muted-foreground">{c[1] ? `${c[1]}%` : "—"}</p>
|
|
<div className="mt-2 h-1 w-full bg-secondary">
|
|
<div className="h-full" style={{ width: `${c[1]}%`, backgroundColor: c[1] >= 95 ? "var(--prov-3)" : c[1] > 0 ? "var(--prov-2)" : "transparent" }} />
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
) : null}
|
|
|
|
{variant === "schema" ? (
|
|
<div className="grid grid-cols-3 gap-3 p-4" style={{ backgroundImage: "radial-gradient(var(--border) 1px, transparent 1px)", backgroundSize: "14px 14px" }}>
|
|
{[
|
|
{ n: "dim_company", key: true },
|
|
{ n: "fact_financials", key: false },
|
|
{ n: "bridge_provenance", key: true },
|
|
].map((e, i) => (
|
|
<div key={e.n} className={`reveal-scale delay-${i + 1} bg-background`} style={{ border: e.key ? "1px solid var(--accent-red)" : "1px solid var(--border)" }}>
|
|
<div className="border-b border-border px-2 py-1 font-mono text-[10px]">{e.n}</div>
|
|
<div className="px-2 py-1.5 font-mono text-[9px] text-muted-foreground">id · key · src</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
) : null}
|
|
|
|
{variant === "chart" ? (
|
|
<div className="flex h-40 items-end gap-2 p-4">
|
|
{CHART_BARS.map((h, i) => (
|
|
<div key={i} className={`reveal delay-${(i % 6) + 1} flex-1`} style={{ height: `${h}%`, backgroundColor: i === CHART_BARS.length - 1 ? "var(--accent-red)" : "var(--foreground)" }} />
|
|
))}
|
|
</div>
|
|
) : null}
|
|
|
|
{variant === "grid" ? (
|
|
<div className="relative flex h-40 items-center justify-center" style={{ backgroundImage: "radial-gradient(var(--border) 1px, transparent 1px)", backgroundSize: "16px 16px" }}>
|
|
<span className="select-none text-6xl font-semibold tracking-tighter text-border">0pt</span>
|
|
<span className="animate-float absolute right-6 top-6 inline-block h-3 w-3" style={{ backgroundColor: "var(--accent-red)" }} />
|
|
</div>
|
|
) : null}
|
|
</div>
|
|
);
|
|
}
|