CI (SIAX Cloud) / integration (push) Skipped
masterplan-lock / check (push) Successful in 7s
Security Scan (SIAX Cloud) / security (push) Successful in 20s
CI (SIAX Cloud) / security (push) Successful in 47s
masterplan-lock / check (pull_request) Successful in 10s
CI (SIAX Cloud) / quality (push) Successful in 1m11s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 32s
CI (SIAX Cloud) / security (pull_request) Successful in 42s
CI (SIAX Cloud) / integration (pull_request) Successful in 56s
CI (SIAX Cloud) / quality (pull_request) Successful in 59s
axe-core 4.10.2 mot 0pt.app 2026-09-26: en enda regel, color-contrast, impact=serious, 82 noder. Estatets största enskilda a11y-defekt. Alla 82 har samma form: en Tailwind-alfamodifierare på en textfärg. Uppmätt WCAG 2.2-kontrast mot bägge temabakgrunderna i styles/globals.css: text-muted-foreground 4.73:1 ljust 7.63:1 mörkt GODKÄNT text-muted-foreground/70 2.71:1 4.20:1 faller text-muted-foreground/60 2.29:1 3.37:1 faller text-muted-foreground/50 1.96:1 2.67:1 faller text-muted-foreground/40 1.69:1 2.11:1 faller text-foreground/20 1.57:1 1.74:1 faller Den omodifierade token klarar AA i bägge teman, så åtgärden är helt enkelt att aldrig tona den. Elva textställen bytte till text-muted-foreground. Kopieringsknappen i app/portal går från 1.57:1 till 4.73:1 i viloläge och 19.79:1 vid hover — den föll även 1.4.11 för icke-textkomponenter. Toastens stängknapp klarade redan 1.4.11 (3.71:1) men blir 4.73:1. Kvar med alfa är endast den dekorativa masthead-siffran i app/bestall, som redan bär aria-hidden + select-none + pointer-events-none. Den är undantagen både av WCAG och av axe, och guarden nedan tillåter den på just den grunden. scripts/ci/check-text-contrast.mjs är en blockerande källkodsgrind i quality-jobbet. Den är avsiktligt inte en axe-körning: den fullständiga axe-jobb som UI-09 också begär kräver build + serve i CI och spåras separat. Tills det finns stoppar den här grinden regressionen vid den form som orsakade defekten. Refs: UI-09 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
314 lines
14 KiB
TypeScript
314 lines
14 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useMemo, useState } from "react";
|
|
import { Header } from "@/components/header";
|
|
import { useT } from "@/components/locale-provider";
|
|
import { useReveal } from "@/hooks/use-reveal";
|
|
import { CellProvenance, PROVENANCE_LEGEND } from "@/components/provenance-badge";
|
|
import { LoadingSkeleton, EmptyState, ErrorState } from "@/components/states";
|
|
import type { ProvLevel } from "@/lib/data";
|
|
|
|
// Shape of GET /api/sources (docs/04). Legal sourcing only — the transparency moat.
|
|
interface Source {
|
|
source_id: string;
|
|
name: string;
|
|
market: string;
|
|
access: string; // api | bulk | authorized_web | licensed
|
|
licence: string;
|
|
cadence: string; // daily | weekly | quarterly | ...
|
|
confidence: number; // 0..1
|
|
}
|
|
|
|
// Human, terse labels for the access ladder (CLAUDE.md §1 priority order).
|
|
const ACCESS_LABEL: Record<string, { en: string; sv: string }> = {
|
|
api: { en: "Official API", sv: "Officiellt API" },
|
|
bulk: { en: "Bulk / open data", sv: "Bulk / öppen data" },
|
|
authorized_web: { en: "Authorized web", sv: "Auktoriserad webb" },
|
|
licensed: { en: "Licensed partner", sv: "Licensierad partner" },
|
|
};
|
|
|
|
// Confidence (0..1) → provenance level so each row carries an honest square.
|
|
function confidenceLevel(c: number): ProvLevel {
|
|
if (c >= 0.95) return 3;
|
|
if (c >= 0.9) return 2;
|
|
if (c > 0) return 1;
|
|
return 0;
|
|
}
|
|
|
|
// Sortable columns mapped to the request: Source · Market · Access · Licence · Freshness · Confidence.
|
|
type SortKey = "name" | "market" | "access" | "licence" | "cadence" | "confidence";
|
|
const COLUMNS: { key: SortKey; label: { en: string; sv: string }; mono?: boolean }[] = [
|
|
{ key: "name", label: { en: "Source", sv: "Källa" } },
|
|
{ key: "market", label: { en: "Market", sv: "Marknad" }, mono: true },
|
|
{ key: "access", label: { en: "Access", sv: "Åtkomst" }, mono: true },
|
|
{ key: "licence", label: { en: "Licence", sv: "Licens" } },
|
|
{ key: "cadence", label: { en: "Freshness", sv: "Färskhet" }, mono: true },
|
|
{ key: "confidence", label: { en: "Confidence", sv: "Konfidens" }, mono: true },
|
|
];
|
|
|
|
const ALL = "__all__";
|
|
const ALL_LABEL = { en: "All", sv: "Alla" };
|
|
|
|
export default function SourcesPage() {
|
|
const t = useT();
|
|
const [sources, setSources] = useState<Source[] | null>(null);
|
|
const [status, setStatus] = useState<"loading" | "ready" | "error">("loading");
|
|
const [reloadKey, setReloadKey] = useState(0);
|
|
|
|
const [market, setMarket] = useState<string>(ALL);
|
|
const [access, setAccess] = useState<string>(ALL);
|
|
const [sort, setSort] = useState<{ key: SortKey; dir: 1 | -1 }>({ key: "confidence", dir: -1 });
|
|
|
|
const ref = useReveal<HTMLElement>();
|
|
|
|
useEffect(() => {
|
|
let cancelled = false;
|
|
setStatus("loading");
|
|
fetch("/api/sources")
|
|
.then((r) => {
|
|
if (!r.ok) throw new Error(String(r.status));
|
|
return r.json();
|
|
})
|
|
.then((data: Source[]) => {
|
|
if (cancelled) return;
|
|
setSources(Array.isArray(data) ? data : []);
|
|
setStatus("ready");
|
|
})
|
|
.catch(() => {
|
|
if (cancelled) return;
|
|
setSources(null);
|
|
setStatus("error");
|
|
});
|
|
return () => {
|
|
cancelled = true;
|
|
};
|
|
}, [reloadKey]);
|
|
|
|
const markets = useMemo(() => {
|
|
if (!sources) return [ALL];
|
|
return [ALL, ...Array.from(new Set(sources.map((s) => s.market)))];
|
|
}, [sources]);
|
|
|
|
const accesses = useMemo(() => {
|
|
if (!sources) return [ALL];
|
|
return [ALL, ...Array.from(new Set(sources.map((s) => s.access)))];
|
|
}, [sources]);
|
|
|
|
const rows = useMemo(() => {
|
|
if (!sources) return [];
|
|
const filtered = sources.filter(
|
|
(s) => (market === ALL || s.market === market) && (access === ALL || s.access === access),
|
|
);
|
|
const { key, dir } = sort;
|
|
return [...filtered].sort((a, b) => {
|
|
const av = a[key];
|
|
const bv = b[key];
|
|
if (typeof av === "number" && typeof bv === "number") return (av - bv) * dir;
|
|
return String(av).localeCompare(String(bv), "sv") * dir;
|
|
});
|
|
}, [sources, market, access, sort]);
|
|
|
|
const setSortKey = (key: SortKey) =>
|
|
setSort((p) => (p.key === key ? { key, dir: (p.dir * -1) as 1 | -1 } : { key, dir: key === "confidence" ? -1 : 1 }));
|
|
|
|
const Pill = ({
|
|
active,
|
|
onClick,
|
|
children,
|
|
}: {
|
|
active: boolean;
|
|
onClick: () => void;
|
|
children: React.ReactNode;
|
|
}) => (
|
|
<button
|
|
type="button"
|
|
onClick={onClick}
|
|
aria-pressed={active}
|
|
className="border px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.08em] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
style={{
|
|
borderColor: active ? "var(--foreground)" : "var(--border)",
|
|
backgroundColor: active ? "var(--foreground)" : "transparent",
|
|
color: active ? "var(--background)" : "var(--foreground)",
|
|
}}
|
|
>
|
|
{children}
|
|
</button>
|
|
);
|
|
|
|
return (
|
|
<main id="main-content" className="min-h-screen bg-background text-foreground">
|
|
<Header />
|
|
|
|
{/* masthead — oversized faint numeral as graphic texture */}
|
|
<section ref={ref} className="relative overflow-hidden border-b border-border">
|
|
<span
|
|
aria-hidden
|
|
className="pointer-events-none absolute -right-3 -top-8 select-none font-mono text-[clamp(7rem,22vw,15rem)] font-medium leading-none tracking-[-0.05em] text-secondary"
|
|
>
|
|
05
|
|
</span>
|
|
<div className="relative mx-auto max-w-[80rem] px-6 py-16 md:py-24">
|
|
<div className="reveal flex items-center gap-3">
|
|
<span aria-hidden className="animate-float inline-block h-2 w-2" style={{ backgroundColor: "var(--accent-red)" }} />
|
|
<p className="font-mono text-[11px] uppercase tracking-[0.16em] text-muted-foreground">{t({ en: "Source map", sv: "Källkarta" })}</p>
|
|
</div>
|
|
<h1 className="reveal delay-1 mt-6 max-w-3xl text-[clamp(2.4rem,6vw,4.5rem)] font-medium leading-[0.95] tracking-[-0.035em]">
|
|
{t({ en: "Every field.", sv: "Varje fält." })}
|
|
<br />
|
|
{t({ en: "Every source.", sv: "Varje källa." })}
|
|
</h1>
|
|
<p className="reveal delay-2 mt-6 max-w-[42ch] font-mono text-[11px] uppercase tracking-[0.1em] text-muted-foreground">
|
|
{t({ en: "Official first. Then open data. Then licence. Never guessed.", sv: "Officiellt först. Sen öppen data. Sen licens. Aldrig gissat." })}
|
|
</p>
|
|
</div>
|
|
</section>
|
|
|
|
<section className="mx-auto max-w-[80rem] px-6 py-12">
|
|
{/* legend — the 4 provenance squares */}
|
|
<div className="reveal mb-8 flex flex-wrap items-center gap-x-6 gap-y-3 border-b border-border pb-6">
|
|
<span className="font-mono text-[10px] uppercase tracking-[0.18em] text-muted-foreground">{t({ en: "Provenance", sv: "Härkomst" })}</span>
|
|
{PROVENANCE_LEGEND.map((l) => (
|
|
<span key={l.level} className="inline-flex items-center gap-2 font-mono text-[10.5px] tracking-[0.02em] text-muted-foreground">
|
|
<span
|
|
aria-hidden
|
|
className="inline-block h-[9px] w-[9px]"
|
|
style={{
|
|
backgroundColor: l.level === 0 ? "transparent" : `var(--prov-${l.level})`,
|
|
border: l.level === 0 ? "1px solid var(--prov-0)" : "none",
|
|
}}
|
|
/>
|
|
{t(l.text)}
|
|
</span>
|
|
))}
|
|
</div>
|
|
|
|
{/* filters — pills by Market / Access */}
|
|
{status === "ready" && sources && sources.length > 0 ? (
|
|
<div className="reveal mb-8 flex flex-col gap-5">
|
|
<div>
|
|
<p className="mb-3 font-mono text-[10px] uppercase tracking-[0.18em] text-muted-foreground">{t({ en: "Market", sv: "Marknad" })}</p>
|
|
<div className="flex flex-wrap gap-2">
|
|
{markets.map((m) => (
|
|
<Pill key={m} active={market === m} onClick={() => setMarket(m)}>
|
|
{m === ALL ? t(ALL_LABEL) : m === "global" ? "Global" : m}
|
|
</Pill>
|
|
))}
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<p className="mb-3 font-mono text-[10px] uppercase tracking-[0.18em] text-muted-foreground">{t({ en: "Access type", sv: "Typ av åtkomst" })}</p>
|
|
<div className="flex flex-wrap gap-2">
|
|
{accesses.map((a) => (
|
|
<Pill key={a} active={access === a} onClick={() => setAccess(a)}>
|
|
{a === ALL ? t(ALL_LABEL) : ACCESS_LABEL[a] ? t(ACCESS_LABEL[a]) : a}
|
|
</Pill>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
) : null}
|
|
|
|
{/* states + table */}
|
|
{status === "loading" ? <LoadingSkeleton rows={9} /> : null}
|
|
|
|
{status === "error" ? (
|
|
<ErrorState title={t({ en: "Couldn't load the source map", sv: "Kunde inte läsa källkartan" })} onRetry={() => setReloadKey((k) => k + 1)} />
|
|
) : null}
|
|
|
|
{status === "ready" && (!sources || sources.length === 0) ? (
|
|
<EmptyState
|
|
title={t({ en: "No sources yet", sv: "Inga källor ännu" })}
|
|
line={t({ en: "The source map fills as the first market goes live. Nordics first.", sv: "Källkartan fylls när första marknaden går live. Norden först." })}
|
|
ctaHref="/bestall"
|
|
ctaLabel={t({ en: "Build a job", sv: "Bygg ett jobb" })}
|
|
/>
|
|
) : null}
|
|
|
|
{status === "ready" && sources && sources.length > 0 && rows.length === 0 ? (
|
|
<EmptyState
|
|
title={t({ en: "Nothing in that view", sv: "Inget i den vyn" })}
|
|
line={t({ en: "No sources match the chosen filter. Reset and try again.", sv: "Inga källor matchar valt filter. Nollställ och försök igen." })}
|
|
/>
|
|
) : null}
|
|
|
|
{status === "ready" && rows.length > 0 ? (
|
|
<div className="reveal-fade">
|
|
<div className="overflow-x-auto border border-border">
|
|
<table className="w-full border-collapse text-sm">
|
|
<thead>
|
|
<tr className="border-b border-border bg-secondary">
|
|
{COLUMNS.map((c) => {
|
|
const isSorted = sort.key === c.key;
|
|
return (
|
|
<th
|
|
key={c.key}
|
|
scope="col"
|
|
aria-sort={isSorted ? (sort.dir === 1 ? "ascending" : "descending") : "none"}
|
|
className={`px-3 py-2.5 text-left ${c.key === "confidence" ? "text-right" : ""}`}
|
|
>
|
|
<button
|
|
type="button"
|
|
onClick={() => setSortKey(c.key)}
|
|
className={`group inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.1em] transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background ${
|
|
isSorted ? "text-foreground" : "text-muted-foreground"
|
|
}`}
|
|
>
|
|
{t(c.label)}
|
|
<span aria-hidden className="text-[9px] tabular-nums">
|
|
{isSorted ? (sort.dir === 1 ? "↑" : "↓") : "·"}
|
|
</span>
|
|
</button>
|
|
</th>
|
|
);
|
|
})}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{rows.map((s) => {
|
|
const level = confidenceLevel(s.confidence);
|
|
return (
|
|
<tr
|
|
key={s.source_id}
|
|
className="border-b border-border transition-colors last:border-b-0 hover:bg-secondary/60"
|
|
>
|
|
<td className="px-3 py-3 align-top">
|
|
<span className="text-[15px] tracking-tight">{s.name}</span>
|
|
<span className="ml-2 font-mono text-[10px] uppercase tracking-[0.08em] text-muted-foreground">
|
|
{s.source_id}
|
|
</span>
|
|
</td>
|
|
<td className="px-3 py-3 align-top font-mono text-xs uppercase tracking-[0.06em]">
|
|
{s.market === "global" ? "Global" : s.market}
|
|
</td>
|
|
<td className="px-3 py-3 align-top font-mono text-[11px] uppercase tracking-[0.04em] text-muted-foreground">
|
|
{ACCESS_LABEL[s.access] ? t(ACCESS_LABEL[s.access]) : s.access}
|
|
</td>
|
|
<td className="px-3 py-3 align-top text-xs text-muted-foreground">{s.licence}</td>
|
|
<td className="px-3 py-3 align-top font-mono text-[11px] uppercase tracking-[0.04em]">
|
|
{s.cadence}
|
|
</td>
|
|
<td className="whitespace-nowrap px-3 py-3 text-right align-top font-mono text-xs tabular-nums">
|
|
{Math.round(s.confidence * 100)}%
|
|
<CellProvenance level={level} />
|
|
</td>
|
|
</tr>
|
|
);
|
|
})}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div className="mt-4 flex flex-wrap items-center justify-between gap-3">
|
|
<p className="font-mono text-[10.5px] uppercase tracking-[0.08em] text-muted-foreground">
|
|
{rows.length} {t({ en: "sources · every field carries its provenance", sv: "källor · varje fält bär sin härkomst" })}
|
|
</p>
|
|
<p className="font-mono text-[10px] uppercase tracking-[0.08em] text-muted-foreground">
|
|
{t({ en: "Licence terms verified before use", sv: "Licensvillkor verifieras innan användning" })}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
) : null}
|
|
</section>
|
|
</main>
|
|
);
|
|
}
|