actual-css 0.16.0 → 0.16.1
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/CHANGELOG.md +14 -0
- package/components.json +2 -1
- package/dist/actual.full.css +17 -6
- package/dist/actual.full.js +1 -1
- package/dist/actual.full.min.css +1 -1
- package/docs/design-notes/tokens.md +2 -0
- package/docs/pages/components/accordion.md +5 -0
- package/docs/pages/components/chat.md +20 -0
- package/docs/pages/enhancements/status-bar.md +1 -0
- package/docs/pages/examples/overview.md +2 -0
- package/docs/pages/forms/date-picker.md +6 -0
- package/docs/pages/forms/overview.md +1 -1
- package/docs/pages/forms/sticky-actions.md +2 -0
- package/docs/pages/foundations/theming.md +19 -3
- package/docs/pages/guides/upgrading.md +1 -1
- package/docs/pages/layout/scroll-snap.md +69 -2
- package/package.json +1 -1
- package/src/css/components/chat.css +5 -1
- package/src/css/components/status-bar.css +4 -2
- package/src/css/forms/choice-card.css +5 -2
- package/src/css/forms/form.css +3 -1
- package/src/js/selectors.js +10 -2
- package/src/js/status.js +71 -10
|
@@ -47,6 +47,8 @@ Neutral roles may lean toward the palette's ambient hue — by default the prima
|
|
|
47
47
|
|
|
48
48
|
Semantic intents are curated colors, not mechanical derivatives of `--primary`. Danger, warning, and success stay recognizable for their function, but they are chosen as members of the theme palette rather than copied independently from a generic scale. Neither intents nor neutrals are derived from `--primary` at runtime: the relationship is a design decision recorded in the theme's own values.
|
|
49
49
|
|
|
50
|
+
Actual ships a theme, not a palette. A palette lists available colors (`blue-100` … `blue-900`); a theme assigns meaning (primary, danger, surface, text). Components consume only the roles, so bundled color scales would add hundreds of custom properties the framework never reads and widen the public API without adding behavior. Applications bring their own source — a palette library, brand guidelines, literal values — and map it to the roles at the theme boundary.
|
|
51
|
+
|
|
50
52
|
Color should reinforce structure and meaning, not carry them alone. Information hierarchy and semantic states should remain understandable when hue is removed or unavailable. Desaturating a composition is a useful review heuristic, not a conformance test.
|
|
51
53
|
|
|
52
54
|
## Soft foreground calibration
|
|
@@ -168,3 +168,8 @@ recipe repeats it on its own property:
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
```
|
|
171
|
+
|
|
172
|
+
The [playful FAQ template](../../demo/templates/playful-faq.html) applies this
|
|
173
|
+
recipe with a local palette and animates the panel opening and closing (smooth
|
|
174
|
+
expand / collapse, height animation) through `::details-content`, without
|
|
175
|
+
JavaScript.
|
|
@@ -30,6 +30,24 @@ also follows right-to-left writing direction. The avatar is optional. Bubble
|
|
|
30
30
|
colors compose with intents and shared variants: `.primary`, `.primary.soft`,
|
|
31
31
|
and `.primary.outline` all work without chat-specific color classes.
|
|
32
32
|
|
|
33
|
+
The avatar sits beside the last line by default, as in messaging. For a long
|
|
34
|
+
message with a footer — an assistant answer, a comment with its actions — set
|
|
35
|
+
`--chat-avatar-align: start` to keep it beside the header.
|
|
36
|
+
|
|
37
|
+
```html demo
|
|
38
|
+
<div class="chat chat-start" style="--chat-avatar-align: start">
|
|
39
|
+
<div class="chat-avatar avatar sm" role="img" aria-label="Assistant">
|
|
40
|
+
<span aria-hidden="true">A</span>
|
|
41
|
+
</div>
|
|
42
|
+
<div class="chat-header">Assistant <time datetime="2026-08-18T21:31">21:31</time></div>
|
|
43
|
+
<div class="chat-bubble">
|
|
44
|
+
Three invoices are overdue. The largest, INV-2041, is 47 days late; I drafted a
|
|
45
|
+
reminder for it and left the other two for review.
|
|
46
|
+
</div>
|
|
47
|
+
<div class="chat-footer">Sources: Invoices, Customer contacts</div>
|
|
48
|
+
</div>
|
|
49
|
+
```
|
|
50
|
+
|
|
33
51
|
For a live conversation, put an appropriate live-region or `role="log"` on the
|
|
34
52
|
conversation container according to the product's announcement needs. Do not
|
|
35
53
|
put `role="log"` on individual messages.
|
|
@@ -53,3 +71,5 @@ Formatting needs a hosted editor instead — see the
|
|
|
53
71
|
|
|
54
72
|
- `--chat-gap` — gap between the avatar and message content.
|
|
55
73
|
- `--chat-max-size` — maximum inline size of a bubble.
|
|
74
|
+
- `--chat-avatar-align` — the avatar's block alignment: `end` (default) beside
|
|
75
|
+
the last line, `start` beside the header for long messages with a footer.
|
|
@@ -15,6 +15,7 @@ runtime targets, empty by default.
|
|
|
15
15
|
- Use it for transient status (`Saved.`, `Reconnected.`, `Copied.`). Critical, persistent, or actionable information belongs in `.alert`, inline messages, or dialogs.
|
|
16
16
|
- Intents: `danger`, `success`, `warning`, `neutral`. The default (no intent) is a neutral dark pill.
|
|
17
17
|
- On mobile, the runtime keeps the bar above the software keyboard by tracking `visualViewport` while a message is showing.
|
|
18
|
+
- A [sticky form-actions](../forms/sticky-actions.md) bar docked to the bottom edge lifts the bar above it, so an invalid-submit message never covers the submit button.
|
|
18
19
|
- A message from an open modal dialog temporarily moves the bar inside that
|
|
19
20
|
dialog so it remains visible and announced. The bar returns after its exit.
|
|
20
21
|
|
|
@@ -57,6 +57,8 @@ extension points.
|
|
|
57
57
|
- [Adaptive filter surface](../../demo/templates/adaptive-surface.html) - app-level flyout/drawer composition with one synchronized filter state
|
|
58
58
|
- [Select intents](../../demo/templates/select-intents.html) - extending the enhancer with a project's own `data-enhance` behavior, injected markup included, with no framework change
|
|
59
59
|
- [Popover transport probe](../../demo/templates/popover-transport.html) - self-scoring bench for the native popover transport go/no-go
|
|
60
|
+
- [Card rail](../../demo/templates/card-rail.html) - one list as a 3-column grid in a wide container and a scroll-snap rail with a peek and CSS scroll markers in a narrow one
|
|
61
|
+
- [Playful FAQ](../../demo/templates/playful-faq.html) - the separated accordion with an application palette, a pill plus/close marker and an animated open/close through `::details-content`, no JavaScript
|
|
60
62
|
- [Tooltips](../../demo/templates/tooltips.html) - generated text is a snapshot at show time: what updates, what stays, and the explicit-tip way for dynamic content
|
|
61
63
|
|
|
62
64
|
### Third-party components on Actual tokens
|
|
@@ -38,6 +38,12 @@ control, the masked field and
|
|
|
38
38
|
[`@lekoala/date-picker`](https://github.com/lekoala/date-picker) side by side, the
|
|
39
39
|
picker skinned entirely with Actual tokens.
|
|
40
40
|
|
|
41
|
+
The picker also masks typed entry in the locale: digits gain the `Intl`
|
|
42
|
+
separators (`29102026` becomes `29/10/2026` in `fr-BE`) while the submitted value
|
|
43
|
+
stays ISO. `format-on-type="false"` disables the automatic separators; parsing,
|
|
44
|
+
validation and the ISO value are unaffected. Do not combine the picker with
|
|
45
|
+
`data-mask` — two writers on the same value have no defined caret behaviour.
|
|
46
|
+
|
|
41
47
|
```html
|
|
42
48
|
<label class="field">
|
|
43
49
|
<span class="field-label">Booking date</span>
|
|
@@ -191,7 +191,7 @@ root; keyboard focus and an open custom select keep it.
|
|
|
191
191
|
- `.field` is the canonical field wrapper. It works on `<label>` and `<div>`.
|
|
192
192
|
- `.field-label` is element-agnostic. Use it on `<span>` inside a wrapped label, on `<label for="…">` in a detached layout, or on `<legend>` inside a fieldset.
|
|
193
193
|
- `.field-group` styles a `<fieldset class="field-group">` as a grouped field container. Its legend gutter is tunable with `--fieldset-legend-padding-inline` (`var(--space-10)`). It carries no sibling margin: space consecutive groups with `.stack` on the form, so the rhythm follows the layout instead of the component.
|
|
194
|
-
- `.field-group.flush` drops the frame (unboxed, borderless fieldset) for a group that already sits in a card or a form section; the legend then reads as a plain label above the options. It keeps the `<fieldset>` and `<legend>` semantics.
|
|
194
|
+
- `.field-group.flush` drops the frame (unboxed, borderless fieldset) for a group that already sits in a card or a form section; the legend then reads as a plain label above the options, at `--control-font-size` like a `.field` label. It keeps the `<fieldset>` and `<legend>` semantics.
|
|
195
195
|
- Use native `<optgroup>` and `disabled` options in `.select` controls when applicable; the customizable picker preserves both as a progressive enhancement.
|
|
196
196
|
- `.choice` is the choice-label API. Use `.check` or `.radio` on the nested control. The control goes first, the label group second, so multi-line labels align the control with the first line.
|
|
197
197
|
- For a switch, use `class="switch"` and `role="switch"`.
|
|
@@ -187,3 +187,5 @@ Scroll the page to see the detached footer stay reachable.
|
|
|
187
187
|
```
|
|
188
188
|
|
|
189
189
|
A sticky footer can cover the last field on short pages. That is a page-layout concern, not a framework concern. Add bottom padding to the page or scroll container if needed.
|
|
190
|
+
|
|
191
|
+
While a docked sticky bar is on screen, the [status bar](../enhancements/status-bar.md) rises above it, so a message never covers the actions — including the validation message an invalid submit shows.
|
|
@@ -200,7 +200,7 @@ controls and scrollbars.
|
|
|
200
200
|
|
|
201
201
|
→ Foundations · Tokens (theme contract)
|
|
202
202
|
|
|
203
|
-
### Replace the palette with my own brand
|
|
203
|
+
### Replace the palette with my own brand / bring your own palette
|
|
204
204
|
|
|
205
205
|
Override the whole minimal recolor set (Tokens · Theme contract), not just
|
|
206
206
|
`--primary`. Every neutral of the default theme — surfaces, text, border,
|
|
@@ -223,8 +223,24 @@ It reads the theme in headless Chrome, in every scheme it declares, and exits 1
|
|
|
223
223
|
when a soft, focus, invalid-focus or inverse pair misses its threshold, so it
|
|
224
224
|
can gate a CI job.
|
|
225
225
|
|
|
226
|
-
Starting from a color scale (
|
|
227
|
-
step per role rather than importing
|
|
226
|
+
Starting from a color scale (Open Props, Radix Colors, Uchū, Tailwind
|
|
227
|
+
`--color-zinc-*`, a brand ramp): map one step per role rather than importing
|
|
228
|
+
the scale. Reference the library's variables in the theme or copy the few
|
|
229
|
+
values you use; components keep reading roles, never a scale step.
|
|
230
|
+
|
|
231
|
+
```css
|
|
232
|
+
[data-theme="brand"] {
|
|
233
|
+
--primary: var(--indigo-9);
|
|
234
|
+
--primary-fg: white;
|
|
235
|
+
--danger: var(--red-9);
|
|
236
|
+
--danger-fg: white;
|
|
237
|
+
/* … the rest of the recolor set */
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Actual ships no color scales (`blue-100` … `blue-900`). Colors with no
|
|
242
|
+
component role — chart series, illustrations, logo colors — are application
|
|
243
|
+
tokens.
|
|
228
244
|
|
|
229
245
|
→ Foundations · Tokens (theme contract) · Guides · Tailwind (Map the palette to theme roles)
|
|
230
246
|
|
|
@@ -25,7 +25,7 @@ No class or hook is removed: markup and application CSS keep working.
|
|
|
25
25
|
package, so this only affects a copy of it: keep the copy, or drop it since
|
|
26
26
|
the core focus line and fields now match it.
|
|
27
27
|
- The combobox, date picker and data grid recipes target
|
|
28
|
-
`@lekoala/combobox` 0.8.0, `@lekoala/date-picker` 0.6.
|
|
28
|
+
`@lekoala/combobox` 0.8.0, `@lekoala/date-picker` 0.6.1 and
|
|
29
29
|
`data-grid-component` 3.8.0. Compare a copied bridge with the current one in
|
|
30
30
|
[Combobox](../forms/combobox.md) and [Date picker](../forms/date-picker.md).
|
|
31
31
|
|
|
@@ -6,7 +6,7 @@ Horizontal rails that stay useful without JavaScript and snap in modern browsers
|
|
|
6
6
|
|
|
7
7
|
Use `.scroll-snap` for a niche row of items that should scroll horizontally, such as card rails, media strips, overflow tabs, or a simple touch-friendly carousel baseline. Scrolling only appears when the items are wider than the container; set `--scroll-snap-item-size` for card rails.
|
|
8
8
|
|
|
9
|
-
**Related terms:** carousel, card carousel, horizontal scroller, media rail, scrolling rail.
|
|
9
|
+
**Related terms:** carousel, card carousel, horizontal scroller, media rail, scrolling rail, grid to slider, swipe on mobile, pagination dots.
|
|
10
10
|
|
|
11
11
|
```html demo
|
|
12
12
|
<section class="stack" aria-labelledby="featured-title">
|
|
@@ -55,4 +55,71 @@ Keep scrollbars visible by default. If a product deliberately hides them, make t
|
|
|
55
55
|
</div>
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
## Grid on wide, rail on narrow
|
|
59
|
+
|
|
60
|
+
To show one list as a grid in a wide container and as a swipeable rail in a narrow one, keep a single `.scroll-snap` list and turn it into a grid from an `actual-container` query:
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<div class="container-query">
|
|
64
|
+
<ul class="scroll-snap list-reset card-rail">
|
|
65
|
+
<li class="card">…</li>
|
|
66
|
+
</ul>
|
|
67
|
+
</div>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```css
|
|
71
|
+
.card-rail {
|
|
72
|
+
--scroll-snap-item-size: min(80%, 18rem);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@container actual-container (min-width: 48rem) {
|
|
76
|
+
.card-rail {
|
|
77
|
+
display: grid;
|
|
78
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
79
|
+
overflow: visible;
|
|
80
|
+
margin-block: 0;
|
|
81
|
+
padding: 0;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Keep the item size under `100%` so the next card peeks in: iOS hides the scrollbar at rest, so the cut-off card is the scroll cue. In the grid, `overflow: visible` ends the scroll container, and resetting `margin-block` and `padding` removes the focus reserve that only a clipping rail needs.
|
|
87
|
+
|
|
88
|
+
### Pagination dots
|
|
89
|
+
|
|
90
|
+
CSS scroll markers add one dot per item in Chromium. Other browsers drop these declarations and keep the peek.
|
|
91
|
+
|
|
92
|
+
```css
|
|
93
|
+
.card-rail {
|
|
94
|
+
scroll-marker-group: after;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.card-rail > li::scroll-marker {
|
|
98
|
+
content: "" / attr(data-marker-label);
|
|
99
|
+
inline-size: 0.5rem;
|
|
100
|
+
block-size: 0.5rem;
|
|
101
|
+
border-radius: var(--radius-full);
|
|
102
|
+
background: var(--text-subtle);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.card-rail > li::scroll-marker:target-current {
|
|
106
|
+
inline-size: 1.5rem;
|
|
107
|
+
background: var(--primary);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@supports (scroll-marker-group: after) {
|
|
111
|
+
.card-rail {
|
|
112
|
+
scrollbar-width: none;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
- Each dot is a link: give every item a `data-marker-label`, because `content: ""` alone leaves the links nameless.
|
|
118
|
+
- The dots are controls and need 3:1 against the page: `--text-subtle` is the quietest text tone that holds it, `--border` does not. Mark the current dot by size, not color alone.
|
|
119
|
+
- The dots replace the scrollbar, so hide it only where they exist; `data-scrollbar="hidden"` would also hide it in browsers without markers.
|
|
120
|
+
- Each dot is a tab stop, placed before the items in Chromium's tab order.
|
|
121
|
+
- The grid needs no `scroll-marker-group` reset: markers exist only on a scroll container.
|
|
122
|
+
|
|
123
|
+
The [card rail template](../../demo/templates/card-rail.html) has the full recipe, focus ring and forced colors included.
|
|
124
|
+
|
|
125
|
+
`.scroll-snap` is not a full interactive carousel. For previous/next controls, pagination dots in every browser, mouse drag, looping, autoplay, or robust accessibility behavior, use a dedicated carousel library such as Swiper and compose it with Actual components.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "actual-css",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "Plain CSS component framework with semantic classes, universal variants, small tokens, theme hooks, and progressive enhancements.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "bun@1.4.4",
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* Public hooks:
|
|
7
7
|
* --chat-gap
|
|
8
8
|
* --chat-max-size
|
|
9
|
+
* --chat-avatar-align
|
|
9
10
|
*
|
|
10
11
|
* Internal:
|
|
11
12
|
* --chat-bubble-bg
|
|
@@ -15,6 +16,9 @@
|
|
|
15
16
|
.chat {
|
|
16
17
|
--chat-gap: var(--space-30);
|
|
17
18
|
--chat-max-size: min(85%, 40rem);
|
|
19
|
+
/* end: the avatar sits beside the last line, as in messaging. start sets it
|
|
20
|
+
beside the header, for long answers or comment threads with a footer. */
|
|
21
|
+
--chat-avatar-align: end;
|
|
18
22
|
|
|
19
23
|
display: grid;
|
|
20
24
|
grid-auto-rows: min-content;
|
|
@@ -33,7 +37,7 @@
|
|
|
33
37
|
|
|
34
38
|
.chat-avatar {
|
|
35
39
|
grid-row: 1 / span 3;
|
|
36
|
-
align-self:
|
|
40
|
+
align-self: var(--chat-avatar-align);
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
.chat-start > .chat-avatar {
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
* Internal:
|
|
23
23
|
* --status-bg
|
|
24
24
|
* --status-fg
|
|
25
|
-
* --status-viewport-offset (written by status.js while the bar is open
|
|
25
|
+
* --status-viewport-offset (written by status.js while the bar is open: the
|
|
26
|
+
* keyboard band plus any docked .form-actions.sticky bar)
|
|
26
27
|
*/
|
|
27
28
|
|
|
28
29
|
/* Intent boundary — inherited intents do not tint this component.
|
|
@@ -38,7 +39,8 @@
|
|
|
38
39
|
|
|
39
40
|
position: fixed;
|
|
40
41
|
/* Fixed positioning tracks the layout viewport, which the mobile software
|
|
41
|
-
keyboard covers
|
|
42
|
+
keyboard covers, and a docked .form-actions.sticky bar shares its bottom
|
|
43
|
+
edge. status.js writes both occluded bands into the offset. */
|
|
42
44
|
inset-block-end: calc(var(--space-40) + var(--status-viewport-offset, 0px));
|
|
43
45
|
inset-inline: var(--space-40);
|
|
44
46
|
z-index: var(--z-status);
|
|
@@ -104,8 +104,11 @@
|
|
|
104
104
|
cursor: not-allowed;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
/* Touch can retain :hover after a tap; hover must never mask selection. */
|
|
108
|
+
@media (hover: hover) {
|
|
109
|
+
.choice-card:hover:not(:has(:disabled, :checked)) {
|
|
110
|
+
--choice-card-border: var(--text-subtle);
|
|
111
|
+
}
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
/* Checked border — shared by radio and checkbox */
|
package/src/css/forms/form.css
CHANGED
|
@@ -51,7 +51,8 @@
|
|
|
51
51
|
|
|
52
52
|
/* Flush — the frame removed, for a group that already sits in a card or a
|
|
53
53
|
form section. With no border to notch, the legend is a plain label above
|
|
54
|
-
the options: no gutter,
|
|
54
|
+
the options: no gutter, the .field label-to-control gap below it, and the
|
|
55
|
+
.field label size — the small size only suits a legend set in a frame. */
|
|
55
56
|
.field-group.flush {
|
|
56
57
|
padding: 0;
|
|
57
58
|
border: 0;
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
.field-group.flush > legend {
|
|
62
63
|
margin-block-end: var(--space-10);
|
|
63
64
|
padding-inline: 0;
|
|
65
|
+
font-size: var(--control-font-size);
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
.field-help {
|
package/src/js/selectors.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Selectors — the state-class vocabulary the runtime writes.
|
|
3
3
|
*
|
|
4
4
|
* The file lists the class names modules write as state (is-open,
|
|
5
|
-
* was-validated, …) and
|
|
6
|
-
*
|
|
5
|
+
* was-validated, …) and the classes they only read as presentation adapters:
|
|
6
|
+
* validation's field and fieldError, status's formActions + sticky pair.
|
|
7
|
+
* Behavior discovery is not listed here: it uses
|
|
7
8
|
* data-enhance tokens. To run this runtime against a different CSS
|
|
8
9
|
* framework, edit this file (or alias it in a bundler).
|
|
9
10
|
*
|
|
@@ -24,6 +25,13 @@ export const CLASSES = {
|
|
|
24
25
|
// validation.js — read-side presentation adapter: ancestor container
|
|
25
26
|
// for aria-invalid/danger state. Optional — degrades to no-op.
|
|
26
27
|
field: "field",
|
|
28
|
+
// status.js — read-side presentation adapter, first half of the compound
|
|
29
|
+
// .form-actions.sticky: the docked action bar the status bar rises above
|
|
30
|
+
// instead of covering its submit button.
|
|
31
|
+
formActions: "form-actions",
|
|
32
|
+
// status.js — read-side presentation adapter, second half of the same
|
|
33
|
+
// compound. Read only, never written: the runtime sets no sticky state.
|
|
34
|
+
sticky: "sticky",
|
|
27
35
|
// surface.js — state class on the open flyout/menu/dialog surface.
|
|
28
36
|
// status.js writes the same class on the status bar while a message shows.
|
|
29
37
|
open: "is-open",
|
package/src/js/status.js
CHANGED
|
@@ -58,6 +58,7 @@ import { waitForTransitions } from "./transition.js";
|
|
|
58
58
|
const STATUS_SELECTOR = '[data-status][role="status"]';
|
|
59
59
|
const STATUS_CLASSES_ATTR = "statusClasses";
|
|
60
60
|
const VIEWPORT_OFFSET_PROPERTY = "--status-viewport-offset";
|
|
61
|
+
const DOCKED_ACTIONS_SELECTOR = `.${CLASSES.formActions}.${CLASSES.sticky}`;
|
|
61
62
|
const DEFAULT_DURATION_MS = 3000;
|
|
62
63
|
|
|
63
64
|
let statusTimer;
|
|
@@ -116,34 +117,94 @@ function mountStatusTarget(target, source) {
|
|
|
116
117
|
mountedStatusTarget = target;
|
|
117
118
|
}
|
|
118
119
|
|
|
120
|
+
function dockedActionsBars(target) {
|
|
121
|
+
const root = target.closest("dialog[open]") ?? target.ownerDocument;
|
|
122
|
+
return root.querySelectorAll(DOCKED_ACTIONS_SELECTOR);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// A sticky action bar docks to the same bottom edge as the status bar. The
|
|
126
|
+
// validation docs pair the two, so an invalid submit would otherwise show its
|
|
127
|
+
// message on top of the submit button it is about. Any message is lifted, not
|
|
128
|
+
// only one from that form: the bar must not hide the page's primary actions
|
|
129
|
+
// whatever it says. A bar counts as docked when its bottom sits at its sticky
|
|
130
|
+
// offset from the visible bottom edge (above a bottom navigation, for one); a
|
|
131
|
+
// bar at rest higher up the page is not in the way. Detection assumes the
|
|
132
|
+
// bar's scrollport reaches the viewport bottom: a bar docked in a scroll
|
|
133
|
+
// container that ends higher (.app-main above an .app-nav row) is not seen.
|
|
134
|
+
function dockedActionsBand(target, view, visibleBottom) {
|
|
135
|
+
let band = 0;
|
|
136
|
+
for (const actions of dockedActionsBars(target)) {
|
|
137
|
+
const rect = actions.getBoundingClientRect();
|
|
138
|
+
const offset = Number.parseFloat(view.getComputedStyle(actions).bottom) || 0;
|
|
139
|
+
if (rect.height > 0 && rect.top < visibleBottom && rect.bottom >= visibleBottom - offset - 1) {
|
|
140
|
+
band = Math.max(band, visibleBottom - rect.top);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return band;
|
|
144
|
+
}
|
|
145
|
+
|
|
119
146
|
// The bar is fixed to the layout viewport, so the mobile software keyboard
|
|
120
|
-
// covers it
|
|
121
|
-
//
|
|
147
|
+
// covers it, and a docked sticky action bar sits where it would show.
|
|
148
|
+
// visualViewport reports the keyboard band; the docked bar's height is added on
|
|
149
|
+
// top; the CSS adds the sum to the bottom inset. Tracking runs only while a
|
|
150
|
+
// message is on screen.
|
|
122
151
|
function trackViewport(target) {
|
|
123
152
|
if (viewportTracker?.target === target) return;
|
|
124
153
|
releaseViewport();
|
|
125
154
|
|
|
126
155
|
const view = target.ownerDocument?.defaultView;
|
|
127
|
-
|
|
128
|
-
|
|
156
|
+
if (!view) return;
|
|
157
|
+
const viewport = view.visualViewport;
|
|
129
158
|
|
|
130
159
|
const controller = new AbortController();
|
|
160
|
+
let frame = 0;
|
|
161
|
+
let written = null;
|
|
131
162
|
const update = () => {
|
|
163
|
+
frame = 0;
|
|
132
164
|
// Self-heal: an app that drops the bar while a message is up never reaches
|
|
133
165
|
// the clear() path, so the tracker would outlive its element.
|
|
134
166
|
if (!target.isConnected) {
|
|
135
167
|
releaseViewport();
|
|
136
168
|
return;
|
|
137
169
|
}
|
|
138
|
-
const
|
|
139
|
-
|
|
170
|
+
const keyboard = viewport
|
|
171
|
+
? Math.max(0, view.innerHeight - viewport.height - viewport.offsetTop)
|
|
172
|
+
: 0;
|
|
173
|
+
const docked = dockedActionsBand(target, view, view.innerHeight - keyboard);
|
|
174
|
+
const value = `${keyboard + docked}px`;
|
|
175
|
+
if (value === written) return;
|
|
176
|
+
written = value;
|
|
177
|
+
target.style.setProperty(VIEWPORT_OFFSET_PROPERTY, value);
|
|
178
|
+
};
|
|
179
|
+
// Scroll fires per frame and per scroll container; one layout read per frame
|
|
180
|
+
// is enough.
|
|
181
|
+
const schedule = () => {
|
|
182
|
+
if (!frame) frame = view.requestAnimationFrame(update);
|
|
140
183
|
};
|
|
141
184
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
185
|
+
// Installed before the first update, so a target already detached there is
|
|
186
|
+
// released instead of leaving a tracker behind.
|
|
187
|
+
const observer = view.ResizeObserver ? new view.ResizeObserver(schedule) : null;
|
|
188
|
+
viewportTracker = {
|
|
189
|
+
target,
|
|
190
|
+
stop: () => {
|
|
191
|
+
controller.abort();
|
|
192
|
+
observer?.disconnect();
|
|
193
|
+
if (frame) view.cancelAnimationFrame(frame);
|
|
194
|
+
},
|
|
195
|
+
};
|
|
145
196
|
|
|
146
|
-
|
|
197
|
+
const options = { signal: controller.signal, passive: true };
|
|
198
|
+
viewport?.addEventListener("resize", schedule, options);
|
|
199
|
+
viewport?.addEventListener("scroll", schedule, options);
|
|
200
|
+
// Scrolling docks and releases the action bar. Capture also hears the scroll
|
|
201
|
+
// containers (.app-main) whose scroll events do not bubble.
|
|
202
|
+
view.addEventListener("scroll", schedule, { ...options, capture: true });
|
|
203
|
+
view.addEventListener("resize", schedule, options);
|
|
204
|
+
// A docked bar can change height without any scroll: a wrapping button, a
|
|
205
|
+
// spinner, an error line above the actions.
|
|
206
|
+
for (const actions of dockedActionsBars(target)) observer?.observe(actions);
|
|
207
|
+
update();
|
|
147
208
|
}
|
|
148
209
|
|
|
149
210
|
function releaseViewport() {
|