1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-19 04:49:37 +02:00

feat(map): implement dynamic basemap URL based on theme; update map styles across components

This commit is contained in:
Sean Morley 2025-06-13 23:49:14 -04:00
parent badeac867d
commit d4c76f8718
11 changed files with 55 additions and 17 deletions

View file

@ -584,3 +584,32 @@ export function debounce(func: Function, timeout: number) {
}, timeout);
};
}
export function getIsDarkMode() {
const theme = document.documentElement.getAttribute('data-theme');
if (theme) {
const isDark =
theme === 'dark' ||
theme === 'night' ||
theme === 'aestheticDark' ||
theme === 'northernLights' ||
theme === 'forest';
return isDark;
}
// Fallback to browser preference if no theme cookie is set
if (typeof window !== 'undefined' && window.matchMedia) {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
return prefersDark;
}
return false;
}
export function getBasemapUrl() {
if (getIsDarkMode()) {
return 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json';
}
return 'https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json';
}