@fusion.dev/helix-docs 0.105.0 → 0.106.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.
- package/content/iconography.mdx +7 -7
- package/content/maps.mdx +223 -14
- package/content/metrics.mdx +223 -223
- package/dist/sources.generated.js +453 -244
- package/package.json +3 -3
package/content/iconography.mdx
CHANGED
|
@@ -10,12 +10,12 @@ title: Iconography
|
|
|
10
10
|
<helix-icon name="trash"></helix-icon>
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Helix has
|
|
14
|
-
weight. We keep Phosphor's own geometry. Rescaling to a 24 box
|
|
15
|
-
optical weight of every glyph, and the set would stop matching
|
|
16
|
-
the bold weight because Phosphor's regular weight is a
|
|
17
|
-
medium weight of Helix text. An icon that looks lighter than
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
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
|
|
@@ -103,13 +137,23 @@ reports which one is missing.
|
|
|
103
137
|
| `helix-map-area` | A shape, such as a delivery zone |
|
|
104
138
|
| `helix-map-position` | A moving point or arrow, such as a vehicle |
|
|
105
139
|
| `helix-map-points` | Thousands of places loaded from GeoJSON |
|
|
140
|
+
| `helix-map-buildings` | The map's buildings, raised to their heights in 3D |
|
|
141
|
+
| `helix-map-raster` | Map tiles over the map, such as weather radar or satellite imagery |
|
|
142
|
+
| `helix-map-terrain` | Hills and mountains, shaded and raised in 3D |
|
|
143
|
+
| `helix-map-contours` | Contour lines, each at one height |
|
|
144
|
+
| `helix-map-landcover` | What covers the ground: forest, grass, farmland, sand, rock, and ice |
|
|
106
145
|
|
|
107
146
|
Each element takes `tone`, such as `primary` or `danger`, for its color.
|
|
108
147
|
|
|
109
148
|
### Markers
|
|
110
149
|
|
|
111
150
|
```html
|
|
112
|
-
<helix-map-marker
|
|
151
|
+
<helix-map-marker
|
|
152
|
+
label="Texas Capitol"
|
|
153
|
+
lat="30.2747"
|
|
154
|
+
lng="-97.7405"
|
|
155
|
+
shape="ring"
|
|
156
|
+
>
|
|
113
157
|
<span slot="icon">B</span>
|
|
114
158
|
</helix-map-marker>
|
|
115
159
|
```
|
|
@@ -140,8 +184,8 @@ panel, pass `clusterZoom: false` to `connectMap` and listen for
|
|
|
140
184
|
|
|
141
185
|
```html
|
|
142
186
|
<helix-map-route
|
|
143
|
-
label="Depot to Mission"
|
|
144
187
|
description="4.2 km"
|
|
188
|
+
label="Depot to Mission"
|
|
145
189
|
points="37.7955,-122.3937 37.7644,-122.427"
|
|
146
190
|
progress="0.4"
|
|
147
191
|
></helix-map-route>
|
|
@@ -160,12 +204,12 @@ service such as OSRM or Valhalla.
|
|
|
160
204
|
|
|
161
205
|
```html
|
|
162
206
|
<helix-map-position
|
|
207
|
+
accuracy="30"
|
|
208
|
+
description="Two stops away"
|
|
209
|
+
heading="90"
|
|
163
210
|
label="Van 12"
|
|
164
211
|
lat="37.78"
|
|
165
212
|
lng="-122.41"
|
|
166
|
-
heading="90"
|
|
167
|
-
accuracy="30"
|
|
168
|
-
description="Two stops away"
|
|
169
213
|
></helix-map-position>
|
|
170
214
|
```
|
|
171
215
|
|
|
@@ -177,7 +221,11 @@ readers announce its `description` when it changes, at most once every
|
|
|
177
221
|
### Thousands of points
|
|
178
222
|
|
|
179
223
|
```html
|
|
180
|
-
<helix-map-points
|
|
224
|
+
<helix-map-points
|
|
225
|
+
cluster
|
|
226
|
+
label="Food and drink"
|
|
227
|
+
src="/places.geojson"
|
|
228
|
+
></helix-map-points>
|
|
181
229
|
```
|
|
182
230
|
|
|
183
231
|
Use `helix-map-points` for more places than markers can handle. MapLibre draws
|
|
@@ -187,16 +235,176 @@ count zooms in to it. Pressing a point sends `helix-activate` from the layer
|
|
|
187
235
|
with the point's id, or with the property named by `name-key`. Leaflet draws
|
|
188
236
|
each point on its own, which works for hundreds of points.
|
|
189
237
|
|
|
238
|
+
### Buildings in 3D
|
|
239
|
+
|
|
240
|
+
```html
|
|
241
|
+
<helix-map-buildings></helix-map-buildings>
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
`helix-map-buildings` raises the buildings in the map's tiles to the heights the
|
|
245
|
+
tiles record, in your theme's raised surface color. Set `tone` to color them by
|
|
246
|
+
meaning. The buildings appear from zoom 13. To see their height, tilt the map by
|
|
247
|
+
setting `pitch` when you create it:
|
|
248
|
+
|
|
249
|
+
```js
|
|
250
|
+
const map = new maplibregl.Map({ container: 'map', pitch: 55, style, zoom: 15.5 })
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
To let users tilt the map, add `tilt` to the frame's `controls`:
|
|
254
|
+
|
|
255
|
+
```html
|
|
256
|
+
<helix-map
|
|
257
|
+
controls="zoom compass tilt fullscreen"
|
|
258
|
+
label="Downtown Austin in 3D"
|
|
259
|
+
>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The 3D button is a toggle. Pressed, it tilts the map 50 degrees toward the
|
|
263
|
+
horizon and raises the buildings. Pressed again, it makes the map flat, and the
|
|
264
|
+
buildings are the map's own flat footprints. Raised terrain lies flat with them,
|
|
265
|
+
and keeps its shading. The compass's needle points north as the map turns, and
|
|
266
|
+
pressing the compass turns the map back to north.
|
|
267
|
+
|
|
268
|
+
Leaflet draws maps flat and does not rotate, so a Leaflet map shows no
|
|
269
|
+
buildings, and the compass and the 3D button do nothing.
|
|
270
|
+
|
|
271
|
+
### Weather and other tile overlays
|
|
272
|
+
|
|
273
|
+
```html
|
|
274
|
+
<helix-map-raster
|
|
275
|
+
attribution="Radar from Example Weather"
|
|
276
|
+
frames="https://tiles.example/radar-50m/{z}/{x}/{y}.png https://tiles.example/radar-now/{z}/{x}/{y}.png"
|
|
277
|
+
label="Weather radar"
|
|
278
|
+
></helix-map-raster>
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
`helix-map-raster` draws map tiles over the land and roads, and under your
|
|
282
|
+
routes, areas, and place names. Set `src` to one tile URL, or `frames` to
|
|
283
|
+
several, and set `playing` to show the frames in order, `interval` milliseconds
|
|
284
|
+
each. Every frame's tiles load once, so the loop plays without a blank frame.
|
|
285
|
+
|
|
286
|
+
- Put the tile provider's credit in `attribution`. The frame shows it beside
|
|
287
|
+
the map's credit.
|
|
288
|
+
- The frames do not play while the user has asked for reduced motion.
|
|
289
|
+
- Content that moves for more than five seconds needs a way to pause it, so
|
|
290
|
+
give `playing` a control on your page.
|
|
291
|
+
|
|
292
|
+
### Satellite imagery and map types
|
|
293
|
+
|
|
294
|
+
```html
|
|
295
|
+
<helix-map-raster
|
|
296
|
+
attribution="Imagery from USGS The National Map"
|
|
297
|
+
ground
|
|
298
|
+
label="Satellite imagery"
|
|
299
|
+
max-zoom="16"
|
|
300
|
+
opacity="1"
|
|
301
|
+
src="https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}"
|
|
302
|
+
></helix-map-raster>
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Set `ground` on `helix-map-raster` to make its tiles the map's imagery. Imagery
|
|
306
|
+
is a map type, which the frame's `map-type` attribute chooses:
|
|
307
|
+
|
|
308
|
+
- Absent, the Standard map: your themed map, without the imagery.
|
|
309
|
+
- `hybrid`: the imagery in place of the map's land, under its roads and names.
|
|
310
|
+
- `satellite`: the imagery alone, without the roads and names.
|
|
311
|
+
|
|
312
|
+
With `layers` in the frame's `controls`, the layers menu opens with a card for
|
|
313
|
+
each map type, showing a picture of the map in it. Set `max-zoom` to the deepest
|
|
314
|
+
zoom your provider has tiles for, and the map enlarges those tiles when a user
|
|
315
|
+
zooms in further.
|
|
316
|
+
|
|
317
|
+
The imagery above is from the U.S. Geological Survey. It is in the public domain
|
|
318
|
+
and covers the United States. Some providers put `{y}` before `{x}` in their
|
|
319
|
+
tile URLs, as this one does.
|
|
320
|
+
|
|
321
|
+
### Terrain
|
|
322
|
+
|
|
323
|
+
```html
|
|
324
|
+
<helix-map-terrain
|
|
325
|
+
attribution="Elevation from 3DEP and SRTM data, courtesy of the U.S. Geological Survey"
|
|
326
|
+
max-zoom="15"
|
|
327
|
+
raised
|
|
328
|
+
src="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"
|
|
329
|
+
></helix-map-terrain>
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
`helix-map-terrain` shades the land by its slopes, so hills and valleys show on a
|
|
333
|
+
flat map. Set `raised` to raise the ground to its real height as well, and tilt
|
|
334
|
+
the map to see it. Set `exaggeration` to raise it more than its real height,
|
|
335
|
+
such as `1.5`. Routes, areas, and buildings lie on the raised ground.
|
|
336
|
+
|
|
337
|
+
The elevation tiles above are Terrain Tiles on AWS, which are free to use and
|
|
338
|
+
cover the world. Their tiles store heights in the `terrarium` encoding, which is
|
|
339
|
+
the default. For tiles in the Mapbox encoding, set `encoding="mapbox"`. Credit
|
|
340
|
+
the sources your map shows: in the United States, the U.S. Geological Survey.
|
|
341
|
+
|
|
342
|
+
Leaflet draws maps flat, so a Leaflet map shows no terrain.
|
|
343
|
+
|
|
344
|
+
### Contour lines
|
|
345
|
+
|
|
346
|
+
```html
|
|
347
|
+
<helix-map-contours
|
|
348
|
+
max-zoom="15"
|
|
349
|
+
src="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"
|
|
350
|
+
unit="feet"
|
|
351
|
+
></helix-map-contours>
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
`helix-map-contours` draws lines of equal height from the same elevation tiles
|
|
355
|
+
as terrain. The lines are closer together as the map zooms in, from 500 meters
|
|
356
|
+
apart over a region to 5 meters at street level. Every fifth line is heavier and
|
|
357
|
+
labeled with its height, in meters, or in feet with `unit="feet"`. They show
|
|
358
|
+
from zoom 9, and lie on the ground when it is raised.
|
|
359
|
+
|
|
360
|
+
### Land cover
|
|
361
|
+
|
|
362
|
+
```html
|
|
363
|
+
<helix-map-landcover></helix-map-landcover>
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
`helix-map-landcover` colors the ground by what covers it: forest and grass in
|
|
367
|
+
greens, farmland in wheat, wetland in teal, sand in tan, rock in gray, and ice
|
|
368
|
+
in pale blue. Each color is mixed into your theme's land color. It draws over
|
|
369
|
+
parks and under water and roads, so a park shows its meadows and forests.
|
|
370
|
+
|
|
371
|
+
### Turn layers on and off
|
|
372
|
+
|
|
373
|
+
```html
|
|
374
|
+
<helix-map
|
|
375
|
+
controls="zoom compass layers fullscreen"
|
|
376
|
+
label="Downtown Austin"
|
|
377
|
+
>
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
Add `layers` to the frame's `controls` for a layers button. It opens a menu with
|
|
381
|
+
a tile for each layer: a picture of what the layer draws, and its `label`. A
|
|
382
|
+
tile is lit while its layer is shown. Pressing a tile sets its layer's `hidden`
|
|
383
|
+
attribute, and `connectMap` does not draw a hidden layer. Write `hidden` on a
|
|
384
|
+
layer to start it turned off.
|
|
385
|
+
|
|
386
|
+
Give layers the same `group` to show them as one tile, such as a route and the
|
|
387
|
+
dotted legs at its ends. The tile takes the name of the first layer in the
|
|
388
|
+
group, and shows or hides every layer in it. Keep labels short, such as
|
|
389
|
+
"Walking route", and put the rest in `description`, which screen readers read
|
|
390
|
+
after the label.
|
|
391
|
+
|
|
190
392
|
## Keyboard and screen readers
|
|
191
393
|
|
|
192
394
|
- The frame is one tab stop. Arrow keys pan the map, and the plus and minus keys
|
|
193
|
-
zoom it.
|
|
395
|
+
zoom it. Shift with Left or Right rotates the map, and Shift with Up or Down
|
|
396
|
+
tilts it.
|
|
194
397
|
- The markers are one tab stop. Arrow keys move between them in the order you
|
|
195
398
|
wrote them. The map pans to show a marker that is off screen.
|
|
196
399
|
- A points layer is one tab stop over the points and counts in view. Arrow keys
|
|
197
400
|
move top to bottom and along each line. Enter on a count zooms in to it.
|
|
198
|
-
- Screen readers find
|
|
199
|
-
|
|
401
|
+
- Screen readers find the map's shown layers in a list inside the frame, named
|
|
402
|
+
by their `label` and `description`.
|
|
403
|
+
- With a pointer, dragging is the only way to move and turn the map. Where your
|
|
404
|
+
map has to work without dragging, as WCAG 2.2 asks at level AA, add `pan` and
|
|
405
|
+
`rotate` to `controls` for buttons around the compass that move and turn it.
|
|
406
|
+
- In the layers menu, Tab moves between the tiles, Space or Enter turns a layer
|
|
407
|
+
on or off, and Escape closes the menu.
|
|
200
408
|
|
|
201
409
|
## Write a driver
|
|
202
410
|
|
|
@@ -216,7 +424,8 @@ animation. Each optional method turns on a feature:
|
|
|
216
424
|
| `layers` | Drawing routes, areas, and points |
|
|
217
425
|
| `credits` | The map credit in the frame's footer |
|
|
218
426
|
| `silenceKeyboard`, `focusTarget`, `replaceZoom` | Using the frame's keys and zoom buttons |
|
|
219
|
-
| `bearing` | Arrows that stay correct when the map is rotated |
|
|
427
|
+
| `bearing` | Arrows that stay correct when the map is rotated, and the Face north arrow |
|
|
428
|
+
| `rotate`, `tilt` | The rotate, Face north, and tilt buttons and keys |
|
|
220
429
|
|
|
221
430
|
Without `project`, markers stay hidden. To animate a move your page makes
|
|
222
431
|
itself, read the same motion with `motionOf(element, pace)`.
|