@wral/wral-election-map
v0.1.2
Published
<wral-election-map>: a public election results map. Its own artifact, separate from the elections mod.
Keywords
Readme
wral-election-map
<wral-election-map>: one contest on SBOE's precinct shapes, read from the public election API (contract §37).
Statewide by county; a county opens its precincts. It polls with If-None-Match and pauses while the page is hidden.
<script type="module" src="https://cdn.wral.com/elections/election-map/v0.1.2/wral-election-map.js"></script>
<wral-election-map
api-base="https://api.wral.com/dev/election/v2"
shapes-base="https://cdn.wral.com/elections/election-map/shapes/SBE_PRECINCTS_20260824"
election="…" contest="…"></wral-election-map>| attribute | |
|---|---|
| api-base | the public election API |
| shapes-base | a published shapes directory |
| election, contest | what to draw |
| county | open on one county (WAKE, NEW HANOVER) |
| poll | seconds between reads; 15 by default, 5 at least, 0 off |
Theming
Set these on the element (wral-election-map { --wem-bg: … }); they win over its light and dark defaults.
Party colours are fixed.
| property | |
|---|---|
| --wem-bg, --wem-text, --wem-muted | ground, text, secondary text |
| --wem-stroke | the lines between places |
| --wem-none | a place nobody leads |
| --wem-outside, --wem-outside-stroke | a county the race does not cover, and its outline |
| --wem-border, --wem-focus | buttons, the focused place |
| --wem-font | |
| --wem-label, --wem-label-halo | county names, and the ring that keeps them legible |
| --wem-label-on-dark, --wem-label-on-dark-halo | the same, on a dark party fill |
Selecting
A click (or Enter) fires place-select, bubbling and composed, with detail: { county, precinct }:
a county statewide, a precinct inside an open county, { county: null, precinct: null } back to statewide.
Choosing a county opens it unless a listener calls preventDefault(). el.selected reads the last choice.
Published paths (cdn.wral.com/elections/election-map/)
| path | cache |
|---|---|
| vX.Y.Z/wral-election-map.js | immutable |
| shapes/<SBOE file>/counties.topojson, precincts/<COUNTY>.topojson, manifest.json | immutable |
Pages pin an exact version; there are no vX or latest aliases. Also on npm as @wral/wral-election-map.
Releasing
Bump version here, then tag election-map-vX.Y.Z (the tag must match). The pipeline builds the element and the
shapes, publishes both, and publishes to npm. The mod's own vX.Y.Z tags do not release the map.
npm run build -w election-map # dist/, with a 30 KB gzip budget
npm run shapes -w election-map # build/shapes/, from SBOE's zip