feat(dees-geo-map): Add dark/light theme support for UI and map tiles, subscribe to theme changes and add traffic toggle in navigation

This commit is contained in:
2026-02-05 16:50:51 +00:00
parent 32454a7d19
commit 54999a52b7
6 changed files with 275 additions and 133 deletions

View File

@@ -260,6 +260,26 @@ The component uses a CSS Grid layout with sidebars that **push** the map (not ov
- `z-index: 10` - Header toolbar
- `z-index: 5` - Map overlays (traffic legend, feature count)
### Dark/Light Theme Support
The component fully supports automatic dark/light theme switching:
**UI Elements Theming:**
- All UI elements (toolbar, panels, search, navigation) use `cssManager.bdTheme()` for automatic color switching
- Pattern: `cssManager.bdTheme('lightValue', 'darkValue')` - first arg is light theme, second is dark
**Map Tiles Theming:**
- When `mapStyle="osm"` (default), the map automatically switches between:
- **Light theme**: CartoDB Voyager GL (vector tiles) - clean, detailed style
- **Dark theme**: CartoDB Dark Matter GL (vector tiles) - sleek dark style
- Theme changes are detected via `domtools.themeManager.themeObservable`
- No API key required for CartoDB basemaps
**Semantic Colors (unchanged by theme):**
- Navigation markers: Green (#22c55e) for start, Red (#ef4444) for end
- Route line: Blue (#3b82f6) with dark outline (#1e40af)
- Traffic congestion: Green → Yellow → Orange → Red → Dark Red (universal traffic colors)
### Shadow DOM & Terra-Draw Drawing Fix
Terra-draw's event listeners normally intercept map events through MapLibre's canvas element. In Shadow DOM contexts, these events are scoped locally and don't propagate correctly, causing terra-draw handlers to fail while MapLibre's drag handlers continue working.