mirror of
https://github.com/zvx-echo6/navi.git
synced 2026-05-20 22:54:42 +02:00
feat(navi): config-driven tile source, defaults, and feature flags
Load deployment config from /api/config on startup: - src/config.js: loader with 3s timeout + hardcoded fallback - src/hooks/useConfig.js: useConfig() and useFeature() hooks - MapView.jsx: tile URL, attribution, center, zoom from config - main.jsx: loads config before first render Falls back to home profile defaults if backend unavailable. No visible behavior change — infrastructure for future features. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a819458865
commit
edc5a9788d
4 changed files with 146 additions and 22 deletions
29
src/hooks/useConfig.js
Normal file
29
src/hooks/useConfig.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { useState, useEffect } from 'react'
|
||||
import { loadConfig, getConfig, hasFeature } from '../config'
|
||||
|
||||
/**
|
||||
* Hook that returns the deployment config, loading it if needed.
|
||||
* Components using this will re-render once config is loaded.
|
||||
*/
|
||||
export function useConfig() {
|
||||
const [config, setConfig] = useState(getConfig)
|
||||
|
||||
useEffect(() => {
|
||||
if (!config) {
|
||||
loadConfig().then(setConfig)
|
||||
}
|
||||
}, [config])
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to check a single feature flag.
|
||||
* @param {string} flag - e.g. 'has_hillshade'
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function useFeature(flag) {
|
||||
const config = useConfig()
|
||||
if (!config) return false
|
||||
return Boolean(config.features?.[flag])
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue