Files
0pt/components/provenance-badge.tsx
T
adminandClaude Opus 4.8 24035dec8b Build 0pt ordering flow: configurator, deposit/escrow, production tracker, validation
Customer order lifecycle on the mono design system: red + provenance tokens, useReveal hook, lib/data pricing model, ProvenanceBadge/CellProvenance, OrderStepper, and 4 routes with live pricing, 50/50 escrow, simulated production, 4-view validation. tsc clean; next build green (5 routes).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-24 17:28:24 +02:00

76 lines
2.1 KiB
TypeScript

import type { ProvLevel } from "@/lib/data";
const PROV_COLOR: Record<ProvLevel, string> = {
0: "var(--prov-0)", // ej tillgänglig / licens
1: "var(--prov-1)", // en källa
2: "var(--prov-2)", // delvis bekräftad
3: "var(--prov-3)", // flera källor överens
};
const PROV_LABEL: Record<ProvLevel, string> = {
0: "Ej tillgänglig / licens",
1: "En källa",
2: "Delvis bekräftad",
3: "Flera källor överens",
};
/**
* The product's whole promise in one chip: where a value came from and how
* confident we are. The ONLY place non-mono color (besides the single red CTA)
* is allowed to appear.
*/
export function ProvenanceBadge({
level,
source,
freshness,
}: {
level: ProvLevel;
source: string;
freshness?: string;
}) {
return (
<span
className="inline-flex items-center gap-1.5 border border-border px-1.5 py-0.5 font-mono text-[10.5px] tracking-[0.02em] text-muted-foreground"
title={PROV_LABEL[level]}
>
<span
aria-hidden
className="inline-block h-[7px] w-[7px]"
style={{
backgroundColor: level === 0 ? "transparent" : PROV_COLOR[level],
border: level === 0 ? `1px solid ${PROV_COLOR[0]}` : "none",
}}
/>
<span className="uppercase">{source}</span>
{freshness ? (
<>
<span className="text-border">·</span>
<span>{freshness}</span>
</>
) : null}
</span>
);
}
/** Just the 9px status square — for the end of table cells. */
export function CellProvenance({ level }: { level: ProvLevel }) {
return (
<span
aria-hidden
title={PROV_LABEL[level]}
className="ml-1.5 inline-block h-[9px] w-[9px] align-middle"
style={{
backgroundColor: level === 0 ? "transparent" : PROV_COLOR[level],
border: level === 0 ? `1px solid ${PROV_COLOR[0]}` : "none",
}}
/>
);
}
export const PROVENANCE_LEGEND: { level: ProvLevel; text: string }[] = [
{ level: 3, text: "Flera källor överens" },
{ level: 2, text: "Delvis bekräftad" },
{ level: 1, text: "En källa" },
{ level: 0, text: "Licens krävs / ej tillgänglig" },
];