diff --git a/docs/delivered-pr-types.js b/docs/delivered-pr-types.js index dedea7a..cea842c 100644 --- a/docs/delivered-pr-types.js +++ b/docs/delivered-pr-types.js @@ -2,13 +2,33 @@ "use strict"; const PR_TYPE_KEYS = ["feat", "fix", "docs", "ci", "chore", "test", "perf", "other"]; - // Concrete hex — CSS vars are unreliable as SVG fill in some browsers - const TYPE_COLORS = { - feat: "#6b93f7", fix: "#ff453a", docs: "#9775fa", ci: "#f5c842", - chore: "#8e8e93", test: "#4fbc6b", perf: "#f4845f", other: "#5c5c5e", - }; + // Resolve theme tokens to concrete colors for SVG (CSS vars as fill attrs are unreliable). + function themeColor(name, fallback) { + const v = getComputedStyle(document.documentElement).getPropertyValue(name).trim(); + return v || fallback; + } + // Re-resolved on each render / color-scheme change so charts track live CSS tokens. + function resolveTypeColors() { + return { + feat: themeColor("--chart-1", "#5cb3ff"), + fix: themeColor("--negative", "#f87171"), + docs: themeColor("--type-docs", "#9775fa"), + ci: themeColor("--chart-2", "#f5c842"), + chore: themeColor("--type-chore", "#8e8e93"), + test: themeColor("--positive", "#4ade80"), + perf: themeColor("--chart-3", "#ff8f5c"), + other: themeColor("--type-other", "#5c5c5e"), + }; + } const FIX_KEYS = ["core", "external", "bot"]; - const FIX_COLORS = { core: "#6b93f7", external: "#4fbc6b", bot: "#f4845f" }; + // Must match .fix-bucket.{core,external,bot} in style.css (chart-1 / chart-5 / accent). + function resolveFixColors() { + return { + core: themeColor("--chart-1", "#5cb3ff"), + external: themeColor("--chart-5", "#2dd4bf"), + bot: themeColor("--accent", "#c4ff0e"), + }; + } const FIX_LABELS = { core: "Core team filed", external: "External human filed", @@ -207,7 +227,7 @@ }); } - function renderHero(t) { + function renderHero(t, typeColors) { const topType = PR_TYPE_KEYS.slice().sort((a, b) => t[b] - t[a])[0]; const topPct = t.merged ? (100 * t[topType] / t.merged).toFixed(1) : "0.0"; const typeBits = PR_TYPE_KEYS @@ -216,10 +236,12 @@ .slice(0, 4) .map(k => `${k} ${(100 * t[k] / (t.merged || 1)).toFixed(0)}%`) .join(" · "); + const fixColor = typeColors.fix; + const topColor = typeColors[topType] || typeColors.feat; document.getElementById("hero").innerHTML = `