DX-life's country pages render nothing where a map belongs. The map they need
has been in this repo since the regions clone landed — it was just unreachable
without loading the whole regions dashboard, a bundle that fetches the people
group list, builds four stat cards, a region chooser and a table, none of which
a country page wants. So this is not a new map. It is the same component, given
its own element and its own bundle.
<doxa-country-map profile-config='{"countryCodes":["TCD"],"colorByPrayer":true}'>
RegionCountryMap and useRegionsI18n move to library/ because they now have a
second consumer, which is the only thing that earns a place there. Six import
sites updated in this commit; nothing else moved.
THE CONTRACT arrives through profile-config, the channel every element here
uses, so a generated page and a hand-written host page are configured the same
way: countryCodes, center, zoom, bounds, colorByPrayer, researchUrl,
prayBaseUrl. Two translations happen at the edge rather than by widening the
component — colorByPrayer is a boolean here and colorMode a string inside, and
countryCodes accepts an array OR "TCD,NER,MLI", because an HTML attribute is a
string and JSON-inside-an-attribute is the shape people get wrong.
THE ELEMENT FETCHES ITS OWN PINS, and that is what makes prayBaseUrl part of the
contract rather than decoration. An element handed a country code, a base URL
and no way to fetch would draw a country outline with nothing inside it — the
blank page it exists to fix, in a new disguise. Same endpoint, same fields, same
mapping as the dashboard; it asks for a country instead of the world.
THE FIELD LIST TRAVELS WITH THE MAPPING, in peopleGroupPoints.js. The obvious
version of this commit asks for PEOPLE_GROUP_LIST_FIELDS — the list the stats
need — and every pin still draws, every popup comes up empty, and nothing logs
anything. The popup half is what makes it a map you can read, so the two are
one export and neither can be requested without the other. The dashboard's own
request is unchanged: the concatenation produces the identical string.
countryUrl is additive, not in the confirmed contract. The component's country
link needs a base and DX-life's country pages live under /regions/; a host that
sets nothing gets that documented default.
31 lines
1.5 KiB
JavaScript
31 lines
1.5 KiB
JavaScript
/**
|
|
* plugin-designs/country-map/index.js
|
|
*
|
|
* Bundle entry — registers <doxa-country-map>.
|
|
*
|
|
* Usage from a host page (a DX-life country page is the first consumer):
|
|
* <script src="/dx-maps/country-map/country-map.js"></script>
|
|
* <doxa-country-map profile-config='{"profile":"country-map","countryCodes":["TCD"],"colorByPrayer":true}'></doxa-country-map>
|
|
*
|
|
* ONE tag, unlike doxa-simple-map's two: there is no legacy name to keep working, because nothing
|
|
* has ever embedded this map on its own. Adding a second alias now would create the back-compat
|
|
* problem rather than solve one.
|
|
*/
|
|
import { defineMapElement } from '@map/elements/defineMapElement.js'
|
|
import { registerStrategies } from '@map/colors/_registry.js'
|
|
|
|
// Evaluated by Vite relative to THIS file, so it captures only this bundle's profiles, and handed
|
|
// to ProfileLoader via app.provide('profileModules') — the Q3 contract, same as every bundle.
|
|
const profileModules = import.meta.glob('./*.vue')
|
|
|
|
// Bundle-private colour strategies. Empty today: this bundle draws with the shared region palette
|
|
// and the prayer strategy the library already registers.
|
|
registerStrategies(import.meta.glob('./src/colors/*.js', { eager: true }))
|
|
|
|
const DoxaCountryMapElement = defineMapElement({ profileModules, configureApp: () => {} })
|
|
|
|
if (typeof customElements !== 'undefined' && !customElements.get('doxa-country-map')) {
|
|
customElements.define('doxa-country-map', DoxaCountryMapElement)
|
|
}
|
|
|
|
export default DoxaCountryMapElement
|