Converts every last bare-Swedish const array across landing sections
(STATS, TILES, CHAIN, PIPELINE, MODELS, DATASETS, PRINCIPLES, COLUMNS)
and shared components (data-artifact, provenance-badge) to {en,sv} Loc
objects consumed via useT(). Verified by per-file verify agent: 10/10
clean, zero remaining bare-Swedish display text. tsc 0 + build green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
81 lines
2.5 KiB
TypeScript
81 lines
2.5 KiB
TypeScript
"use client";
|
|
|
|
import type { ProvLevel, Loc } from "@/lib/data";
|
|
import { useT } from "@/components/locale-provider";
|
|
|
|
const PROV_COLOR: Record<ProvLevel, string> = {
|
|
0: "var(--prov-0)", // not available / licence
|
|
1: "var(--prov-1)", // one source
|
|
2: "var(--prov-2)", // partially confirmed
|
|
3: "var(--prov-3)", // multiple sources agree
|
|
};
|
|
|
|
const PROV_LABEL: Record<ProvLevel, Loc> = {
|
|
0: { en: "Not available / licence", sv: "Ej tillgänglig / licens" },
|
|
1: { en: "One source", sv: "En källa" },
|
|
2: { en: "Partially confirmed", sv: "Delvis bekräftad" },
|
|
3: { en: "Multiple sources agree", sv: "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;
|
|
}) {
|
|
const t = useT();
|
|
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={t(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 }) {
|
|
const t = useT();
|
|
return (
|
|
<span
|
|
aria-hidden
|
|
title={t(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: Loc }[] = [
|
|
{ level: 3, text: { en: "Multiple sources agree", sv: "Flera källor överens" } },
|
|
{ level: 2, text: { en: "Partially confirmed", sv: "Delvis bekräftad" } },
|
|
{ level: 1, text: { en: "One source", sv: "En källa" } },
|
|
{ level: 0, text: { en: "Licence required / not available", sv: "Licens krävs / ej tillgänglig" } },
|
|
];
|