feat(results): gold, silver and bronze medals for the top three in PDF, printouts and result tables (1.73.0)
This commit is contained in:
1 parent
7c25f23ad0
commit
41043a990d
12 files changed
+72
-12
No files matched your search
@@ -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
|
||||
|
||||
Generated
+2
-2
@@ -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",
|
||||
|
||||
+1
-1
@@ -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": {
|
||||
|
||||
@@ -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];
|
||||
});
|
||||
|
||||
+6
-2
@@ -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 |
|
||||
<section class="print-block">
|
||||
<h2>${escapeHtml(raceOverviewPhaseLabel(phase.type))} • ${escapeHtml(session.name)}</h2>
|
||||
${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) => `<tr><td>${row.pos}</td><td>${escapeHtml(row.name)}</td>${rows.some((item) => item.car) ? `<td>${escapeHtml(row.car || "-")}</td>` : ""}<td>${row.laps}</td><td>${escapeHtml(row.result)}</td><td>${row.bestLapMs ? escapeHtml(formatLap(row.bestLapMs)) : "-"}</td></tr>`))}
|
||||
rows.map((row) => `<tr><td>${medal(row.pos)}</td><td>${escapeHtml(row.name)}</td>${rows.some((item) => item.car) ? `<td>${escapeHtml(row.car || "-")}</td>` : ""}<td>${row.laps}</td><td>${escapeHtml(row.result)}</td><td>${row.bestLapMs ? escapeHtml(formatLap(row.bestLapMs)) : "-"}</td></tr>`))}
|
||||
</section>`)).join("");
|
||||
const getSessionsForEvent = (eventId) => getSessionsForEventHelper(state, eventId);
|
||||
const getModeLabel = (mode) => getModeLabelHelper(mode, { t });
|
||||
@@ -1021,7 +1022,7 @@ const printSeries = (series, tables) => openPrintWindow(series.name, `
|
||||
<div class="print-meta"><p>${escapeHtml(new Date().toLocaleDateString())}</p></div></div>
|
||||
${tables.map((table) => `<div class="print-block"><h2>${escapeHtml(table.className)} - ${escapeHtml(t("series.counted_of", { counted: table.countedCount, completed: table.completedCount, total: table.events.length }))}</h2>
|
||||
<table><thead><tr><th>${escapeHtml(t("table.pos"))}</th><th>${escapeHtml(t("table.driver"))}</th>${table.events.map((event, index) => `<th>${index + 1}</th>`).join("")}<th>${escapeHtml(t("series.starts"))}</th><th>${escapeHtml(t("series.total"))}</th></tr></thead>
|
||||
<tbody>${table.rows.map((row) => `<tr><td>${row.rank}</td><td>${escapeHtml(row.driverName)}</td>${table.events.map((event) => `<td>${escapeHtml(seriesCell(table, row, event))}</td>`).join("")}<td>${row.starts}</td><td><strong>${row.total}</strong></td></tr>`).join("")}</tbody></table>
|
||||
<tbody>${table.rows.map((row) => `<tr><td>${medal(row.rank)}</td><td>${escapeHtml(row.driverName)}</td>${table.events.map((event) => `<td>${escapeHtml(seriesCell(table, row, event))}</td>`).join("")}<td>${row.starts}</td><td><strong>${row.total}</strong></td></tr>`).join("")}</tbody></table>
|
||||
<p>${table.events.map((event, index) => `${index + 1}: ${escapeHtml(event.date || "")} ${escapeHtml(event.name)}`).join(" · ")}</p></div>`).join("")}
|
||||
<p>${escapeHtml(t("series.legend"))}</p>`);
|
||||
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%); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -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) ? `<span class="medal medal-${value}">${value}</span>` : value;
|
||||
}
|
||||
@@ -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) => `<tr><td>${row.pos}</td><td>${escapeHtml(row.name)}</td>${rows.some((item) => item.car) ? `<td>${escapeHtml(row.car || "-")}</td>` : ""}<td>${row.laps}</td><td>${escapeHtml(row.result)}</td><td>${row.bestLapMs ? escapeHtml(formatLap(row.bestLapMs)) : "-"}</td></tr>`)
|
||||
rows.map((row) => `<tr><td>${medal(row.pos)}</td><td>${escapeHtml(row.name)}</td>${rows.some((item) => item.car) ? `<td>${escapeHtml(row.car || "-")}</td>` : ""}<td>${row.laps}</td><td>${escapeHtml(row.result)}</td><td>${row.bestLapMs ? escapeHtml(formatLap(row.bestLapMs)) : "-"}</td></tr>`)
|
||||
);
|
||||
return `
|
||||
<section class="panel mt-16 race-overview" id="raceDayOverview">
|
||||
@@ -20,7 +21,7 @@ export function renderRaceOverviewPanel(overview, { t, escapeHtml, formatLap, re
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
${podium.length ? `<ol class="race-overview-podium">${podium.map((row, index) => `<li class="podium-${index + 1}"><span>${index + 1}</span><strong>${escapeHtml(row.driverName || "-")}</strong></li>`).join("")}</ol>` : ""}
|
||||
${podium.length ? `<ol class="race-overview-podium">${podium.map((row, index) => `<li class="podium-${index + 1}">${medal(index + 1)}<strong>${escapeHtml(row.driverName || "-")}</strong></li>`).join("")}</ol>` : ""}
|
||||
${phases.map((phase) => `
|
||||
<details class="race-overview-phase" data-phase="${phase.type}" ${openPhases.has(phase.type) ? "open" : ""}>
|
||||
<summary><strong>${escapeHtml(phaseLabel(phase.type))}</strong> <small>${t("race_overview.heats_done", { done: phase.heats.filter(({ session }) => session.status === "finished").length, total: phase.planned })}</small></summary>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { medal } from "./medal.js";
|
||||
export function renderRaceFormatField(labelKey, hintKey, controlHtml, options = {}, { t }) {
|
||||
const extraClass = options.checkbox ? " field-card-checkbox" : "";
|
||||
return `
|
||||
@@ -215,7 +216,7 @@ export function renderRaceStandingsTable(rows, emptyLabel, { t, renderTable, esc
|
||||
rows.map(
|
||||
(row) => `
|
||||
<tr>
|
||||
<td>${row.rank}</td>
|
||||
<td>${medal(row.rank)}</td>
|
||||
<td>${escapeHtml(row.driverName || t("common.unknown_driver"))}</td>
|
||||
<td>
|
||||
<div class="table-primary">${escapeHtml(row.score || "-")}</div>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { medal } from "./medal.js";
|
||||
import { sortableTable, sortValuesAttribute } from "./list_sorting.js";
|
||||
|
||||
export function buildArchiveRows(state, { getEventName, getClassName, getTrackLayoutLabel, buildLeaderboard }) {
|
||||
@@ -76,7 +77,7 @@ function renderArchiveDetail(row, deps) {
|
||||
[t("table.pos"), t("table.driver"), t("table.laps"), t("table.best_lap"), t("timing.total_time")],
|
||||
leaderboard.map((rowItem, index) => `
|
||||
<tr>
|
||||
<td>${index + 1}</td>
|
||||
<td>${medal(index + 1)}</td>
|
||||
<td>${escapeHtml(rowItem.displayName || rowItem.driverName || t("common.unknown_driver"))}</td>
|
||||
<td>${rowItem.laps}</td>
|
||||
<td>${formatLap(rowItem.bestLapMs)}</td>
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
import { medal } from "./medal.js";
|
||||
// "Series" page: create a series/cup, pick its classes and races (or create the races in one
|
||||
// go from a list of dates), set the points table and how many results count, and follow the
|
||||
// standings per class - printable and exportable as PDF. Scoring lives in series_logic.js.
|
||||
@@ -183,7 +184,7 @@ function renderStandingsTable(table, { t, escapeHtml }) {
|
||||
${table.rows.length ? `
|
||||
<div class="table-wrap"><table class="series-table">
|
||||
<thead><tr><th>${t("table.pos")}</th><th>${t("table.driver")}</th>${head}<th>${t("series.starts")}</th><th>${t("series.total")}</th></tr></thead>
|
||||
<tbody>${table.rows.map((row) => `<tr><td>${row.rank}</td><td>${escapeHtml(row.driverName)}</td>${cells(row)}<td>${row.starts}</td><td><strong>${row.total}</strong></td></tr>`).join("")}</tbody>
|
||||
<tbody>${table.rows.map((row) => `<tr><td>${medal(row.rank)}</td><td>${escapeHtml(row.driverName)}</td>${cells(row)}<td>${row.starts}</td><td><strong>${row.total}</strong></td></tr>`).join("")}</tbody>
|
||||
</table></div>` : `<p class="hint">${t("series.no_results")}</p>`}
|
||||
</section>`;
|
||||
}
|
||||
|
||||
+9
-2
@@ -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; }
|
||||
@@ -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), '<span class="medal medal-1">1</span>');
|
||||
assert.equal(medal("3"), '<span class="medal medal-3">3</span>');
|
||||
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");
|
||||
});
|
||||
Reference in new issue
Block a user