feat: mobile UI card layout for players and courses (#16)

This commit is contained in:
Samuel Enocsson
2026-05-22 21:07:00 +02:00
parent e25f66c5d3
commit cc9d8eb4cd
14 changed files with 1007 additions and 56 deletions
+14 -9
View File
@@ -1,4 +1,5 @@
function createRatingChart(container, history) {
function createRatingChart(container, history, opts) {
opts = opts || {};
if (!history || history.length === 0) {
container.textContent = '';
var empty = document.createElement('div');
@@ -8,8 +9,13 @@ function createRatingChart(container, history) {
return;
}
var W = 880, H = 240;
var pad = { left: 44, right: 16, top: 20, bottom: 32 };
var W = opts.w || 880;
var H = opts.h || 240;
var pad = opts.padding || { left: 44, right: 16, top: 20, bottom: 32 };
var tickCount = opts.tickCount !== undefined ? opts.tickCount : 4;
var xLabelCount = opts.xLabelCount !== undefined ? opts.xLabelCount : 5;
var dotR = opts.dotR !== undefined ? opts.dotR : 3;
var lastDotR = opts.lastDotR !== undefined ? opts.lastDotR : 4;
var chartW = W - pad.left - pad.right;
var chartH = H - pad.top - pad.bottom;
@@ -61,8 +67,7 @@ function createRatingChart(container, history) {
'aria-hidden': 'true'
});
// Grid lines + y-axis labels (4 ticks)
var tickCount = 4;
// Grid lines + y-axis labels
for (var i = 0; i <= tickCount; i++) {
var gy = pad.top + (i / tickCount) * chartH;
var gr = Math.round(maxR - (i / tickCount) * range);
@@ -96,18 +101,18 @@ function createRatingChart(container, history) {
if (isLast) {
svg.appendChild(el('circle', {
cx: p.x.toFixed(1), cy: p.y.toFixed(1),
r: '4', fill: 'var(--accent)', stroke: 'var(--paper)', 'stroke-width': '2'
r: String(lastDotR), fill: 'var(--accent)', stroke: 'var(--paper)', 'stroke-width': '2'
}));
} else {
svg.appendChild(el('circle', {
cx: p.x.toFixed(1), cy: p.y.toFixed(1),
r: '3', fill: 'var(--accent)'
r: String(dotR), fill: 'var(--accent)'
}));
}
});
// X-axis labels (5 evenly spaced)
var labelCount = Math.min(5, history.length);
// X-axis labels (evenly spaced)
var labelCount = Math.min(xLabelCount, history.length);
var labelIndices = [];
if (labelCount <= 1) {
labelIndices.push(0);