@fusion.dev/helix-docs 0.143.0 → 0.145.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/accessibility.mdx +7 -0
- package/content/building-on-the-headless-tier.mdx +4 -1
- package/content/localization.mdx +12 -0
- package/content/metrics.mdx +224 -224
- package/content/overlays.mdx +31 -2
- package/content/recipes.mdx +24 -0
- package/content/sandbox.mdx +29 -13
- package/dist/sources.generated.js +331 -240
- package/package.json +9 -9
package/content/overlays.mdx
CHANGED
|
@@ -81,8 +81,15 @@ to the element that opened it. `Dialog` does this, and so does `Drawer` unless
|
|
|
81
81
|
you set `modal="false"`. The page behind a modal `Dialog` or `Drawer` does not
|
|
82
82
|
scroll while it is open.
|
|
83
83
|
|
|
84
|
-
`Popover`
|
|
85
|
-
panel,
|
|
84
|
+
Opening a `Popover` moves focus to the first control in its panel, or to the
|
|
85
|
+
panel where it holds none, and closing it from inside gives focus back to the
|
|
86
|
+
trigger. It does not trap focus unless you set `modal`, which keeps `Tab` in the
|
|
87
|
+
panel until it closes. When focus moves out of its trigger and its panel, the
|
|
88
|
+
popover closes.
|
|
89
|
+
|
|
90
|
+
Press F8 to move focus to the `Toast` stack, and press it again to go back.
|
|
91
|
+
Set `hotkey` on the stack to use another key. The stack's name says which key
|
|
92
|
+
it is.
|
|
86
93
|
|
|
87
94
|
The fields with a panel behave the same way:
|
|
88
95
|
|
|
@@ -91,10 +98,18 @@ The fields with a panel behave the same way:
|
|
|
91
98
|
leaves the field, and `Escape` returns focus to the field.
|
|
92
99
|
- Opening one of those panels from its trigger, or with `ArrowDown`, moves
|
|
93
100
|
focus into the panel.
|
|
101
|
+
- Inside one of those panels, `Tab` moves between the panel's controls and
|
|
102
|
+
does not leave the panel.
|
|
94
103
|
|
|
95
104
|
**A tooltip never takes focus.** A tooltip only describes a control, so it
|
|
96
105
|
cannot contain a button. For something with a button in it, use a `Popover`.
|
|
97
106
|
|
|
107
|
+
A tooltip describes its trigger by itself, whether it wraps the trigger or
|
|
108
|
+
names it with `for`. A Helix trigger is described as soon as it has rendered.
|
|
109
|
+
A plain element in your markup is described the first time a reader points at
|
|
110
|
+
it or focuses it, so the link is never written into markup your server sent.
|
|
111
|
+
Write `aria-describedby` yourself to have the link in the server's markup.
|
|
112
|
+
|
|
98
113
|
## Keep an overlay open
|
|
99
114
|
|
|
100
115
|
An overlay sends `helix-before-close` before it closes. Cancel the event to keep
|
|
@@ -118,6 +133,20 @@ on the `overlay` and `display` properties, which allows an exit animation on an
|
|
|
118
133
|
element the browser is about to remove from the top layer. Every overlay
|
|
119
134
|
responds to `prefers-reduced-motion`.
|
|
120
135
|
|
|
136
|
+
`Dialog` and `Drawer` also say where they are in the journey:
|
|
137
|
+
`:state(entering)` holds from the moment they open until their entrance has
|
|
138
|
+
finished, and `:state(exiting)` from the moment they close until their exit has
|
|
139
|
+
finished. Select on them to draw an entrance or an exit of your own.
|
|
140
|
+
|
|
141
|
+
## Swiping an overlay away
|
|
142
|
+
|
|
143
|
+
A touch or a pen swipes a `Drawer` toward the edge it came from, and a `Toast`
|
|
144
|
+
message toward the end of the line. A swipe past halfway, or a quick one, closes
|
|
145
|
+
it through the same cancelable request as its close control. A `Drawer` with
|
|
146
|
+
`snap-points` comes to rest at the nearest point, such as half open. In a
|
|
147
|
+
`Lightbox`, a swipe across the viewer shows the next or the previous item. A
|
|
148
|
+
mouse never swipes, because dragging with a mouse selects text.
|
|
149
|
+
|
|
121
150
|
## Choose an overlay
|
|
122
151
|
|
|
123
152
|
| Component | Use it for |
|
package/content/recipes.mdx
CHANGED
|
@@ -62,6 +62,30 @@ loading state, no pressed state, and no `type="submit"` handling.
|
|
|
62
62
|
navigation, where an underline on every row would distract. If a link opens a
|
|
63
63
|
new tab or window, say so in the link text, so it does not surprise your users.
|
|
64
64
|
|
|
65
|
+
## Navigation items
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<helix-navigation label="Sections">
|
|
69
|
+
<a
|
|
70
|
+
aria-current="page"
|
|
71
|
+
href="/guide"
|
|
72
|
+
>Guide</a>
|
|
73
|
+
<a href="/api">API</a>
|
|
74
|
+
</helix-navigation>
|
|
75
|
+
<button data-navigation-item>Menu</button>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
A link inside `helix-navigation` is styled by the page's stylesheet, because the
|
|
79
|
+
page's styles reach a slotted link before the component's do.
|
|
80
|
+
`data-navigation-item` gives the same look to an element outside a navigation
|
|
81
|
+
bar. Two custom properties set the text color:
|
|
82
|
+
|
|
83
|
+
- `--navigation-item-color` colors every destination except the current one.
|
|
84
|
+
- `--navigation-item-current-color` colors the destination marked
|
|
85
|
+
`aria-current="page"`.
|
|
86
|
+
|
|
87
|
+
Set them on `helix-navigation` or on any element that contains it.
|
|
88
|
+
|
|
65
89
|
## Surfaces and layout
|
|
66
90
|
|
|
67
91
|
```html
|
package/content/sandbox.mdx
CHANGED
|
@@ -72,6 +72,15 @@ In a source pane, Tab inserts two spaces. Shift+Tab moves focus back, and
|
|
|
72
72
|
Escape then Tab moves it forward. The field's description says this to a
|
|
73
73
|
screen reader.
|
|
74
74
|
|
|
75
|
+
Each request has a notification once it is applied: `helix-edit` after
|
|
76
|
+
`helix-before-edit`, `helix-split` after `helix-before-split`, and
|
|
77
|
+
`helix-panel-resize` after `helix-before-panel-resize`. Listen for these to
|
|
78
|
+
store the arrangement or the source.
|
|
79
|
+
|
|
80
|
+
Set `controls` on `helix-sandbox-terminal` for a clear button and a level
|
|
81
|
+
filter above the log. Without them, `clear()` empties the log, and `level`
|
|
82
|
+
hides the quieter lines.
|
|
83
|
+
|
|
75
84
|
## The frame document
|
|
76
85
|
|
|
77
86
|
`helix-sandbox-preview` loads `src` into a sandboxed frame. You provide that
|
|
@@ -94,9 +103,13 @@ its own frame, and only from an opaque origin, so the frame keeps the sandbox
|
|
|
94
103
|
it was given. The types are exported from `@fusion.dev/helix/sandbox` as
|
|
95
104
|
`PreviewMessage` and its members.
|
|
96
105
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
`servePreview` from `@fusion.dev/helix/sandbox` is that protocol, written for
|
|
107
|
+
you. Call it once in the frame document, after your elements are defined. It
|
|
108
|
+
writes each render into `#preview-root`, runs the example's scripts, relays
|
|
109
|
+
its console, reports its height and its presses, and adds the rules for the
|
|
110
|
+
four layouts. A frame follows. `/helix.css` is the stylesheet from
|
|
111
|
+
`@fusion.dev/helix-styles`, and `/frame.js` is a classic script you bundle,
|
|
112
|
+
for the reason under "How the preview is isolated":
|
|
100
113
|
|
|
101
114
|
```html
|
|
102
115
|
<!doctype html>
|
|
@@ -104,21 +117,24 @@ registers your elements, for the reason under "How the preview is isolated".
|
|
|
104
117
|
href="/helix.css"
|
|
105
118
|
rel="stylesheet"
|
|
106
119
|
>
|
|
120
|
+
<div id="preview-root"></div>
|
|
107
121
|
<script
|
|
108
122
|
defer
|
|
109
|
-
src="/
|
|
123
|
+
src="/frame.js"
|
|
110
124
|
></script>
|
|
111
|
-
<style id="example-styles"></style>
|
|
112
|
-
<script defer>
|
|
113
|
-
addEventListener('message', ({ data }) => {
|
|
114
|
-
if (data?.type !== 'helix-preview-render') return
|
|
115
|
-
document.getElementById('example-styles').textContent = data.styles
|
|
116
|
-
document.body.innerHTML = data.source
|
|
117
|
-
})
|
|
118
|
-
parent.postMessage({ type: 'helix-preview-ready' }, '*')
|
|
119
|
-
</script>
|
|
120
125
|
```
|
|
121
126
|
|
|
127
|
+
```ts
|
|
128
|
+
// frame.ts, bundled to /frame.js as a classic script
|
|
129
|
+
import '@fusion.dev/helix' // registers every family, because an example can use any of them
|
|
130
|
+
import { servePreview } from '@fusion.dev/helix/sandbox'
|
|
131
|
+
|
|
132
|
+
servePreview()
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Pass `onReplace` to take down what an example mounted before the next one
|
|
136
|
+
replaces it, and `onRender` to act after each render, such as mounting a map.
|
|
137
|
+
|
|
122
138
|
## Console output from the example
|
|
123
139
|
|
|
124
140
|
Logs from the example appear in the console panel. Logs from the page around it
|