@fusion.dev/helix-docs 0.106.0 → 0.108.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/maps.mdx CHANGED
@@ -128,6 +128,42 @@ changes its theme another way, such as by replacing a stylesheet, call
128
128
  a frame or two after the page loads. If the colors never become available, it
129
129
  reports which one is missing.
130
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
+
131
167
  ## What you can add to a map
132
168
 
133
169
  | Element | What it adds |
@@ -403,7 +403,7 @@ stripped column shows the bytes we removed.
403
403
  | `@fusion.dev/helix-icons` | 150,162 | 21 | 50,346 | `svgo` |
404
404
  | `@fusion.dev/helix-styles` | 102,108 | 6 | 0 | none |
405
405
  | `@fusion.dev/helix-theme` | 465,413 | 8 | 4,703 | none |
406
- | `@fusion.dev/helix` | 14,179,532 | 868 | 362,883 | `@fusion.dev/helix-core`, `@fusion.dev/helix-headless`, `@fusion.dev/helix-styles` |
406
+ | `@fusion.dev/helix` | 14,185,818 | 870 | 368,333 | `@fusion.dev/helix-core`, `@fusion.dev/helix-headless`, `@fusion.dev/helix-styles` |
407
407
 
408
408
  ## Not measured yet
409
409
 
@@ -112,14 +112,40 @@ In prose:
112
112
 
113
113
  See [Typography](./typography).
114
114
 
115
- If you control the Markdown renderer, map two elements to components, because
116
- HTML alone cannot hold what they need:
117
-
118
- - **Fenced code** to `helix-code-block`, with the fence's language as its `label`.
119
- A `<pre>` has no label or copy button.
120
- - **Alerts** such as `> [!WARNING]` to `helix-callout`. A `<blockquote>` has no
121
- tone. `NOTE` and `IMPORTANT` become `tone="info"`, `TIP` becomes `success`,
122
- `WARNING` becomes `warning`, and `CAUTION` becomes `danger`.
115
+ Two Markdown constructs need components, because HTML alone cannot hold what
116
+ they need:
117
+
118
+ - **Fenced code** becomes `helix-code-block`, with the fence's language as its
119
+ `label`. A `<pre>` has no label or copy button.
120
+ - **Alerts** such as `> [!WARNING]` become `helix-callout`. A `<blockquote>` has no
121
+ tone. `NOTE` becomes `tone="info"`, `TIP` becomes `success`, `WARNING` becomes
122
+ `warning`, and `CAUTION` becomes `danger`. `IMPORTANT` has no tone. Each
123
+ callout is headed by its kind, as GitHub shows it.
124
+
125
+ The `rehype` plugin from `@fusion.dev/helix/rehype` makes both changes in the
126
+ tree your Markdown library has already built. It parses nothing, so your
127
+ library, its dialect, and your sanitizing stay yours. Add it to any pipeline
128
+ that reaches rehype, such as `remark` with `remark-rehype`, `react-markdown`, or
129
+ MDX:
130
+
131
+ ```js
132
+ import rehypeHelix from '@fusion.dev/helix/rehype'
133
+
134
+ const html = await unified()
135
+ .use(remarkParse)
136
+ .use(remarkRehype)
137
+ .use(rehypeHelix)
138
+ .use(rehypeStringify)
139
+ .process(markdown)
140
+ ```
141
+
142
+ Code that a highlighter colored before the plugin ran keeps its colors. Pass
143
+ `fences: false` if your page draws its own code blocks, `alerts: false` to keep
144
+ alerts as quotes, and `headings` to name each kind in your page's language.
145
+
146
+ > [!NOTE]
147
+ > The plugin changes only these two constructs. If the Markdown comes from your
148
+ > users, sanitize it in your pipeline before the plugin runs.
123
149
 
124
150
  Prose spaces each component the same as the element it replaces.
125
151
 
@@ -2403,6 +2403,42 @@ changes its theme another way, such as by replacing a stylesheet, call
2403
2403
  a frame or two after the page loads. If the colors never become available, it
2404
2404
  reports which one is missing.
2405
2405
 
2406
+ ## Draw the map before it loads
2407
+
2408
+ \`mapSnapshot(view)\` draws the map on your server as an SVG, from the same tiles
2409
+ and in the same colors as \`mapLibreStyle\`. Put it in the frame after the element
2410
+ MapLibre draws in, and the page shows a map from its first paint. \`connectMap\`
2411
+ fades it out once MapLibre has drawn its tiles.
2412
+
2413
+ \`\`\`js
2414
+ import { mapSnapshot } from '@fusion.dev/helix-map/snapshot'
2415
+
2416
+ const view = {
2417
+ center: { lat: 30.27, lng: -97.74 },
2418
+ height: 700,
2419
+ pitch: 45,
2420
+ width: 1200,
2421
+ zoom: 14,
2422
+ }
2423
+ const snapshot = await mapSnapshot(view)
2424
+ // Inside helix-map, after <div id="map"></div>, write the snapshot's markup.
2425
+ \`\`\`
2426
+
2427
+ Give MapLibre the same \`center\`, \`zoom\`, \`pitch\`, and \`bearing\`, and the snapshot
2428
+ lines up with the map that replaces it. \`width\` and \`height\` are the box it is
2429
+ drawn for, and a smaller box shows its middle. A snapshot draws the land, water,
2430
+ parks, buildings, and roads, and leaves the labels to MapLibre. Its colors are
2431
+ your theme's tokens, so it is light or dark with the page and follows a theme
2432
+ change. It resolves to an empty string when the tiles cannot be read.
2433
+
2434
+ In a framework that renders the markup for you, such as React, put the snapshot
2435
+ in an element that is a direct child of the frame and has the
2436
+ \`data-helix-map-snapshot\` attribute. \`connectMap\` hides that element, and leaves
2437
+ removing it to your framework.
2438
+
2439
+ A snapshot is a flat map. A map zoomed out past about 6 is a globe in MapLibre,
2440
+ so draw snapshots of city and street views.
2441
+
2406
2442
  ## What you can add to a map
2407
2443
 
2408
2444
  | Element | What it adds |
@@ -3110,7 +3146,7 @@ stripped column shows the bytes we removed.
3110
3146
  | \`@fusion.dev/helix-icons\` | 150,162 | 21 | 50,346 | \`svgo\` |
3111
3147
  | \`@fusion.dev/helix-styles\` | 102,108 | 6 | 0 | none |
3112
3148
  | \`@fusion.dev/helix-theme\` | 465,413 | 8 | 4,703 | none |
3113
- | \`@fusion.dev/helix\` | 14,179,532 | 868 | 362,883 | \`@fusion.dev/helix-core\`, \`@fusion.dev/helix-headless\`, \`@fusion.dev/helix-styles\` |
3149
+ | \`@fusion.dev/helix\` | 14,185,818 | 870 | 368,333 | \`@fusion.dev/helix-core\`, \`@fusion.dev/helix-headless\`, \`@fusion.dev/helix-styles\` |
3114
3150
 
3115
3151
  ## Not measured yet
3116
3152
 
@@ -3858,14 +3894,40 @@ In prose:
3858
3894
 
3859
3895
  See [Typography](./typography).
3860
3896
 
3861
- If you control the Markdown renderer, map two elements to components, because
3862
- HTML alone cannot hold what they need:
3897
+ Two Markdown constructs need components, because HTML alone cannot hold what
3898
+ they need:
3899
+
3900
+ - **Fenced code** becomes \`helix-code-block\`, with the fence's language as its
3901
+ \`label\`. A \`<pre>\` has no label or copy button.
3902
+ - **Alerts** such as \`> [!WARNING]\` become \`helix-callout\`. A \`<blockquote>\` has no
3903
+ tone. \`NOTE\` becomes \`tone="info"\`, \`TIP\` becomes \`success\`, \`WARNING\` becomes
3904
+ \`warning\`, and \`CAUTION\` becomes \`danger\`. \`IMPORTANT\` has no tone. Each
3905
+ callout is headed by its kind, as GitHub shows it.
3906
+
3907
+ The \`rehype\` plugin from \`@fusion.dev/helix/rehype\` makes both changes in the
3908
+ tree your Markdown library has already built. It parses nothing, so your
3909
+ library, its dialect, and your sanitizing stay yours. Add it to any pipeline
3910
+ that reaches rehype, such as \`remark\` with \`remark-rehype\`, \`react-markdown\`, or
3911
+ MDX:
3912
+
3913
+ \`\`\`js
3914
+ import rehypeHelix from '@fusion.dev/helix/rehype'
3915
+
3916
+ const html = await unified()
3917
+ .use(remarkParse)
3918
+ .use(remarkRehype)
3919
+ .use(rehypeHelix)
3920
+ .use(rehypeStringify)
3921
+ .process(markdown)
3922
+ \`\`\`
3923
+
3924
+ Code that a highlighter colored before the plugin ran keeps its colors. Pass
3925
+ \`fences: false\` if your page draws its own code blocks, \`alerts: false\` to keep
3926
+ alerts as quotes, and \`headings\` to name each kind in your page's language.
3863
3927
 
3864
- - **Fenced code** to \`helix-code-block\`, with the fence's language as its \`label\`.
3865
- A \`<pre>\` has no label or copy button.
3866
- - **Alerts** such as \`> [!WARNING]\` to \`helix-callout\`. A \`<blockquote>\` has no
3867
- tone. \`NOTE\` and \`IMPORTANT\` become \`tone="info"\`, \`TIP\` becomes \`success\`,
3868
- \`WARNING\` becomes \`warning\`, and \`CAUTION\` becomes \`danger\`.
3928
+ > [!NOTE]
3929
+ > The plugin changes only these two constructs. If the Markdown comes from your
3930
+ > users, sanitize it in your pipeline before the plugin runs.
3869
3931
 
3870
3932
  Prose spaces each component the same as the element it replaces.
3871
3933
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fusion.dev/helix-docs",
3
3
  "description": "Versioned documentation content and registry for Helix.",
4
- "version": "0.106.0",
4
+ "version": "0.108.0",
5
5
  "license": "MIT",
6
6
  "author": "Ross Sheppard <ross.sheppard@fusion.dev>",
7
7
  "repository": {
@@ -36,8 +36,8 @@
36
36
  },
37
37
  "bugs": "https://github.com/project-fusion/fusion/issues",
38
38
  "devDependencies": {
39
- "@fusion.dev/helix-cem": "0.106.0",
40
- "@fusion.dev/helix-testing": "0.106.0",
39
+ "@fusion.dev/helix-cem": "0.108.0",
40
+ "@fusion.dev/helix-testing": "0.108.0",
41
41
  "@fusion.dev/scripts": "0.0.0-dev",
42
42
  "lit": "^3.2.1",
43
43
  "playwright": "^1.62.1"