Skip to content

Commit e8a7394

Browse files
CopilotOlliV
andauthored
Use theme primary color and centralized tokens for explorer tile colors
Agent-Logs-Url: https://github.com/bfree-trainer/bfree/sessions/530d55d1-269a-4442-94d2-0a1226f3ba16 Co-authored-by: OlliV <1401625+OlliV@users.noreply.github.com>
1 parent e8d3620 commit e8a7394

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

components/map/ExplorerTilesLayer.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
import { useEffect } from 'react';
77
import L from 'leaflet';
88
import { useMap } from 'react-leaflet';
9+
import { useTheme } from '@mui/material/styles';
910
import { EXPLORER_ZOOM, collectVisitedTiles, findMaxSquare, tileToBounds } from 'lib/explorer_tiles';
11+
import { explorerColors } from 'lib/tokens';
1012

1113
/**
1214
* Renders Veloviewer-style explorer tiles on a Leaflet map:
@@ -20,6 +22,8 @@ import { EXPLORER_ZOOM, collectVisitedTiles, findMaxSquare, tileToBounds } from
2022
*/
2123
export default function ExplorerTilesLayer({ tracks }: { tracks: [number, number][][] }) {
2224
const map = useMap();
25+
const theme = useTheme();
26+
const tileColor = theme.palette.primary.main;
2327

2428
useEffect(() => {
2529
if (!map) return;
@@ -30,7 +34,7 @@ export default function ExplorerTilesLayer({ tracks }: { tracks: [number, number
3034
const maxSquare = findMaxSquare(visitedTiles);
3135
const layerGroup = L.layerGroup().addTo(map);
3236

33-
// Draw all visited tiles as semi-transparent blue rectangles.
37+
// Draw all visited tiles as semi-transparent rectangles.
3438
for (const key of visitedTiles) {
3539
const parts = key.split(',');
3640
const tx = Number(parts[0]);
@@ -42,8 +46,8 @@ export default function ExplorerTilesLayer({ tracks }: { tracks: [number, number
4246
[b.north, b.east],
4347
],
4448
{
45-
color: '#1976D2',
46-
fillColor: '#1976D2',
49+
color: tileColor,
50+
fillColor: tileColor,
4751
fillOpacity: 0.3,
4852
weight: 0.5,
4953
opacity: 0.6,
@@ -65,7 +69,7 @@ export default function ExplorerTilesLayer({ tracks }: { tracks: [number, number
6569
[nwBounds.north, seBounds.east],
6670
],
6771
{
68-
color: '#ff7700',
72+
color: explorerColors.maxSquare,
6973
fill: false,
7074
weight: 3,
7175
opacity: 0.9,
@@ -95,7 +99,7 @@ export default function ExplorerTilesLayer({ tracks }: { tracks: [number, number
9599
return () => {
96100
layerGroup.remove();
97101
};
98-
}, [map, tracks]);
102+
}, [map, tracks, tileColor]);
99103

100104
return null;
101105
}

lib/tokens.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ export const recordCardMinHeight = '10em' as const;
6868
// ---------------------------------------------------------------------------
6969
export const inlineIconFontSize = '18px !important' as const;
7070

71+
// ---------------------------------------------------------------------------
72+
// Explorer tiles — Veloviewer-style visited tiles and max-square highlight
73+
// ---------------------------------------------------------------------------
74+
export const explorerColors = {
75+
/** Visited tile fill and border (matches MUI primary.main). */
76+
tile: '#1976D2',
77+
/** Max-square outline — Veloviewer orange. */
78+
maxSquare: '#ff7700',
79+
} as const;
80+
7181
// ---------------------------------------------------------------------------
7282
// YouTube brand colors — side pane tab, header, and load button
7383
// ---------------------------------------------------------------------------

pages/history.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { getElapsedTimeStr } from 'lib/format';
4343
import { smartDistanceUnitFormat } from 'lib/units';
4444
import { useGlobalState } from 'lib/global';
4545
import { collectVisitedTiles, findMaxSquare } from 'lib/explorer_tiles';
46+
import { explorerColors } from 'lib/tokens';
4647
import type RideMiniMapType from 'components/map/RideMiniMap';
4748
import type { OpenStreetMapArg } from 'components/map/OpenStreetMap';
4849
import type { ExplorerTilesLayerArgs } from 'components/map/ExplorerTilesLayer';
@@ -477,7 +478,7 @@ export default function History() {
477478
</Box>
478479
{maxSquare && (
479480
<Box>
480-
<Typography variant="h4" fontWeight={700} sx={{ color: '#ff7700' }}>
481+
<Typography variant="h4" fontWeight={700} sx={{ color: explorerColors.maxSquare }}>
481482
{maxSquare.size}×{maxSquare.size}
482483
</Typography>
483484
<Typography variant="caption" color="text.secondary">

0 commit comments

Comments
 (0)