living-documentation 7.13.0 → 7.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,12 +2,35 @@
2
2
  // Shown in the sticky document header (right-aligned, own row) when the
3
3
  // current document has at least one metadata entry.
4
4
 
5
+ const RED = "#dc2626"; // red-600
6
+ const YELLOW = "#eab308"; // yellow-500
7
+ const GREEN = "#16a34a"; // green-600
8
+
5
9
  function accuracyColor(ratio) {
6
10
  const pct = Math.max(0, Math.min(1, ratio)) * 100;
7
- if (pct > 80) return "#16a34a"; // green-600
8
- if (pct >= 60) return "#eab308"; // yellow-500
11
+ if (pct > 80) return GREEN;
12
+ if (pct >= 60) return YELLOW;
9
13
  if (pct >= 40) return "#f97316"; // orange-500
10
- return "#dc2626"; // red-600
14
+ return RED;
15
+ }
16
+
17
+ // Returns the CSS background for the gauge bar (always 100% wide).
18
+ // < 30% → solid red
19
+ // 30–60% → red → yellow gradient, red-dominant (yellow at 85%)
20
+ // 60–80% → red → yellow gradient, yellow-dominant (red at 15%)
21
+ // 80–100% → yellow → green gradient, green-dominant (yellow at 15%)
22
+ // 100% → solid green
23
+ function accuracyBackground(ratio) {
24
+ const pct = Math.max(0, Math.min(1, ratio)) * 100;
25
+ if (pct >= 100) return GREEN;
26
+ if (pct < 30) return RED;
27
+ if (pct < 60) {
28
+ return `linear-gradient(to right, ${RED} 0%, ${RED} 60%, ${YELLOW} 100%)`;
29
+ }
30
+ if (pct < 80) {
31
+ return `linear-gradient(to right, ${RED} 0%, ${YELLOW} 40%, ${YELLOW} 100%)`;
32
+ }
33
+ return `linear-gradient(to right, ${YELLOW} 0%, ${GREEN} 40%, ${GREEN} 100%)`;
11
34
  }
12
35
 
13
36
  function renderAccuracyGauge(report) {
@@ -28,11 +51,8 @@ function renderAccuracyGauge(report) {
28
51
 
29
52
  if (label) label.textContent = window.t("accuracy.label");
30
53
  if (bar) {
31
- bar.style.width = pct + "%";
32
- // The gradient spans the full track width, so we stretch the background
33
- // to (100/pct)× the bar width — this way the bar only shows the left
34
- // portion of the red→green gradient corresponding to its percentage.
35
- bar.style.backgroundSize = pct > 0 ? `${10000 / pct}% 100%` : "100% 100%";
54
+ bar.style.width = "100%";
55
+ bar.style.background = accuracyBackground(report.accuracy);
36
56
  }
37
57
  if (value) {
38
58
  value.textContent = pct + "%";
@@ -659,8 +659,8 @@
659
659
  >
660
660
  <div
661
661
  id="accuracy-gauge-bar"
662
- class="h-full transition-all"
663
- style="width: 0%; background: linear-gradient(to right, #dc2626, #f97316, #eab308, #16a34a); background-size: 100% 100%; background-repeat: no-repeat;"
662
+ class="h-full w-full transition-all"
663
+ style="background: #dc2626;"
664
664
  ></div>
665
665
  </div>
666
666
  <span
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "living-documentation",
3
- "version": "7.13.0",
3
+ "version": "7.14.0",
4
4
  "description": "A CLI tool that serves a local Markdown documentation viewer",
5
5
  "main": "dist/src/server.js",
6
6
  "bin": {