From 690ced7aea43c1187a66d9f7ef813bd6daa13195 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Tue, 11 Aug 2026 22:04:00 +0200 Subject: refactor(web): centralize OKLCH palette --- web/static/style.css | 87 ++++++++++++++++++++++++++++++++++++-------------- web/templates.templ | 53 ++++++++++++++++++++---------- web/templates_templ.go | 10 +++--- 3 files changed, 105 insertions(+), 45 deletions(-) (limited to 'web') diff --git a/web/static/style.css b/web/static/style.css index 7bb63aa..b24fd21 100644 --- a/web/static/style.css +++ b/web/static/style.css @@ -1,47 +1,86 @@ -:root { color-scheme: light; font-family: system-ui, sans-serif; background: #f5f3ee; color: #1d2a22; } +:root { + color-scheme: light; + font-family: system-ui, sans-serif; + + --palette-forest: oklch(27% 0.065 155); + --palette-leaf: oklch(51% 0.14 154); + --palette-coral: oklch(65% 0.17 48); + --palette-paper: oklch(96% 0.015 90); + --palette-ink: oklch(25% 0.04 155); + --palette-white: oklch(100% 0 0); + + --color-background: var(--palette-paper); + --color-foreground: var(--palette-ink); + --color-forest: var(--palette-forest); + --color-leaf: var(--palette-leaf); + --color-accent: var(--palette-coral); + --color-surface: var(--palette-white); + --color-on-dark: var(--palette-white); + --color-muted: oklch(from var(--palette-ink) calc(l + 0.2) calc(c * 0.35) h); + --color-subtle: oklch(from var(--palette-ink) calc(l + 0.25) calc(c * 0.2) h); + --color-border: oklch(from var(--palette-forest) calc(l + 0.6) calc(c * 0.12) h); + --color-border-subtle: oklch(from var(--palette-forest) calc(l + 0.65) calc(c * 0.12) h); + --color-input-border: oklch(from var(--palette-forest) calc(l + 0.55) calc(c * 0.16) h); + --color-secondary-surface: oklch(from var(--palette-leaf) calc(l + 0.43) calc(c * 0.16) h); + --color-notice-surface: oklch(from var(--palette-leaf) calc(l + 0.39) calc(c * 0.2) h); + --color-notice-text: oklch(from var(--palette-forest) calc(l + 0.18) calc(c * 0.8) h); + --color-error-surface: oklch(from var(--palette-coral) calc(l + 0.31) calc(c * 0.25) h); + --color-error-text: oklch(from var(--palette-coral) calc(l - 0.28) calc(c * 0.8) h); + --color-panel-shadow: oklch(from var(--palette-forest) l c h / 5%); + --color-focus: oklch(from var(--palette-leaf) l c h / 40%); + --color-plot-surface: oklch(from var(--palette-paper) calc(l + 0.03) calc(c * 0.35) h); + --color-plot-surface-overlay: oklch(from var(--color-plot-surface) l c h / 90%); + --color-plot-grid: var(--color-border-subtle); + --color-accent-fill: oklch(from var(--palette-coral) l c h / 12%); + --color-climb-label: oklch(from var(--palette-coral) calc(l - 0.21) calc(c * 0.72) h); + --color-crossing: oklch(from var(--palette-leaf) l c h / 60%); + --color-crossing-label: var(--color-notice-text); + --color-hover-line: oklch(from var(--palette-forest) l c h / 60%); +} + * { box-sizing: border-box; } -body { margin: 0; } -a { color: #18794e; } -.site-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem max(1rem, calc((100vw - 70rem) / 2)); background: #173b2a; color: #fff; } -.site-header a { color: #fff; text-decoration: none; } +body { margin: 0; background: var(--color-background); color: var(--color-foreground); } +a { color: var(--color-leaf); } +.site-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem max(1rem, calc((100vw - 70rem) / 2)); background: var(--color-forest); color: var(--color-on-dark); } +.site-header a { color: var(--color-on-dark); text-decoration: none; } .brand { font-weight: 750; letter-spacing: .02em; } .nav { display: flex; gap: 1rem; font-size: .95rem; } .container { width: min(70rem, calc(100% - 2rem)); margin: 0 auto; padding: 2.5rem 0 4rem; } -.eyebrow { margin: 0 0 .4rem; color: #18794e; font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; } +.eyebrow { margin: 0 0 .4rem; color: var(--color-leaf); font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; } h1 { margin: 0; font-size: clamp(2rem, 4vw, 3.2rem); line-height: 1; } -.lead { max-width: 42rem; color: #5b675f; } -.panel { margin-top: 2rem; padding: 1.25rem; border: 1px solid #d9ded8; border-radius: 1rem; background: #fff; box-shadow: 0 1rem 2.5rem #173b2a0d; } +.lead { max-width: 42rem; color: var(--color-muted); } +.panel { margin-top: 2rem; padding: 1.25rem; border: 1px solid var(--color-border); border-radius: 1rem; background: var(--color-surface); box-shadow: 0 1rem 2.5rem var(--color-panel-shadow); } .toolbar { display: flex; align-items: end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; } -.button { display: inline-block; border: 0; border-radius: .65rem; padding: .7rem 1rem; background: #d96932; color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; } -.button.secondary { background: #e8eee9; color: #173b2a; } -label { display: grid; gap: .35rem; color: #5b675f; font-size: .85rem; font-weight: 650; } -input { border: 1px solid #c8d0c9; border-radius: .55rem; padding: .65rem .7rem; font: inherit; color: inherit; background: #fff; } +.button { display: inline-block; border: 0; border-radius: .65rem; padding: .7rem 1rem; background: var(--color-accent); color: var(--color-on-dark); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; } +.button.secondary { background: var(--color-secondary-surface); color: var(--color-forest); } +label { display: grid; gap: .35rem; color: var(--color-muted); font-size: .85rem; font-weight: 650; } +input { border: 1px solid var(--color-input-border); border-radius: .55rem; padding: .65rem .7rem; font: inherit; color: inherit; background: var(--color-surface); } .form-row { display: flex; align-items: end; gap: .75rem; flex-wrap: wrap; } .sync-progress { display: grid; gap: .7rem; margin-top: 1.25rem; } .progress-heading { display: flex; justify-content: space-between; gap: 1rem; } -progress { width: 100%; height: .8rem; accent-color: #d96932; } -.notice { margin: 1rem 0 0; border-radius: .6rem; padding: .75rem 1rem; background: #e5f3e9; color: #17633f; } -.error { margin: 1rem 0 0; border-radius: .6rem; padding: .75rem 1rem; background: #fbe8df; color: #8c3517; } +progress { width: 100%; height: .8rem; accent-color: var(--color-accent); } +.notice { margin: 1rem 0 0; border-radius: .6rem; padding: .75rem 1rem; background: var(--color-notice-surface); color: var(--color-notice-text); } +.error { margin: 1rem 0 0; border-radius: .6rem; padding: .75rem 1rem; background: var(--color-error-surface); color: var(--color-error-text); } table { width: 100%; border-collapse: collapse; } -th, td { padding: .85rem .5rem; border-bottom: 1px solid #e5e9e5; text-align: left; } -th { color: #68746c; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; } +th, td { padding: .85rem .5rem; border-bottom: 1px solid var(--color-border-subtle); text-align: left; } +th { color: var(--color-subtle); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; } .sort-link { color: inherit; text-decoration: none; } -.sort-link:hover, .sort-link:focus-visible, th.active .sort-link { color: #d96932; } +.sort-link:hover, .sort-link:focus-visible, th.active .sort-link { color: var(--color-accent); } .sort-indicator { display: inline-block; margin-left: .2rem; } .numeric { text-align: right; white-space: nowrap; } -.empty { padding: 2.5rem 1rem; text-align: center; color: #68746c; } +.empty { padding: 2.5rem 1rem; text-align: center; color: var(--color-subtle); } .map-panel { padding: 0; overflow: hidden; } .ride-map { min-height: 24rem; height: min(65vh, 40rem); } .profile-panel { padding-bottom: 1rem; } .profile-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; } .profile-heading h2 { margin: 0; font-size: 1.2rem; } -.profile-heading p { margin: 0; color: #68746c; font-size: .9rem; } +.profile-heading p { margin: 0; color: var(--color-subtle); font-size: .9rem; } .profile-chart { margin-top: 1rem; } -.profile-chart canvas { display: block; width: 100%; height: 22rem; border-radius: .65rem; background: #fbfcfa; outline: none; } -.profile-chart canvas:focus-visible { box-shadow: 0 0 0 .2rem #18794e66; } -.profile-hover { display: block; min-height: 1.4rem; margin: .7rem 0 0; color: #5b675f; font-size: .9rem; } +.profile-chart canvas { display: block; width: 100%; height: 22rem; border-radius: .65rem; background: var(--color-plot-surface); outline: none; } +.profile-chart canvas:focus-visible { box-shadow: 0 0 0 .2rem var(--color-focus); } +.profile-hover { display: block; min-height: 1.4rem; margin: .7rem 0 0; color: var(--color-muted); font-size: .9rem; } dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 0; } -dt { color: #68746c; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; } +dt { color: var(--color-subtle); font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; } dd { margin: .25rem 0 0; font-size: 1.2rem; font-weight: 700; } @media (max-width: 700px) { .container { width: min(100% - 1rem, 70rem); padding-top: 1.5rem; } .site-header { padding-inline: 1rem; } th:nth-child(n+4), td:nth-child(n+4) { display: none; } .panel { padding: .8rem; } } @media (max-width: 500px) { dl { grid-template-columns: repeat(2, 1fr); } } diff --git a/web/templates.templ b/web/templates.templ index efc7213..8e7c0f1 100644 --- a/web/templates.templ +++ b/web/templates.templ @@ -97,6 +97,27 @@ templ RideDetailContent(data RideDetailView) { const canvas = document.getElementById("ride-profile-chart"); const hoverOutput = document.getElementById("ride-profile-hover"); if (!mapElement || !routeElement || !profileElement || !canvas || !hoverOutput) return; + const colorProbe = document.createElement("span"); + colorProbe.hidden = true; + document.body.append(colorProbe); + const resolveColor = (name) => { + colorProbe.style.color = `var(${name})`; + return getComputedStyle(colorProbe).color; + }; + const colors = { + accent: resolveColor("--color-accent"), + forest: resolveColor("--color-forest"), + subtle: resolveColor("--color-subtle"), + plotSurface: resolveColor("--color-plot-surface"), + plotSurfaceOverlay: resolveColor("--color-plot-surface-overlay"), + grid: resolveColor("--color-plot-grid"), + accentFill: resolveColor("--color-accent-fill"), + climbLabel: resolveColor("--color-climb-label"), + crossing: resolveColor("--color-crossing"), + crossingLabel: resolveColor("--color-crossing-label"), + hoverLine: resolveColor("--color-hover-line"), + }; + colorProbe.remove(); const route = JSON.parse(routeElement.textContent); const profile = JSON.parse(profileElement.textContent); const map = L.map(mapElement); @@ -106,7 +127,7 @@ templ RideDetailContent(data RideDetailView) { }); tiles.addTo(map); const routeLayer = L.geoJSON(route, { - style: { color: "#d96932", weight: 4, opacity: 0.9 }, + style: { color: colors.accent, weight: 4, opacity: 0.9 }, }).addTo(map); const bounds = routeLayer.getBounds(); if (bounds.isValid()) { @@ -116,8 +137,8 @@ templ RideDetailContent(data RideDetailView) { const points = profile.points || []; if (points.length === 0) return; const routeCursor = L.circleMarker([points[0].latitude, points[0].longitude], { - color: "#173b2a", - fillColor: "#d96932", + color: colors.forest, + fillColor: colors.accent, fillOpacity: 0, opacity: 0, radius: 7, @@ -176,7 +197,7 @@ templ RideDetailContent(data RideDetailView) { state.plot = { left: 52, right: rect.width - 20, top: 24, bottom: rect.height - 34 }; const plot = state.plot; context.clearRect(0, 0, rect.width, rect.height); - context.fillStyle = "#fbfcfa"; + context.fillStyle = colors.plotSurface; context.fillRect(0, 0, rect.width, rect.height); context.font = "12px system-ui, sans-serif"; @@ -185,13 +206,13 @@ templ RideDetailContent(data RideDetailView) { const fraction = step / 4; const y = plot.top + fraction * (plot.bottom - plot.top); const elevation = maxElevation - fraction * (maxElevation - minElevation); - context.strokeStyle = "#e5e9e5"; + context.strokeStyle = colors.grid; context.lineWidth = 1; context.beginPath(); context.moveTo(plot.left, y); context.lineTo(plot.right, y); context.stroke(); - context.fillStyle = "#68746c"; + context.fillStyle = colors.subtle; context.textAlign = "right"; context.fillText(formatElevation(elevation), plot.left - 8, y); } @@ -199,10 +220,10 @@ templ RideDetailContent(data RideDetailView) { for (const climb of profile.climbs || []) { const startX = clamp(xForDistance(climb.startKm), plot.left, plot.right); const endX = clamp(xForDistance(climb.endKm), plot.left, plot.right); - context.fillStyle = "#d9693230"; + context.fillStyle = colors.accentFill; context.fillRect(startX, plot.top, Math.max(endX - startX, 1), plot.bottom - plot.top); const label = climb.name || `${climb.category} ${Math.round(climb.score)}`; - context.fillStyle = "#8c421f"; + context.fillStyle = colors.climbLabel; context.textAlign = "center"; context.textBaseline = "top"; context.fillText(label, clamp((startX + endX) / 2, plot.left + 24, plot.right - 24), plot.top + 4); @@ -210,7 +231,7 @@ templ RideDetailContent(data RideDetailView) { for (const crossing of profile.crossings || []) { const x = xForDistance(crossing.distanceKm); - context.strokeStyle = "#18794e99"; + context.strokeStyle = colors.crossing; context.lineWidth = 1; context.setLineDash([4, 3]); context.beginPath(); @@ -225,7 +246,7 @@ templ RideDetailContent(data RideDetailView) { for (const point of points) context.lineTo(xForDistance(point.distanceKm), yForElevation(point.elevationM)); context.lineTo(xForDistance(points[points.length - 1].distanceKm), plot.bottom); context.closePath(); - context.fillStyle = "#d9693220"; + context.fillStyle = colors.accentFill; context.fill(); context.beginPath(); for (let i = 0; i < points.length; i++) { @@ -233,7 +254,7 @@ templ RideDetailContent(data RideDetailView) { if (i === 0) context.moveTo(xForDistance(point.distanceKm), yForElevation(point.elevationM)); else context.lineTo(xForDistance(point.distanceKm), yForElevation(point.elevationM)); } - context.strokeStyle = "#d96932"; + context.strokeStyle = colors.accent; context.lineWidth = 2.5; context.stroke(); for (const crossing of profile.crossings || []) { @@ -242,15 +263,15 @@ templ RideDetailContent(data RideDetailView) { const labelWidth = context.measureText(label).width; const labelX = clamp(x, plot.left + labelWidth / 2 + 3, plot.right - labelWidth / 2 - 3); const labelY = plot.top - 6; - context.fillStyle = "#fbfcfae6"; + context.fillStyle = colors.plotSurfaceOverlay; context.fillRect(labelX - labelWidth / 2 - 3, labelY - 15, labelWidth + 6, 16); - context.fillStyle = "#17633f"; + context.fillStyle = colors.crossingLabel; context.textAlign = "center"; context.textBaseline = "bottom"; context.fillText(label, labelX, labelY); } - context.fillStyle = "#68746c"; + context.fillStyle = colors.subtle; context.textAlign = "center"; context.textBaseline = "top"; for (let step = 0; step <= 4; step++) { @@ -262,7 +283,7 @@ templ RideDetailContent(data RideDetailView) { const point = points[state.hoveredIndex]; const x = xForDistance(point.distanceKm); const y = yForElevation(point.elevationM); - context.strokeStyle = "#173b2a99"; + context.strokeStyle = colors.hoverLine; context.lineWidth = 1; context.setLineDash([3, 3]); context.beginPath(); @@ -270,7 +291,7 @@ templ RideDetailContent(data RideDetailView) { context.lineTo(x, plot.bottom); context.stroke(); context.setLineDash([]); - context.fillStyle = "#173b2a"; + context.fillStyle = colors.forest; context.beginPath(); context.arc(x, y, 5, 0, 2 * Math.PI); context.fill(); diff --git a/web/templates_templ.go b/web/templates_templ.go index 93bc9e3..6991c73 100644 --- a/web/templates_templ.go +++ b/web/templates_templ.go @@ -498,7 +498,7 @@ func RideDetailContent(data RideDetailView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -569,7 +569,7 @@ func SyncContent(data SyncPageData) templ.Component { var templ_7745c5c3_Var31 string templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(data.Notice) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates.templ`, Line: 330, Col: 52} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates.templ`, Line: 351, Col: 52} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31)) if templ_7745c5c3_Err != nil { @@ -593,7 +593,7 @@ func SyncContent(data SyncPageData) templ.Component { var templ_7745c5c3_Var32 string templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(data.Error) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates.templ`, Line: 335, Col: 49} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates.templ`, Line: 356, Col: 49} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32)) if templ_7745c5c3_Err != nil { @@ -635,7 +635,7 @@ func SyncContent(data SyncPageData) templ.Component { var templ_7745c5c3_Var34 string templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(data.From) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates.templ`, Line: 346, Col: 64} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates.templ`, Line: 367, Col: 64} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34)) if templ_7745c5c3_Err != nil { @@ -648,7 +648,7 @@ func SyncContent(data SyncPageData) templ.Component { var templ_7745c5c3_Var35 string templ_7745c5c3_Var35, templ_7745c5c3_Err = templ.JoinStringErrs(data.To) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates.templ`, Line: 347, Col: 58} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates.templ`, Line: 368, Col: 58} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35)) if templ_7745c5c3_Err != nil { -- cgit v1.2.3