diff --git a/CHANGELOG.md b/CHANGELOG.md
index 15a293f..719c6af 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,11 @@ The application version is maintained in `package.json` and displayed in the adm
No changes recorded yet.
+## 1.73.0
+
+### Added
+- Gold, silver and bronze medals for places 1-3 instead of plain numbers: in the PDF export, the printouts and the result tables in the app (race overview with a podium of medals on ribbons, standings, series standings, results archive).
+
## 1.72.0
### Changed
diff --git a/package-lock.json b/package-lock.json
index 141676a..5f925ff 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "rc-racecore",
- "version": "1.72.0",
+ "version": "1.73.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "rc-racecore",
- "version": "1.72.0",
+ "version": "1.73.0",
"hasInstallScript": true,
"dependencies": {
"better-sqlite3": "^12.11.1",
diff --git a/package.json b/package.json
index 534e0ae..93d4cab 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "rc-racecore",
- "version": "1.72.0",
+ "version": "1.73.0",
"private": true,
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
"engines": {
diff --git a/server/pdf_render.js b/server/pdf_render.js
index 8771064..57fae24 100644
--- a/server/pdf_render.js
+++ b/server/pdf_render.js
@@ -8,6 +8,12 @@ const THEMES = {
minimal: { band: null, accent: "#3c4454", headFill: "#e9ecf1", headText: "#1d2330", zebra: "#f7f8fa" },
};
const PODIUM = { 1: "#d4af37", 2: "#a9b0bb", 3: "#c27c3e" };
+// Medal colours: rim, face, highlight, number.
+const MEDALS = {
+ 1: ["#9c7210", "#f0c53f", "#fff2b0", "#4a3500"],
+ 2: ["#7d8691", "#cfd5dc", "#ffffff", "#33383f"],
+ 3: ["#84491a", "#d38a4c", "#ffd7b0", "#3d2109"],
+};
const TEXT = "#1d2330";
const MUTED = "#6b7486";
const RULE = "#d8dde6";
@@ -150,6 +156,19 @@ function createWriter(pageWidth, pageHeight, title) {
if (align === "center") left = x + (width - textWidth(value, size, bold)) / 2;
writer.page.push(`BT ${rgb(color)} rg /${bold ? "F2" : "F1"} ${size} Tf ${n(left)} ${n(y)} Td (${escapePdfText(value)}) Tj ET`);
},
+ circle(cx, cy, r, color) {
+ const k = r * 0.5523;
+ writer.page.push(`${rgb(color)} rg ${n(cx + r)} ${n(cy)} m ${n(cx + r)} ${n(cy + k)} ${n(cx + k)} ${n(cy + r)} ${n(cx)} ${n(cy + r)} c ${n(cx - k)} ${n(cy + r)} ${n(cx - r)} ${n(cy + k)} ${n(cx - r)} ${n(cy)} c ${n(cx - r)} ${n(cy - k)} ${n(cx - k)} ${n(cy - r)} ${n(cx)} ${n(cy - r)} c ${n(cx + k)} ${n(cy - r)} ${n(cx + r)} ${n(cy - k)} ${n(cx + r)} ${n(cy)} c f`);
+ },
+ // A gold/silver/bronze medal: rim, face, a soft highlight and the place in bold.
+ medal(cx, cy, place) {
+ const [rim, face, light, ink] = MEDALS[place];
+ writer.circle(cx, cy, 7, rim);
+ writer.circle(cx, cy, 5.8, face);
+ writer.circle(cx - 1.6, cy + 1.8, 2.4, light);
+ writer.circle(cx - 0.3, cy + 0.3, 4.1, face);
+ writer.text(cx - 6, cy - 2.6, String(place), 7.5, { bold: true, color: ink, align: "center", width: 12 });
+ },
image(x, y, w, h) {
writer.page.push(`q ${n(w)} 0 0 ${n(h)} ${n(x)} ${n(y)} cm /Im1 Do Q`);
},
@@ -233,6 +252,11 @@ function drawTable(writer, section, theme) {
let x = MARGIN;
section.headers.forEach((_h, index) => {
const bold = Boolean(podium) && index <= 1;
+ if (podium && index === 0) {
+ writer.medal(x + widths[0] / 2, top - rowHeight / 2, Number(String(row[0]).trim()));
+ x += widths[0];
+ return;
+ }
writer.text(x + PAD, top - 11.5, fitText(row[index], CELL_SIZE, bold, widths[index] - PAD * 2), CELL_SIZE, { bold, align: align(index), width: widths[index] - PAD * 2 });
x += widths[index];
});
diff --git a/src/app.js b/src/app.js
index 851b382..7922428 100644
--- a/src/app.js
+++ b/src/app.js
@@ -1,3 +1,4 @@
+import { medal } from "./medal.js";
import { getSyncStatus } from "./sync_status.js";
import { installListSorting } from "./list_sorting.js";
import { escapeHtml } from "./html_escape.js";
@@ -158,7 +159,7 @@ const renderRaceOverviewHeatsHtml = (event) => (getRaceOverview(event)?.phases |
${escapeHtml(raceOverviewPhaseLabel(phase.type))} • ${escapeHtml(session.name)}
${renderTable([t("table.pos"), t("table.driver"), ...(rows.some((row) => row.car) ? [t("race_overview.car")] : []), t("table.laps"), t("table.result"), t("table.best_lap")],
- rows.map((row) => ` `))}
+ rows.map((row) => `${row.pos} ${escapeHtml(row.name)} ${rows.some((item) => item.car) ? `${escapeHtml(row.car || "-")} ` : ""}${row.laps} ${escapeHtml(row.result)} ${row.bestLapMs ? escapeHtml(formatLap(row.bestLapMs)) : "-"} `))}
${medal(row.pos)} ${escapeHtml(row.name)} ${rows.some((item) => item.car) ? `${escapeHtml(row.car || "-")} ` : ""}${row.laps} ${escapeHtml(row.result)} ${row.bestLapMs ? escapeHtml(formatLap(row.bestLapMs)) : "-"}
| ${escapeHtml(t("table.pos"))} | ${escapeHtml(t("table.driver"))} | ${table.events.map((event, index) => `${index + 1} | `).join("")}${escapeHtml(t("series.starts"))} | ${escapeHtml(t("series.total"))} |
|---|---|---|---|---|
| ${row.rank} | ${escapeHtml(row.driverName)} | ${table.events.map((event) => `${escapeHtml(seriesCell(table, row, event))} | `).join("")}${row.starts} | ${row.total} |
${table.events.map((event, index) => `${index + 1}: ${escapeHtml(event.date || "")} ${escapeHtml(event.name)}`).join(" · ")}
${escapeHtml(t("series.legend"))}
`); const exportSeriesPdf = async (series, tables) => { @@ -7493,6 +7494,9 @@ function openPrintWindow(title, bodyHtml) { td.pos, th.pos { text-align: center; width: 1%; white-space: nowrap; } tr.podium-1 td:first-child { box-shadow: inset 4px 0 #d4af37; } tr.podium-2 td:first-child { box-shadow: inset 4px 0 #a9b0bb; } tr.podium-3 td:first-child { box-shadow: inset 4px 0 #c27c3e; } tr.podium-1 td, tr.podium-2 td, tr.podium-3 td { font-weight: 700; } + .medal { display: inline-block; width: 20px; height: 20px; line-height: 20px; border-radius: 50%; text-align: center; font-weight: 800; font-size: 11px; color: #4a3500; background: radial-gradient(circle at 32% 28%, #fff7cf 0%, #f4cf55 38%, #c9971c 75%, #9c7210 100%); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.4); } + .medal-2 { color: #33383f; background: radial-gradient(circle at 32% 28%, #ffffff 0%, #dfe3e8 38%, #a8b0ba 75%, #7d8691 100%); } + .medal-3 { color: #3d2109; background: radial-gradient(circle at 32% 28%, #ffe2c4 0%, #e3a46a 38%, #b06a2c 75%, #84491a 100%); } diff --git a/src/medal.js b/src/medal.js new file mode 100644 index 0000000..1c4b8d0 --- /dev/null +++ b/src/medal.js @@ -0,0 +1,6 @@ +// Gold / silver / bronze medal for places 1-3 in result tables; other places stay a plain number. +// The medal still holds the number, so text, CSV and the print table decoration keep working. +export function medal(pos) { + const value = String(pos ?? "").trim(); + return ["1", "2", "3"].includes(value) ? `${value}` : value; +} diff --git a/src/race_overview_view.js b/src/race_overview_view.js index 6dd61ae..01e80b3 100644 --- a/src/race_overview_view.js +++ b/src/race_overview_view.js @@ -1,3 +1,4 @@ +import { medal } from "./medal.js"; // Race Day → Race overview panel: podium, then practice / qualifying / finals with standings // and every heat. Logic in race_overview_logic.js; print, PDF and CSV come in as deps. const openPhases = new Set(); @@ -7,7 +8,7 @@ export function renderRaceOverviewPanel(overview, { t, escapeHtml, formatLap, re const { event, phases, podium } = overview; const heatTable = (rows) => renderTable( [t("table.pos"), t("table.driver"), ...(rows.some((row) => row.car) ? [t("race_overview.car")] : []), t("table.laps"), t("table.result"), t("table.best_lap")], - rows.map((row) => `| ${t("table.pos")} | ${t("table.driver")} | ${head}${t("series.starts")} | ${t("series.total")} |
|---|---|---|---|
| ${row.rank} | ${escapeHtml(row.driverName)} | ${cells(row)}${row.starts} | ${row.total} |
| ${medal(row.rank)} | ${escapeHtml(row.driverName)} | ${cells(row)}${row.starts} | ${row.total} |
${t("series.no_results")}
`} `; } diff --git a/src/styles.css b/src/styles.css index 1585379..9d643fe 100644 --- a/src/styles.css +++ b/src/styles.css @@ -4847,8 +4847,6 @@ details.event-group > summary { cursor: pointer; list-style: revert; } /* Race overview (Race Day, results archive) */ .race-overview-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; list-style: none; margin: 0 0 12px; padding: 0; } .race-overview-podium li { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-card); text-align: center; } -.race-overview-podium li span { font-size: 1.4rem; font-weight: 800; color: var(--muted); } -.race-overview-podium .podium-1 span { color: #d4a514; } .race-overview-phase { border-top: 1px solid var(--line); padding: 8px 0; } .race-overview-phase summary { cursor: pointer; padding: 4px 0; } .race-overview-phase h4 { margin: 12px 0 6px; } @@ -4883,3 +4881,12 @@ details.event-group > summary { cursor: pointer; list-style: revert; } /* Sponsor event heats: the car each driver has in this heat, next to the name. */ .overlay-heat-car, .live-heat-car { color: var(--accent-2, #0ea5e9); font-weight: 600; white-space: nowrap; } .live-heat-car { font-size: 0.85em; margin-left: 6px; } + +/* Gold / silver / bronze medals for places 1-3 in result tables (src/medal.js). */ +.medal { position: relative; display: inline-grid; place-items: center; width: 1.75em; height: 1.75em; border-radius: 50%; font-weight: 800; font-size: 0.85em; line-height: 1; color: #4a3500; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); background: radial-gradient(circle at 32% 28%, #fff7cf 0%, #f4cf55 38%, #c9971c 75%, #9c7210 100%); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35), 0 1px 3px rgba(0, 0, 0, 0.35); vertical-align: middle; } +.medal-2 { color: #33383f; background: radial-gradient(circle at 32% 28%, #ffffff 0%, #dfe3e8 38%, #a8b0ba 75%, #7d8691 100%); } +.medal-3 { color: #3d2109; background: radial-gradient(circle at 32% 28%, #ffe2c4 0%, #e3a46a 38%, #b06a2c 75%, #84491a 100%); } +.race-overview-podium .medal { width: 2.6em; height: 2.6em; font-size: 1.1rem; justify-self: center; margin-top: 10px; } +.race-overview-podium .medal::before { content: ""; position: absolute; top: -12px; left: 50%; width: 18px; height: 14px; transform: translateX(-50%); background: linear-gradient(90deg, #2f6fde 0 38%, #f4cf55 38% 62%, #2f6fde 62%); clip-path: polygon(0 0, 100% 0, 75% 100%, 25% 100%); z-index: -1; } +.race-overview-podium .podium-1 { border-color: #e2bd45; } +.race-overview-podium li { position: relative; z-index: 0; } diff --git a/tests/pdf_render.test.js b/tests/pdf_render.test.js index 33903fb..96c7800 100644 --- a/tests/pdf_render.test.js +++ b/tests/pdf_render.test.js @@ -20,3 +20,13 @@ test("a long name is shortened with … instead of running into the next column" const pdf = buildStyledPdf({ ...base, sections: [{ title: "", headers: ["Pos", "Förare", ...Array.from({ length: 14 }, (_, i) => `R${i + 1}`)], rows: [["1", "A".repeat(120), ...Array.from({ length: 14 }, () => "(100)")]] }] }); assert.ok(pdf.includes(Buffer.from([0x85])), "ellipsis as a WinAnsi byte"); }); + +test("places 1-3 get gold, silver and bronze medals - in the app tables and drawn in the PDF", async () => { + const { medal } = await import("../src/medal.js"); + assert.equal(medal(1), '1'); + assert.equal(medal("3"), '3'); + assert.equal(medal(4), "4"); + const pdf = buildStyledPdf({ ...base, sections: [{ title: "", headers: ["Pos", "Förare"], rows: [["1", "A"], ["2", "B"], ["3", "C"], ["4", "D"]] }] }).toString("latin1"); + assert.ok(pdf.includes("0.941 0.773 0.247 rg") && pdf.includes("0.812 0.835 0.863 rg") && pdf.includes("0.827 0.541 0.298 rg"), "gold, silver and bronze medal faces"); + assert.ok(pdf.includes("(4) Tj"), "place 4 stays a plain number"); +});