SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

mapLinks

Links every data-map-key row and pin in the host's document at once, by listening on the document.

tsx
import { mapLinks } from "@sdxc/ui/map";
View code
tsx
<ul>
	{stays.map((stay) => (
		<li mix={[mapLink(stay.id)]}>
			<a href={`/stays/${stay.id}`}>{stay.name}</a>
		</li>
	))}
</ul>
<MapCanvas label="Stays in Porto Novo" art={<Town />}>
	{stays.map((stay) => (
		<MapCanvas.Pin x={stay.x} y={stay.y} label={stay.price} mapKey={stay.id} />
	))}
</MapCanvas>
{/* One island links every data-map-key row and pin on the page through mapLinks(). */}
<MapCanvasSync />

Usage

Links every data-map-key row and pin in the host's document at once, by listening on the document, so markup rendered on the server lights up without each row being an island. The listeners go when the host leaves the page.

Signature

typescript
mapLinks(): MixinDescriptor<HTMLElement>

Examples

tsx
<span hidden mix={mapLinks()} />

The events, constants and types its module publishes, each imported from @sdxc/ui/map too.

Constant

MAP_KEY_ATTRIBUTE

Attribute naming the record a row or pin stands for.

typescript
const MAP_KEY_ATTRIBUTE = "data-map-key"
Constant

MAP_HIGHLIGHTED_ATTRIBUTE

Attribute present on every element of the record under the pointer or focus.

typescript
const MAP_HIGHLIGHTED_ATTRIBUTE = "data-highlighted"
@sdxc/ui

Can’t find it? Contact us