@fusion.dev/helix-docs 0.215.2 → 0.216.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/building-on-the-headless-tier.mdx +4 -3
- package/content/diagnostics.mdx +2 -0
- package/content/metrics.mdx +262 -254
- package/content/sandbox.mdx +20 -0
- package/content/undo.mdx +72 -0
- package/dist/pages.generated.js +6 -0
- package/dist/sources.generated.js +361 -257
- package/package.json +12 -12
package/content/sandbox.mdx
CHANGED
|
@@ -120,6 +120,26 @@ over a package of the same name. The preview loads its document again when one
|
|
|
120
120
|
of them changes, because a browser reads an import map only as a document
|
|
121
121
|
starts. A `src` document declares its own import map.
|
|
122
122
|
|
|
123
|
+
A module pane in TypeScript or JSX is compiled before the frame loads it. The
|
|
124
|
+
compiler runs in a worker, which the preview starts from a `blob:` address, and
|
|
125
|
+
loads from the `cdn`. A page whose Content Security Policy refuses `blob:`
|
|
126
|
+
workers, as `worker-src 'self'` does, serves the worker as a file instead. Copy
|
|
127
|
+
`@fusion.dev/helix/sandbox/compile-worker.js` to the page's own origin, and
|
|
128
|
+
give its address to `registerCompilerWorker` before the first preview compiles:
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
import { registerCompilerWorker } from '@fusion.dev/helix/sandbox'
|
|
132
|
+
|
|
133
|
+
registerCompilerWorker('/sandbox/compile-worker.js')
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
A copied file does not update with the package. Where a release changes the
|
|
137
|
+
messages the worker and the page exchange, the console warns that the file is
|
|
138
|
+
from another release and names the address to copy it to again.
|
|
139
|
+
|
|
140
|
+
In both cases the policy's `script-src` names the `cdn`'s host, which the
|
|
141
|
+
compiler and the packages load from.
|
|
142
|
+
|
|
123
143
|
## Editing keys
|
|
124
144
|
|
|
125
145
|
In a source pane, Tab inserts two spaces. Shift+Tab moves focus back, and
|
package/content/undo.mdx
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Do an action at once and offer to undo it from a toast, in place of asking first.
|
|
3
|
+
section: Essentials
|
|
4
|
+
title: Undo an action from a toast
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Undo an action from a toast
|
|
8
|
+
|
|
9
|
+
An action a reader can take back does not need a confirmation dialog. Do the
|
|
10
|
+
action at once, then show a toast that offers to undo it. The reader who meant
|
|
11
|
+
it loses no time, and the reader who did not has a few seconds to take it back.
|
|
12
|
+
|
|
13
|
+
## Show the toast after the action
|
|
14
|
+
|
|
15
|
+
Call `undoable()` on a `Toast` region after the action, with what to do if the
|
|
16
|
+
reader undoes it:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
const stack = document.querySelector('helix-toast')
|
|
20
|
+
|
|
21
|
+
archive(file)
|
|
22
|
+
stack.undoable(`Archived ${file.name}`, {
|
|
23
|
+
undo: () => restore(file),
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The message holds an Undo button and shows for 8 seconds. While it shows:
|
|
28
|
+
|
|
29
|
+
- Command+Z, or Control+Z on Windows and Linux, undoes the newest one, unless
|
|
30
|
+
focus is in a text field, which keeps the key for its own undo, or the app
|
|
31
|
+
handled the key first and called `preventDefault()`.
|
|
32
|
+
- A pointer or focus in the stack pauses its timer.
|
|
33
|
+
- A screen reader hears the message and then which keys undo it.
|
|
34
|
+
- The shortcut overlay and its sheet list the key.
|
|
35
|
+
|
|
36
|
+
An app with an undo of its own on those keys, such as a canvas or an editor,
|
|
37
|
+
sets `undo-keys=""` on the region. The Undo button stays, and the keys stay
|
|
38
|
+
the app's.
|
|
39
|
+
|
|
40
|
+
## Hold back what cannot be taken back
|
|
41
|
+
|
|
42
|
+
Where the action cannot be reversed once it has happened, such as deleting a
|
|
43
|
+
record on a server, do it when the message closes. Remove the item from the
|
|
44
|
+
page at once, and pass `commit`:
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
row.hidden = true
|
|
48
|
+
const result = await stack.undoable('Deleted 3 files', {
|
|
49
|
+
commit: () => deleteOnServer(ids),
|
|
50
|
+
undo: () => (row.hidden = false),
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`undoable()` returns a promise that settles to `undone` or `kept`.
|
|
55
|
+
|
|
56
|
+
A message that never closes is kept as well: `commit` runs when the region
|
|
57
|
+
leaves the page, such as on a route change, and when the page is hidden to be
|
|
58
|
+
closed or reloaded. A browser can end a page without telling it, so a server
|
|
59
|
+
that holds a deletion back should also finish it on a timeout of its own.
|
|
60
|
+
|
|
61
|
+
## Keep a confirmation where an undo cannot help
|
|
62
|
+
|
|
63
|
+
| Action | Use |
|
|
64
|
+
|---|---|
|
|
65
|
+
| Archive, move, rename, reorder, or change a setting | Undo toast |
|
|
66
|
+
| Delete to a trash, or delete held back until the message closes | Undo toast |
|
|
67
|
+
| Delete with no way back, such as emptying the trash | Confirmation dialog |
|
|
68
|
+
| Send, publish, invite, or pay | Confirmation dialog |
|
|
69
|
+
|
|
70
|
+
An action that reaches another person or leaves the app cannot be taken back
|
|
71
|
+
from a toast, because it has already happened somewhere you do not control.
|
|
72
|
+
Ask first with a `Dialog` with `alert`.
|
package/dist/pages.generated.js
CHANGED
|
@@ -275,6 +275,12 @@ export const docPages = [
|
|
|
275
275
|
slug: 'typography',
|
|
276
276
|
title: 'Typography',
|
|
277
277
|
},
|
|
278
|
+
{
|
|
279
|
+
description: 'Do an action at once and offer to undo it from a toast, in place of asking first.',
|
|
280
|
+
section: 'Essentials',
|
|
281
|
+
slug: 'undo',
|
|
282
|
+
title: 'Undo an action from a toast',
|
|
283
|
+
},
|
|
278
284
|
{
|
|
279
285
|
description: 'The rules an agent follows to write Helix code, and the five mistakes that look like Helix bugs.',
|
|
280
286
|
parent: 'coding-agents',
|