@fusion.dev/helix-docs 0.105.0 → 0.107.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,12 +10,12 @@ title: Iconography
10
10
  <helix-icon name="trash"></helix-icon>
11
11
  ```
12
12
 
13
- Helix has 108 glyphs from Phosphor, drawn on a 256 box at Phosphor's bold
14
- weight. We keep Phosphor's own geometry. Rescaling to a 24 box would change the
15
- optical weight of every glyph, and the set would stop matching Phosphor. We use
16
- the bold weight because Phosphor's regular weight is a hairline beside the
17
- medium weight of Helix text. An icon that looks lighter than the words next to
18
- it does not work as a mark.
13
+ Helix has 125 glyphs, 120 of them from Phosphor, drawn on a 256 box at
14
+ Phosphor's bold weight. We keep Phosphor's own geometry. Rescaling to a 24 box
15
+ would change the optical weight of every glyph, and the set would stop matching
16
+ Phosphor. We use the bold weight because Phosphor's regular weight is a
17
+ hairline beside the medium weight of Helix text. An icon that looks lighter than
18
+ the words next to it does not work as a mark.
19
19
 
20
20
  ## Size and color come from the surrounding text
21
21
 
@@ -90,7 +90,7 @@ both are set, `icon` wins.
90
90
 
91
91
  `icon` also keeps your bundle small. `name` looks up glyphs in an index of the
92
92
  whole set, and no bundler can tree-shake that index. If you render one icon by
93
- `name`, you ship the whole set: 15 kB gzipped for 108 glyphs. With `icon`, you
93
+ `name`, you ship the whole set: 17 kB gzipped for 125 glyphs. With `icon`, you
94
94
  ship only the glyph you import.
95
95
 
96
96
  `icon` also draws glyphs from outside this set. Anything that exports the same
package/content/maps.mdx CHANGED
@@ -7,7 +7,7 @@ title: Maps
7
7
  # Maps
8
8
 
9
9
  Helix Maps puts a frame around a map drawn by MapLibre, Leaflet, or a renderer of
10
- your own. The frame adds pan and zoom buttons and a place for the map credit. You
10
+ your own. The frame adds a column of controls and a place for the map credit. You
11
11
  add places, routes, areas, live positions, and data as elements inside the
12
12
  frame, and `@fusion.dev/helix-map` connects the frame to the renderer and styles
13
13
  the map with your theme.
@@ -25,7 +25,11 @@ Add the map frame, an element for MapLibre to draw in, and your places:
25
25
  ```html
26
26
  <helix-map label="Our stores">
27
27
  <div id="map"></div>
28
- <helix-map-marker label="Flagship" lat="30.2672" lng="-97.7431"></helix-map-marker>
28
+ <helix-map-marker
29
+ label="Flagship"
30
+ lat="30.2672"
31
+ lng="-97.7431"
32
+ ></helix-map-marker>
29
33
  </helix-map>
30
34
  ```
31
35
 
@@ -55,8 +59,8 @@ followTheme(map, frame, style)
55
59
 
56
60
  `connectMap` links the frame to the renderer:
57
61
 
58
- - The frame's pan and zoom buttons and keys move the map, using your theme's
59
- motion settings. The map moves without animation when a user has asked for
62
+ - The frame's pan, zoom, rotate, and tilt buttons and keys move the map, using
63
+ your theme's motion settings. The map moves without animation when a user has asked for
60
64
  reduced motion.
61
65
  - The renderer's own keyboard handling and zoom buttons are turned off, so the
62
66
  frame's controls are the only ones.
@@ -79,11 +83,41 @@ you already have. Leaflet draws routes, areas, and points only when you pass it
79
83
  - Main roads use `primary`, your brand color.
80
84
  - Smaller roads, buildings, borders, and labels use `foreground`.
81
85
 
86
+ It also draws landmarks, highway signs, and neighborhood names:
87
+
88
+ - A landmark is an icon on a disc and its name, in a color for its kind:
89
+ parks, museums, schools, hotels, hospitals, stations, and stadiums from zoom
90
+ 14, and food and shops from zoom 16. Each color is a fixed hue at your brand
91
+ color's lightness, so the kinds stay apart in any theme.
92
+ - A highway's number is on its sign, drawn to the Federal Highway
93
+ Administration's outlines: the red and blue Interstate shield, the white US
94
+ route shield, the white circle of a state route, and a plain plate for other
95
+ roads.
96
+ - Neighborhoods are in spaced capitals, quieter than the towns.
97
+
82
98
  The same call builds a light map for a light theme and a dark map for a dark
83
99
  theme. Map labels meet a contrast target of 4.5 against the land. Pass
84
100
  `contrast` to change it, `language` to choose which name each place is labeled
85
101
  with, and `tiles` and `glyphs` to use your own tile server.
86
102
 
103
+ Pass `font` to draw the labels in your theme's typeface. MapLibre draws the
104
+ letters in the page from the font your page has loaded, so there are no glyph
105
+ files to fetch. `mapFontFrom(frame)` reads the typeface from your theme, and
106
+ `fontReady(font)` waits until its weights are loaded. Wait for it before you
107
+ create the map, because MapLibre keeps each letter as first drawn:
108
+
109
+ ```js
110
+ const font = mapFontFrom(frame)
111
+ await fontReady(font)
112
+ const map = new maplibregl.Map({ container: 'map', style: mapLibreStyle(colors, { font }) })
113
+ ```
114
+
115
+ The style draws the world as a globe when the map is zoomed out. The globe turns
116
+ into the flat map as the map zooms in. `connectMap` hides markers on the far side
117
+ of the globe, and a keyboard user who moves to one turns the globe to show it.
118
+ Pass `globe: false` for a flat map at every zoom. MapLibre 4 has no globe, so
119
+ pass it there too.
120
+
87
121
  `followTheme(map, frame, style)` restyles the map when your theme changes. It
88
122
  watches for a new color mode, class, or theme value on the frame or its
89
123
  ancestors, and for a change in the system's light or dark setting. If your page
@@ -94,6 +128,42 @@ changes its theme another way, such as by replacing a stylesheet, call
94
128
  a frame or two after the page loads. If the colors never become available, it
95
129
  reports which one is missing.
96
130
 
131
+ ## Draw the map before it loads
132
+
133
+ `mapSnapshot(view)` draws the map on your server as an SVG, from the same tiles
134
+ and in the same colors as `mapLibreStyle`. Put it in the frame after the element
135
+ MapLibre draws in, and the page shows a map from its first paint. `connectMap`
136
+ fades it out once MapLibre has drawn its tiles.
137
+
138
+ ```js
139
+ import { mapSnapshot } from '@fusion.dev/helix-map/snapshot'
140
+
141
+ const view = {
142
+ center: { lat: 30.27, lng: -97.74 },
143
+ height: 700,
144
+ pitch: 45,
145
+ width: 1200,
146
+ zoom: 14,
147
+ }
148
+ const snapshot = await mapSnapshot(view)
149
+ // Inside helix-map, after <div id="map"></div>, write the snapshot's markup.
150
+ ```
151
+
152
+ Give MapLibre the same `center`, `zoom`, `pitch`, and `bearing`, and the snapshot
153
+ lines up with the map that replaces it. `width` and `height` are the box it is
154
+ drawn for, and a smaller box shows its middle. A snapshot draws the land, water,
155
+ parks, buildings, and roads, and leaves the labels to MapLibre. Its colors are
156
+ your theme's tokens, so it is light or dark with the page and follows a theme
157
+ change. It resolves to an empty string when the tiles cannot be read.
158
+
159
+ In a framework that renders the markup for you, such as React, put the snapshot
160
+ in an element that is a direct child of the frame and has the
161
+ `data-helix-map-snapshot` attribute. `connectMap` hides that element, and leaves
162
+ removing it to your framework.
163
+
164
+ A snapshot is a flat map. A map zoomed out past about 6 is a globe in MapLibre,
165
+ so draw snapshots of city and street views.
166
+
97
167
  ## What you can add to a map
98
168
 
99
169
  | Element | What it adds |
@@ -103,13 +173,23 @@ reports which one is missing.
103
173
  | `helix-map-area` | A shape, such as a delivery zone |
104
174
  | `helix-map-position` | A moving point or arrow, such as a vehicle |
105
175
  | `helix-map-points` | Thousands of places loaded from GeoJSON |
176
+ | `helix-map-buildings` | The map's buildings, raised to their heights in 3D |
177
+ | `helix-map-raster` | Map tiles over the map, such as weather radar or satellite imagery |
178
+ | `helix-map-terrain` | Hills and mountains, shaded and raised in 3D |
179
+ | `helix-map-contours` | Contour lines, each at one height |
180
+ | `helix-map-landcover` | What covers the ground: forest, grass, farmland, sand, rock, and ice |
106
181
 
107
182
  Each element takes `tone`, such as `primary` or `danger`, for its color.
108
183
 
109
184
  ### Markers
110
185
 
111
186
  ```html
112
- <helix-map-marker label="Texas Capitol" lat="30.2747" lng="-97.7405" shape="ring">
187
+ <helix-map-marker
188
+ label="Texas Capitol"
189
+ lat="30.2747"
190
+ lng="-97.7405"
191
+ shape="ring"
192
+ >
113
193
  <span slot="icon">B</span>
114
194
  </helix-map-marker>
115
195
  ```
@@ -140,8 +220,8 @@ panel, pass `clusterZoom: false` to `connectMap` and listen for
140
220
 
141
221
  ```html
142
222
  <helix-map-route
143
- label="Depot to Mission"
144
223
  description="4.2 km"
224
+ label="Depot to Mission"
145
225
  points="37.7955,-122.3937 37.7644,-122.427"
146
226
  progress="0.4"
147
227
  ></helix-map-route>
@@ -160,12 +240,12 @@ service such as OSRM or Valhalla.
160
240
 
161
241
  ```html
162
242
  <helix-map-position
243
+ accuracy="30"
244
+ description="Two stops away"
245
+ heading="90"
163
246
  label="Van 12"
164
247
  lat="37.78"
165
248
  lng="-122.41"
166
- heading="90"
167
- accuracy="30"
168
- description="Two stops away"
169
249
  ></helix-map-position>
170
250
  ```
171
251
 
@@ -177,7 +257,11 @@ readers announce its `description` when it changes, at most once every
177
257
  ### Thousands of points
178
258
 
179
259
  ```html
180
- <helix-map-points label="Food and drink" src="/places.geojson" cluster></helix-map-points>
260
+ <helix-map-points
261
+ cluster
262
+ label="Food and drink"
263
+ src="/places.geojson"
264
+ ></helix-map-points>
181
265
  ```
182
266
 
183
267
  Use `helix-map-points` for more places than markers can handle. MapLibre draws
@@ -187,16 +271,176 @@ count zooms in to it. Pressing a point sends `helix-activate` from the layer
187
271
  with the point's id, or with the property named by `name-key`. Leaflet draws
188
272
  each point on its own, which works for hundreds of points.
189
273
 
274
+ ### Buildings in 3D
275
+
276
+ ```html
277
+ <helix-map-buildings></helix-map-buildings>
278
+ ```
279
+
280
+ `helix-map-buildings` raises the buildings in the map's tiles to the heights the
281
+ tiles record, in your theme's raised surface color. Set `tone` to color them by
282
+ meaning. The buildings appear from zoom 13. To see their height, tilt the map by
283
+ setting `pitch` when you create it:
284
+
285
+ ```js
286
+ const map = new maplibregl.Map({ container: 'map', pitch: 55, style, zoom: 15.5 })
287
+ ```
288
+
289
+ To let users tilt the map, add `tilt` to the frame's `controls`:
290
+
291
+ ```html
292
+ <helix-map
293
+ controls="zoom compass tilt fullscreen"
294
+ label="Downtown Austin in 3D"
295
+ >
296
+ ```
297
+
298
+ The 3D button is a toggle. Pressed, it tilts the map 50 degrees toward the
299
+ horizon and raises the buildings. Pressed again, it makes the map flat, and the
300
+ buildings are the map's own flat footprints. Raised terrain lies flat with them,
301
+ and keeps its shading. The compass's needle points north as the map turns, and
302
+ pressing the compass turns the map back to north.
303
+
304
+ Leaflet draws maps flat and does not rotate, so a Leaflet map shows no
305
+ buildings, and the compass and the 3D button do nothing.
306
+
307
+ ### Weather and other tile overlays
308
+
309
+ ```html
310
+ <helix-map-raster
311
+ attribution="Radar from Example Weather"
312
+ frames="https://tiles.example/radar-50m/{z}/{x}/{y}.png https://tiles.example/radar-now/{z}/{x}/{y}.png"
313
+ label="Weather radar"
314
+ ></helix-map-raster>
315
+ ```
316
+
317
+ `helix-map-raster` draws map tiles over the land and roads, and under your
318
+ routes, areas, and place names. Set `src` to one tile URL, or `frames` to
319
+ several, and set `playing` to show the frames in order, `interval` milliseconds
320
+ each. Every frame's tiles load once, so the loop plays without a blank frame.
321
+
322
+ - Put the tile provider's credit in `attribution`. The frame shows it beside
323
+ the map's credit.
324
+ - The frames do not play while the user has asked for reduced motion.
325
+ - Content that moves for more than five seconds needs a way to pause it, so
326
+ give `playing` a control on your page.
327
+
328
+ ### Satellite imagery and map types
329
+
330
+ ```html
331
+ <helix-map-raster
332
+ attribution="Imagery from USGS The National Map"
333
+ ground
334
+ label="Satellite imagery"
335
+ max-zoom="16"
336
+ opacity="1"
337
+ src="https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}"
338
+ ></helix-map-raster>
339
+ ```
340
+
341
+ Set `ground` on `helix-map-raster` to make its tiles the map's imagery. Imagery
342
+ is a map type, which the frame's `map-type` attribute chooses:
343
+
344
+ - Absent, the Standard map: your themed map, without the imagery.
345
+ - `hybrid`: the imagery in place of the map's land, under its roads and names.
346
+ - `satellite`: the imagery alone, without the roads and names.
347
+
348
+ With `layers` in the frame's `controls`, the layers menu opens with a card for
349
+ each map type, showing a picture of the map in it. Set `max-zoom` to the deepest
350
+ zoom your provider has tiles for, and the map enlarges those tiles when a user
351
+ zooms in further.
352
+
353
+ The imagery above is from the U.S. Geological Survey. It is in the public domain
354
+ and covers the United States. Some providers put `{y}` before `{x}` in their
355
+ tile URLs, as this one does.
356
+
357
+ ### Terrain
358
+
359
+ ```html
360
+ <helix-map-terrain
361
+ attribution="Elevation from 3DEP and SRTM data, courtesy of the U.S. Geological Survey"
362
+ max-zoom="15"
363
+ raised
364
+ src="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"
365
+ ></helix-map-terrain>
366
+ ```
367
+
368
+ `helix-map-terrain` shades the land by its slopes, so hills and valleys show on a
369
+ flat map. Set `raised` to raise the ground to its real height as well, and tilt
370
+ the map to see it. Set `exaggeration` to raise it more than its real height,
371
+ such as `1.5`. Routes, areas, and buildings lie on the raised ground.
372
+
373
+ The elevation tiles above are Terrain Tiles on AWS, which are free to use and
374
+ cover the world. Their tiles store heights in the `terrarium` encoding, which is
375
+ the default. For tiles in the Mapbox encoding, set `encoding="mapbox"`. Credit
376
+ the sources your map shows: in the United States, the U.S. Geological Survey.
377
+
378
+ Leaflet draws maps flat, so a Leaflet map shows no terrain.
379
+
380
+ ### Contour lines
381
+
382
+ ```html
383
+ <helix-map-contours
384
+ max-zoom="15"
385
+ src="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"
386
+ unit="feet"
387
+ ></helix-map-contours>
388
+ ```
389
+
390
+ `helix-map-contours` draws lines of equal height from the same elevation tiles
391
+ as terrain. The lines are closer together as the map zooms in, from 500 meters
392
+ apart over a region to 5 meters at street level. Every fifth line is heavier and
393
+ labeled with its height, in meters, or in feet with `unit="feet"`. They show
394
+ from zoom 9, and lie on the ground when it is raised.
395
+
396
+ ### Land cover
397
+
398
+ ```html
399
+ <helix-map-landcover></helix-map-landcover>
400
+ ```
401
+
402
+ `helix-map-landcover` colors the ground by what covers it: forest and grass in
403
+ greens, farmland in wheat, wetland in teal, sand in tan, rock in gray, and ice
404
+ in pale blue. Each color is mixed into your theme's land color. It draws over
405
+ parks and under water and roads, so a park shows its meadows and forests.
406
+
407
+ ### Turn layers on and off
408
+
409
+ ```html
410
+ <helix-map
411
+ controls="zoom compass layers fullscreen"
412
+ label="Downtown Austin"
413
+ >
414
+ ```
415
+
416
+ Add `layers` to the frame's `controls` for a layers button. It opens a menu with
417
+ a tile for each layer: a picture of what the layer draws, and its `label`. A
418
+ tile is lit while its layer is shown. Pressing a tile sets its layer's `hidden`
419
+ attribute, and `connectMap` does not draw a hidden layer. Write `hidden` on a
420
+ layer to start it turned off.
421
+
422
+ Give layers the same `group` to show them as one tile, such as a route and the
423
+ dotted legs at its ends. The tile takes the name of the first layer in the
424
+ group, and shows or hides every layer in it. Keep labels short, such as
425
+ "Walking route", and put the rest in `description`, which screen readers read
426
+ after the label.
427
+
190
428
  ## Keyboard and screen readers
191
429
 
192
430
  - The frame is one tab stop. Arrow keys pan the map, and the plus and minus keys
193
- zoom it.
431
+ zoom it. Shift with Left or Right rotates the map, and Shift with Up or Down
432
+ tilts it.
194
433
  - The markers are one tab stop. Arrow keys move between them in the order you
195
434
  wrote them. The map pans to show a marker that is off screen.
196
435
  - A points layer is one tab stop over the points and counts in view. Arrow keys
197
436
  move top to bottom and along each line. Enter on a count zooms in to it.
198
- - Screen readers find routes, areas, and points layers in a list inside the
199
- frame, named by their `label` and `description`.
437
+ - Screen readers find the map's shown layers in a list inside the frame, named
438
+ by their `label` and `description`.
439
+ - With a pointer, dragging is the only way to move and turn the map. Where your
440
+ map has to work without dragging, as WCAG 2.2 asks at level AA, add `pan` and
441
+ `rotate` to `controls` for buttons around the compass that move and turn it.
442
+ - In the layers menu, Tab moves between the tiles, Space or Enter turns a layer
443
+ on or off, and Escape closes the menu.
200
444
 
201
445
  ## Write a driver
202
446
 
@@ -216,7 +460,8 @@ animation. Each optional method turns on a feature:
216
460
  | `layers` | Drawing routes, areas, and points |
217
461
  | `credits` | The map credit in the frame's footer |
218
462
  | `silenceKeyboard`, `focusTarget`, `replaceZoom` | Using the frame's keys and zoom buttons |
219
- | `bearing` | Arrows that stay correct when the map is rotated |
463
+ | `bearing` | Arrows that stay correct when the map is rotated, and the Face north arrow |
464
+ | `rotate`, `tilt` | The rotate, Face north, and tilt buttons and keys |
220
465
 
221
466
  Without `project`, markers stay hidden. To animate a move your page makes
222
467
  itself, read the same motion with `motionOf(element, pace)`.