actual-css 0.19.3 → 0.19.5
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 +13 -0
- package/README.md +2 -2
- package/dist/actual.full.css +8 -4
- package/dist/actual.full.js +2 -2
- package/dist/actual.full.min.css +1 -1
- package/dist/types/surface-focus.d.ts +2 -0
- package/docs/pages/components/dialog.md +3 -0
- package/docs/pages/components/list.md +1 -1
- package/docs/pages/components/timeline.md +4 -2
- package/docs/pages/enhancements/flyout.md +26 -8
- package/docs/pages/forms/joined-controls.md +1 -1
- package/docs/pages/forms/switch.md +4 -2
- package/docs/pages/foundations/theming.md +3 -0
- package/docs/pages/foundations/tokens.md +13 -13
- package/llms.txt +3 -3
- package/package.json +4 -5
- package/src/cli/actual-css.js +3 -3
- package/src/css/components/menu.css +2 -2
- package/src/css/forms/switch.css +6 -2
- package/src/js/dialog.js +30 -11
- package/src/js/surface-focus.js +14 -0
- package/src/js/surface.js +8 -3
- package/src/tooling/theme-contrast.js +6 -2
- package/docs/design-notes/accessibility-decisions.md +0 -65
- package/docs/design-notes/app-ui.md +0 -67
- package/docs/design-notes/architecture.md +0 -70
- package/docs/design-notes/browser-support.md +0 -239
- package/docs/design-notes/cascade-layer.md +0 -74
- package/docs/design-notes/column-layout.md +0 -260
- package/docs/design-notes/css-anchor.md +0 -87
- package/docs/design-notes/enhancement-contract.md +0 -193
- package/docs/design-notes/forced-colors.md +0 -123
- package/docs/design-notes/grid.md +0 -785
- package/docs/design-notes/motion-cost.md +0 -62
- package/docs/design-notes/naming.md +0 -71
- package/docs/design-notes/platform-alignment.md +0 -602
- package/docs/design-notes/popover-manual-poc.md +0 -328
- package/docs/design-notes/references.md +0 -336
- package/docs/design-notes/rich-text.md +0 -61
- package/docs/design-notes/spacing-units.md +0 -286
- package/docs/design-notes/steps.md +0 -776
- package/docs/design-notes/surface-reparenting.md +0 -130
- package/docs/design-notes/tokens.md +0 -166
- package/docs/design-notes/tooltip-coordinate-space.md +0 -130
- package/docs/design-notes/widget-primitives.md +0 -144
- package/docs/navigation.json +0 -176
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
# Surface reparenting broke inherited presentation context
|
|
2
|
-
|
|
3
|
-
Resolved. The record is kept because the defect had no generic repair, three of
|
|
4
|
-
the obvious ones look right and are wrong, and the transport that fixed it is
|
|
5
|
-
the reason the JavaScript floor sits where it does.
|
|
6
|
-
|
|
7
|
-
## What used to happen
|
|
8
|
-
|
|
9
|
-
`surface.js` moved an open surface out of its place in the document:
|
|
10
|
-
|
|
11
|
-
```text
|
|
12
|
-
getSurfaceRoot() → nearest <dialog>, else body
|
|
13
|
-
mountSurface() → root.append(panel)
|
|
14
|
-
restoreSurface() → put it back once the exit transition ends
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
The move existed for good reasons — it escaped `overflow` clipping on any
|
|
18
|
-
ancestor and sidestepped `z-index` stacking. But it also took the panel out of
|
|
19
|
-
every scope that reached it *by inheritance*. The panel was styled by one set of
|
|
20
|
-
ancestors while closed, and by a different set from the moment it became
|
|
21
|
-
visible.
|
|
22
|
-
|
|
23
|
-
Actual leans on inheritance deliberately: theme islands, density, and the
|
|
24
|
-
custom properties an application scopes to its own containers all
|
|
25
|
-
travel that way. So this was not one bug about themes. It was the same bug in as
|
|
26
|
-
many forms as there are inherited contexts.
|
|
27
|
-
|
|
28
|
-
## Measured
|
|
29
|
-
|
|
30
|
-
Chrome, one `.flyout` per scope, values read off the panel before and after the
|
|
31
|
-
click that opens it:
|
|
32
|
-
|
|
33
|
-
| Scope | Closed | Open |
|
|
34
|
-
| ------------------------- | ----------------------------- | -------------------- |
|
|
35
|
-
| `[data-theme="dark"]` | `background: rgb(30, 26, 35)` | `rgb(255, 255, 255)` |
|
|
36
|
-
| `.sm` | `--control-size: 2rem` | `2.375rem` |
|
|
37
|
-
| app-scoped `--app-accent` | `rgb(1, 2, 3)` | *(unset)* |
|
|
38
|
-
| `.sm` inside a `<dialog>` | `--control-size: 2rem` | `2.375rem` |
|
|
39
|
-
|
|
40
|
-
Every context broke. Three consequences were worth stating plainly:
|
|
41
|
-
|
|
42
|
-
- The theme case was visible, not theoretical: a flyout inside a dark island
|
|
43
|
-
turned light at the moment it opened.
|
|
44
|
-
- The density case was measurable: menu rows rendered 38px instead of the 32px
|
|
45
|
-
the scope asked for.
|
|
46
|
-
- The dialog case showed the `getSurfaceRoot()` special case did not help. The
|
|
47
|
-
panel did land inside the dialog, and still lost any scope sitting between
|
|
48
|
-
that dialog and its trigger. Choosing a nearer root loses less context; it
|
|
49
|
-
does not preserve it.
|
|
50
|
-
|
|
51
|
-
`tests/browser/surface-inherited-context.test.js` holds those assertions and
|
|
52
|
-
now passes against the shipped transport.
|
|
53
|
-
|
|
54
|
-
## Why the obvious repairs are wrong
|
|
55
|
-
|
|
56
|
-
Still wrong, and still tempting — this section is the reason the note is kept.
|
|
57
|
-
|
|
58
|
-
**Copying `data-theme` onto the moved panel.** Fixes the one symptom that was
|
|
59
|
-
noticed and leaves the other four broken. It also turns an inherited contract
|
|
60
|
-
into an enumerated one, so every future scope has to be added to a list.
|
|
61
|
-
|
|
62
|
-
**Snapshotting custom properties before the move.** There is no bounded set to
|
|
63
|
-
snapshot — an application's own hooks are unknowable by definition, and
|
|
64
|
-
`getComputedStyle` cannot enumerate inherited custom properties portably. It
|
|
65
|
-
would also freeze values that should stay live.
|
|
66
|
-
|
|
67
|
-
**Mounting to a nearer root.** The dialog row above is the experiment: it
|
|
68
|
-
reduces the damage without addressing the cause.
|
|
69
|
-
|
|
70
|
-
The cause was that the panel was moved at all. The repair is a transport that
|
|
71
|
-
promotes the element without relocating it.
|
|
72
|
-
|
|
73
|
-
## The repair, as shipped
|
|
74
|
-
|
|
75
|
-
A native popover renders in the top layer while staying exactly where the
|
|
76
|
-
author put it in the DOM. That removed the reason to reparent, and with it the
|
|
77
|
-
whole mechanism:
|
|
78
|
-
|
|
79
|
-
```text
|
|
80
|
-
mountedSurfaces
|
|
81
|
-
getSurfaceRoot()
|
|
82
|
-
mountSurface()
|
|
83
|
-
restoreSurface()
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
`popover="manual"` is the mode that fits: it supplies the top layer and nothing
|
|
87
|
-
else, so `surface.js` keeps its dismissal policy, Escape ordering, focus
|
|
88
|
-
restoration and placement orchestration unchanged. See
|
|
89
|
-
[platform-alignment](platform-alignment.md) for the responsibility split, and
|
|
90
|
-
[browser-support](browser-support.md) for the floor it requires.
|
|
91
|
-
|
|
92
|
-
Adopting it behind a capability branch was rejected rather than overlooked: the
|
|
93
|
-
fallback path *is* the defect, so a branch would have kept the bug alive for
|
|
94
|
-
exactly the browsers it was written to serve. Raising the floor was the cheaper
|
|
95
|
-
half of the decision.
|
|
96
|
-
|
|
97
|
-
## The contract now
|
|
98
|
-
|
|
99
|
-
> A surface managed by `surface.js` is presented in its trigger's context. A
|
|
100
|
-
> scoped theme, density, or custom property reaches an anchored surface through
|
|
101
|
-
> inheritance, open or closed.
|
|
102
|
-
|
|
103
|
-
The two workarounds this note used to recommend — declaring the scope on `body`
|
|
104
|
-
or on the panel itself — are no longer needed and can be removed from
|
|
105
|
-
application code.
|
|
106
|
-
|
|
107
|
-
`tooltip.js` reached the same contract later, and for the same reason: it moved
|
|
108
|
-
an explicit tooltip to the dialog or the body on first hover, which is this
|
|
109
|
-
defect in a second component. An explicit tooltip now stays where it was
|
|
110
|
-
written and inherits accordingly.
|
|
111
|
-
|
|
112
|
-
A generated tooltip (`data-tooltip="text"`) is deliberately outside the
|
|
113
|
-
contract. Actual creates that element, so Actual places it, and it goes to
|
|
114
|
-
document level rather than beside the trigger — a generated sibling would take
|
|
115
|
-
`.join > :last-child` from a trigger that ends a group, since structural
|
|
116
|
-
pseudo-classes are DOM-based and `position: fixed` does not exempt an element
|
|
117
|
-
from them. The shorthand therefore promises no inheritance; the explicit form
|
|
118
|
-
is the one to use when local context matters.
|
|
119
|
-
|
|
120
|
-
## Experiment
|
|
121
|
-
|
|
122
|
-
[popover-manual-poc](popover-manual-poc.md) records what the branch measured,
|
|
123
|
-
what it refuted, and the checklist the migration followed. Read that before
|
|
124
|
-
touching the transport again — it holds the negative results, `::backdrop`
|
|
125
|
-
included.
|
|
126
|
-
|
|
127
|
-
## Review trigger
|
|
128
|
-
|
|
129
|
-
Revisit if a further inherited context is found to break, or if a transport
|
|
130
|
-
that promotes without the top layer becomes available by another route.
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
# Token architecture
|
|
2
|
-
|
|
3
|
-
User-facing hooks and theming guidance are in
|
|
4
|
-
[Tokens](../pages/foundations/tokens.md). This note records implementation
|
|
5
|
-
constraints and the reasoning behind the token system.
|
|
6
|
-
|
|
7
|
-
## Scope and inheritance
|
|
8
|
-
|
|
9
|
-
Custom properties resolve their references on the element that declares them.
|
|
10
|
-
An alias declared only on `:root` arrives in a theme island already resolved,
|
|
11
|
-
so it cannot follow the island's palette. Theme-derived aliases must be
|
|
12
|
-
redeclared on `:root, [data-theme]`.
|
|
13
|
-
|
|
14
|
-
Optional hooks such as `--state-selected-text` reset to the guaranteed-invalid
|
|
15
|
-
value at each theme boundary. Consumers then fall back to that theme's
|
|
16
|
-
`--state-selected`, rather than inheriting an outer theme's resolved color.
|
|
17
|
-
|
|
18
|
-
Instance geometry resets on each instance; palette, rhythm, and policy inherit.
|
|
19
|
-
A reset is safe only when the instance itself consumes the hook. The children
|
|
20
|
-
of `.switcher` and `.sidebar-layout` consume their layout hooks, so those hooks
|
|
21
|
-
keep inheriting: a nested instance may also need its parent's value as a child.
|
|
22
|
-
|
|
23
|
-
## Intent boundaries
|
|
24
|
-
|
|
25
|
-
Intent classes expose `--intent`, `--intent-fg`, and `--intent-soft-fg`.
|
|
26
|
-
Each consuming component resets the relays it uses in a `:where()` rule.
|
|
27
|
-
This stops ancestor intents from tinting nested components while allowing a
|
|
28
|
-
local intent class to win by specificity. Both directions are covered by
|
|
29
|
-
`tests/css-audit.test.js`, `tests/browser/intent-boundary.test.js`, and
|
|
30
|
-
`tests/browser/soft-boundary.test.js`.
|
|
31
|
-
|
|
32
|
-
## Size and density
|
|
33
|
-
|
|
34
|
-
Size changes optical scale; density changes spacing and geometry independently
|
|
35
|
-
of text and icons. Components participate only where that distinction is
|
|
36
|
-
meaningful. Controls change geometry and rhythm, content rows change rhythm,
|
|
37
|
-
and badges, avatars, and other intrinsically sized components keep their own
|
|
38
|
-
size scale. Explicit local size wins over inherited density where they overlap.
|
|
39
|
-
|
|
40
|
-
## Palette
|
|
41
|
-
|
|
42
|
-
A coherent palette treats surfaces, text, borders, intents, and shadows as related roles rather than isolated colors.
|
|
43
|
-
|
|
44
|
-
Coherence does not mean that every token must be chromatic. Pure or near-pure whites and blacks remain legitimate where their role calls for them; what matters is that the surrounding neutral ramp and derived treatments belong to the same visual family.
|
|
45
|
-
|
|
46
|
-
Neutral roles may lean toward the palette's ambient hue — by default the primary's — while lightness and chroma stay curated per role. Chroma runs strongest through the ramp's mid-lightness rungs, often around `--border` and `--text-muted` depending on the color scheme, and tapers toward both ends. A palette whose accent is deliberately warmer or cooler than its paper picks an ambient hue of its own.
|
|
47
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
53
|
-
|
|
54
|
-
## Soft foreground calibration
|
|
55
|
-
|
|
56
|
-
Calibrate soft text against the closest resting and hovered surfaces, not just
|
|
57
|
-
against the page. Translucent tints change with the surface underneath, and
|
|
58
|
-
hover adds intent through `--soft-hover-alpha`. The default theme's per-role
|
|
59
|
-
foregrounds hold 4.5:1 on `--surface`, `--surface-raised`, and `--surface-subtle`
|
|
60
|
-
in both schemes; `tests/browser/soft-recipe.test.js` enforces that contract.
|
|
61
|
-
Named themes reset these hooks to avoid inheriting colors calibrated for the
|
|
62
|
-
default palette. Their global mix or per-role hooks need separate measurement.
|
|
63
|
-
|
|
64
|
-
## Contextual color interpolation
|
|
65
|
-
|
|
66
|
-
**When an intent is tinted against a theme-controlled surface or border, the mix interpolates in `oklab`.** That covers the soft recipe, the checked `.choice-card` tint, and the `.overline.pill` border.
|
|
67
|
-
|
|
68
|
-
Not because rectangular interpolation is more faithful to the intent hue — across the shipped presets it is a few degrees *less* faithful. A browser treats hue as powerless below a small chroma epsilon, so for the low-chroma surfaces and borders the presets actually use, a polar mix snaps cleanly onto the intent and wins.
|
|
69
|
-
|
|
70
|
-
The reason is continuity. A theme owns `--surface` and `--border`, and may put them anywhere from achromatic to vivid. Under polar interpolation that range contains a cliff: below the epsilon the mix tracks the intent, above it the surface hue starts winning, and crossing it moves the result into a different color family — 116 degrees, a soft `.secondary` landing in the greens. Cartesian interpolation responds smoothly across the whole range a public token allows. A recipe that is only correct while an adopter's surface stays under an unstated, implementation-defined threshold is not a contract, so the framework trades a small continuous error for a predictable one. The present cost is imperceptible: the largest difference the rule introduces in any preset is 3/255 on one channel.
|
|
71
|
-
|
|
72
|
-
Mixing against `black`, `white`, `transparent`, or `currentColor` is exempt and stays in `oklch`: those have no hue to interpolate, so both spaces give byte-identical results. Polar interpolation also stays legitimate where hue rotation is the point, such as sweeping a gradient through hues. `bun run check:color-space` enforces the rule for contextual tints and takes an `intentional-oklch` comment as an escape hatch.
|
|
73
|
-
|
|
74
|
-
## Motion
|
|
75
|
-
|
|
76
|
-
Ordinary interaction/state transitions have **no easing token**: they use the CSS default `ease` directly, and the dialog shake feedback plus the `actual-dialog` View Transition keep that default deliberately. The presence pair exists only for one-shot open/close where open and closed states own separate easing values (`.status-bar`/`.is-open`, `dialog.modal[open]`, `dialog.drawer[open]`): `--ease-enter` decelerates the appearance, `--ease-exit` accelerates the departure. The pair follows Material's standard rhythm; the emphasized-decelerate entrance is deliberately not offered because it only pays off at 250–400ms durations, beyond this vocabulary. Backdrops keep `ease` — a scrim only fades, it does not travel — but track their surface's duration. Toggles that share one transition list at `--duration-fast` (flyout, tooltip) also stay on `ease`: at 100ms the curve barely resolves and entry/exit cannot split on a single rule. These absences are deliberate, not gaps; a theme with a different motion character overrides `--ease-enter` / `--ease-exit`.
|
|
77
|
-
|
|
78
|
-
Reveal and Mark sweep use native `ease-out`: the surface entrance curve
|
|
79
|
-
completes too much of a fade or highlight sweep near the start. Their gentler
|
|
80
|
-
deceleration is local to those effects, rather than another shared easing token.
|
|
81
|
-
|
|
82
|
-
## Internal tokens
|
|
83
|
-
|
|
84
|
-
Internal tokens are allowed when they reduce duplication or make component code clearer.
|
|
85
|
-
|
|
86
|
-
### Variant plumbing
|
|
87
|
-
|
|
88
|
-
The shared visual variants are:
|
|
89
|
-
|
|
90
|
-
- `.solid`: full background, paired foreground. This is the default for buttons.
|
|
91
|
-
- `.soft`: lightly tinted background, colored text. Good for alerts, badges, and secondary actions.
|
|
92
|
-
- `.outline`: transparent background, colored text, and a text-colored border;
|
|
93
|
-
a neutral `.btn.outline` takes the `--border-control` edge instead.
|
|
94
|
-
- `.surface`: the page surface with the theme border, and the intent only in the text. The neutral chrome neither `.soft` (the intent-tinted treatment) nor `.outline` (no fill) can give.
|
|
95
|
-
|
|
96
|
-
Buttons also support two button-only variants:
|
|
97
|
-
|
|
98
|
-
- `.ghost`: transparent button with hover affordance.
|
|
99
|
-
- `.link`: button semantics with link presentation.
|
|
100
|
-
|
|
101
|
-
Do not force `.ghost` or `.link` onto components where the interaction model does not fit. Shared API should follow shared use.
|
|
102
|
-
|
|
103
|
-
Components map global tokens to local aliases once at the top of the component and consume local tokens afterwards:
|
|
104
|
-
|
|
105
|
-
```css
|
|
106
|
-
.btn {
|
|
107
|
-
--btn-bg: var(--ui-bg, var(--btn-default-bg, var(--intent, var(--neutral))));
|
|
108
|
-
--btn-fg: var(--ui-fg, var(--btn-default-fg, var(--intent-fg, var(--neutral-fg))));
|
|
109
|
-
--btn-border: var(--ui-border, var(--btn-default-border, transparent));
|
|
110
|
-
|
|
111
|
-
border: var(--border-width) solid var(--btn-border-color, var(--btn-border));
|
|
112
|
-
border-block-end-color: var(
|
|
113
|
-
--btn-border-block-end-color,
|
|
114
|
-
var(--btn-border-color, var(--btn-border))
|
|
115
|
-
);
|
|
116
|
-
border-block-end-width: var(--btn-border-block-end-width, var(--border-width));
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
The `--btn-*` fallbacks are intentionally inherited extension points for themes that change button grammar — such as turning the default solid button into a surface button with an intent-colored lower edge (the `edge` theme does exactly this). Keep them local until the same need appears across multiple components.
|
|
121
|
-
|
|
122
|
-
Text controls (`.input`/`.textarea`/`.select`) expose the same lower-edge extension point: `--control-border-block-end-color` and `--control-border-block-end-width` are unset by default and fall back to the regular border, so a theme can give inputs an underline-style lower edge the same way, without fighting the hover/focus/disabled state rules that still own `--control-border` itself.
|
|
123
|
-
|
|
124
|
-
Alerts expose the same idea on the leading edge instead of the lower one: `--alert-border-inline-start-color` and `--alert-border-inline-start-width` are unset by default and fall back to the regular `--ui-border`, so a theme can turn an alert into a callout with a colored flag on the inline-start side, matching the classic notice pattern, without a per-variant override.
|
|
125
|
-
|
|
126
|
-
A theme is not limited to the tokens above; it can restate any component-local token or rule under a state selector to change the interaction recipe itself, not just the palette. The `gradient` theme does this for field focus: it restores a `--focus` border plus an outer translucent halo in place of the core inset outline.
|
|
127
|
-
|
|
128
|
-
Rules:
|
|
129
|
-
|
|
130
|
-
- Prefix internal component tokens with the component name (`--btn-*`, `--alert-*`, `--card-*`).
|
|
131
|
-
- Prefix shared variant plumbing with `--ui-*`.
|
|
132
|
-
- The shared relays `--ui-*`, `--intent*`, and `--density-*` are framework plumbing: they are classified once at framework level, not restated in every component file.
|
|
133
|
-
- Keep component-specific variants in component code when they do not generalize.
|
|
134
|
-
- `flush` is a shared modifier: it removes the component's outer chrome so the component sits directly inside an existing surface (`.accordion.flush`). Reuse the term one component at a time when the same integration need appears elsewhere; `separated` stays component-local until a second real consumer exists.
|
|
135
|
-
- Do not require users to override internal tokens for ordinary theming.
|
|
136
|
-
- Promote an internal token to public only when there is a repeated, reasonable customization need.
|
|
137
|
-
- A custom property used only in a fallback position (`var(--x, default)`) and never declared is an unset extension point and must carry a classification — public, framework plumbing, or internal. `check:css-api` fails on any unclassified fallback-only property; it does not force an artificial declaration to satisfy the audit.
|
|
138
|
-
|
|
139
|
-
## Component mapping
|
|
140
|
-
|
|
141
|
-
Components map global tokens to local aliases at the top of the component, then use the local tokens afterwards. This makes the contract obvious:
|
|
142
|
-
|
|
143
|
-
```css
|
|
144
|
-
.alert {
|
|
145
|
-
--alert-bg: var(--ui-bg, var(--surface-subtle));
|
|
146
|
-
--alert-fg: var(--ui-fg, var(--intent, var(--text)));
|
|
147
|
-
--alert-border: var(--ui-border, var(--border));
|
|
148
|
-
|
|
149
|
-
border: var(--border-width) solid var(--alert-border);
|
|
150
|
-
border-radius: var(--alert-radius, var(--radius-lg));
|
|
151
|
-
background: var(--alert-bg);
|
|
152
|
-
color: var(--alert-fg);
|
|
153
|
-
}
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
- theme authors adjust global tokens
|
|
157
|
-
- variant code adjusts `--ui-*`
|
|
158
|
-
- component code consumes local aliases
|
|
159
|
-
|
|
160
|
-
## Non-goals
|
|
161
|
-
|
|
162
|
-
- Do not expose a separate token for every selector.
|
|
163
|
-
- Do not mirror Pico-style component-specific variables unless there is a clear need.
|
|
164
|
-
- Do not add Tailwind-like color scales as public API.
|
|
165
|
-
- Do not rely on Sass, PostCSS, or generated token files.
|
|
166
|
-
- Do not make dark mode required for old browsers. Light mode is the fallback.
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
# Tooltip coordinate space, and what an unpositionable tip means
|
|
2
|
-
|
|
3
|
-
Two changes to `tooltip.js`, both consequences of one question: what a floating
|
|
4
|
-
element's coordinates are relative to, and what it means when there are none.
|
|
5
|
-
|
|
6
|
-
## The lag
|
|
7
|
-
|
|
8
|
-
Scrolling is asynchronous. The compositor can move the page before any script
|
|
9
|
-
runs, so a `position: fixed` element written from JavaScript is always one frame
|
|
10
|
-
behind the content it is attached to. `autoUpdate()` coalesces to a frame by
|
|
11
|
-
design, which is correct for the work and still visible as a wobble on touch
|
|
12
|
-
devices, where scrolling is driven off the main thread.
|
|
13
|
-
|
|
14
|
-
`@lekoala/floating` 0.2.0 adds `coordinateSpace: "document"`: the same viewport
|
|
15
|
-
measurement, written as `left`/`top` plus the page scroll, for an absolutely
|
|
16
|
-
positioned box whose containing block is the initial one. The browser then
|
|
17
|
-
carries the element with the page and there is nothing to correct.
|
|
18
|
-
|
|
19
|
-
Two candidates were rejected before this one:
|
|
20
|
-
|
|
21
|
-
- **Popper's `strategy: "absolute"`.** Relative to a *containing block*, not to
|
|
22
|
-
the reference — which means resolving the offset parent, its borders, its
|
|
23
|
-
scroll offsets, its transforms, and its own nested scrollers. That is the
|
|
24
|
-
machinery `floating` exists without.
|
|
25
|
-
- **Repositioning synchronously on scroll** instead of at the next frame.
|
|
26
|
-
Cheaper to write, and it only shortens the lag; it cannot remove it, because
|
|
27
|
-
the scroll that moved the page never reached the main thread in time.
|
|
28
|
-
|
|
29
|
-
## The containing block is not a problem here
|
|
30
|
-
|
|
31
|
-
Document coordinates assume the initial containing block. A tip is an open
|
|
32
|
-
popover, so it is in the top layer, where an absolutely positioned box resolves
|
|
33
|
-
against the initial containing block whatever its ancestors do. Measured in
|
|
34
|
-
Chrome, writing viewport point `(200, 300)` in document coordinates at
|
|
35
|
-
`scrollY: 640` and reading the resulting rect back:
|
|
36
|
-
|
|
37
|
-
| Ancestor of the tip | Rect |
|
|
38
|
-
| -------------------- | --------- |
|
|
39
|
-
| `position: relative` | `200,300` |
|
|
40
|
-
| `transform` | `200,300` |
|
|
41
|
-
| `filter` | `200,300` |
|
|
42
|
-
| `contain: paint` | `200,300` |
|
|
43
|
-
| `dialog` (`show()`) | `200,300` |
|
|
44
|
-
| `dialog` (modal) | `200,300` |
|
|
45
|
-
|
|
46
|
-
So where the tip lives never enters into it, and the placement contract — an
|
|
47
|
-
explicit tip stays where the author wrote it, a generated one goes to the
|
|
48
|
-
dialog subtree or the body — is untouched.
|
|
49
|
-
|
|
50
|
-
## The trigger is the problem
|
|
51
|
-
|
|
52
|
-
Document coordinates are only right while the *trigger* scrolls with the page.
|
|
53
|
-
Against a trigger that does not, the browser carries the tip away on every
|
|
54
|
-
scroll and the next frame snaps it back: a worse artefact than the lag it
|
|
55
|
-
removes, and a real one — `.fab`, `.status-bar` and `.drawer` are fixed,
|
|
56
|
-
`.navbar`, `.topbar`, `.app-nav` and `.form-actions` are sticky.
|
|
57
|
-
|
|
58
|
-
`isViewportAnchored()` therefore walks up from the trigger for a computed
|
|
59
|
-
`fixed` or `sticky`, and separately asks for `dialog:modal, :popover-open`,
|
|
60
|
-
which the walk cannot see: a modal dialog computes `position: absolute` and is
|
|
61
|
-
laid out against the viewport by the top layer. Sticky counts even while
|
|
62
|
-
unstuck, because nothing in the DOM changes when it becomes stuck.
|
|
63
|
-
|
|
64
|
-
The modal case is the one worth naming, because a modal dialog does **not**
|
|
65
|
-
stop the page from scrolling behind it — measured, wheel included. A trigger
|
|
66
|
-
inside one is as viewport-anchored as a fixed bar, and keeps `position: fixed`.
|
|
67
|
-
|
|
68
|
-
## The scrollable overflow case
|
|
69
|
-
|
|
70
|
-
An absolutely positioned box in the top layer joins the document's scrollable
|
|
71
|
-
overflow; a fixed one never does. The scrollable height becomes the greater of
|
|
72
|
-
the content's own bottom and the tip's, and the threshold is exact: walking a
|
|
73
|
-
20px tip down a 2000px document in Chrome, `scrollHeight` reads 2000 for every
|
|
74
|
-
tip bottom through 2000, and the tip's own bottom from 2001 on.
|
|
75
|
-
|
|
76
|
-
A tip past the end of the content therefore raises the scroll maximum while it
|
|
77
|
-
is up, and hiding it clamps back any position only that tip made reachable —
|
|
78
|
-
the page appears to jump upwards.
|
|
79
|
-
|
|
80
|
-
Placement is what prevents this, not anything in `tooltip.js`. Flip and shift
|
|
81
|
-
put the tip inside the viewport, which at any scroll position is inside the
|
|
82
|
-
document, so only overflow the engine explicitly accepts — a tip it could not
|
|
83
|
-
fit anywhere — reaches past the end of the content. Nor does the demote and
|
|
84
|
-
promote path add a case: the coordinates are a document point, so a tip that
|
|
85
|
-
was inside the document when it went down is still inside it when it comes
|
|
86
|
-
back up, exit fade included.
|
|
87
|
-
|
|
88
|
-
It is a failure mode to test for, then, not a standing cost of document
|
|
89
|
-
coordinates. If the page ever does jump, `documentElement.scrollHeight` across
|
|
90
|
-
a show and a hide separates this from everything else that moves a page: it
|
|
91
|
-
moves with the tip here, and holds steady for anything else.
|
|
92
|
-
|
|
93
|
-
## `false` is a geometry answer
|
|
94
|
-
|
|
95
|
-
`reposition()` returns `false` when it cannot place the element, an anchor
|
|
96
|
-
outside the boundary included. `tooltip.js` used to read that as the end of the
|
|
97
|
-
interaction and call `hideTip()`, which stopped position tracking.
|
|
98
|
-
|
|
99
|
-
A keyboard-focused trigger keeps its focus when scrolled past the boundary.
|
|
100
|
-
Scrolling back produces no new `focusin`, so the existing tracker must bring
|
|
101
|
-
the tooltip back.
|
|
102
|
-
|
|
103
|
-
So the runtime now keeps two states. `wanted` is what the interaction asks for
|
|
104
|
-
and only `hideTip()` clears it; `visible` is what is promoted. An
|
|
105
|
-
unpositionable tip is demoted and stays tracked, and the next tick that can
|
|
106
|
-
place it brings it back up.
|
|
107
|
-
|
|
108
|
-
`floating` was deliberately left out of this: no `{ positioned, reason }`
|
|
109
|
-
return, no option. Its README already documents the pattern — a failed
|
|
110
|
-
positioning may be temporary without `autoUpdate()` being stopped.
|
|
111
|
-
|
|
112
|
-
## Surfaces share geometry, not lifecycle
|
|
113
|
-
|
|
114
|
-
Element-anchored surfaces use the same coupled coordinate and CSS position mode
|
|
115
|
-
as tooltips. Point-positioned surfaces stay fixed because their `x` and `y` are
|
|
116
|
-
client coordinates. A nested scroll container remains a separate boundary:
|
|
117
|
-
document coordinates move natively with page scroll, while container scroll
|
|
118
|
-
still waits for `autoUpdate()` to correct the placement.
|
|
119
|
-
|
|
120
|
-
A surface that fits inside its boundary must not create scrollable overflow
|
|
121
|
-
merely because it uses document coordinates. This is not a guarantee for an
|
|
122
|
-
arbitrarily large custom surface: the positioner deliberately accepts overflow
|
|
123
|
-
when no placement can physically contain it.
|
|
124
|
-
|
|
125
|
-
`surface.js` still closes on `false`, and that stays a separate decision. A
|
|
126
|
-
flyout close restores focus, fires an event and releases an Escape entry;
|
|
127
|
-
hiding one while its trigger is off-boundary would leave a panel the user
|
|
128
|
-
cannot see holding all three. The prerequisite named in
|
|
129
|
-
[css-anchor](css-anchor.md) — "an out-of-view surface hides instead of closing"
|
|
130
|
-
— is a component decision, and it has been taken for tooltips only.
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
# Widget primitives
|
|
2
|
-
|
|
3
|
-
The JS runtime doubles as a primitive kit for building custom widgets.
|
|
4
|
-
|
|
5
|
-
## Primitives
|
|
6
|
-
|
|
7
|
-
| Need | Primitive | Import |
|
|
8
|
-
| ---------------------------------- | ------------- | --------------------------- |
|
|
9
|
-
| Discovery, lifecycle, cleanup | `enhance` | `actual-css/js/enhance` |
|
|
10
|
-
| Per-document LIFO Escape dismissal | `escape` | `actual-css/js/escape` |
|
|
11
|
-
| Positioning, flip and shift | `floating` | `@lekoala/floating` |
|
|
12
|
-
| Open/close, dismissal, focus | `surface` | `actual-css/js/surface` |
|
|
13
|
-
| Directional item lookup | `keys` | `actual-css/js/keys` |
|
|
14
|
-
| Menu-item vocabulary | `menu` | `actual-css/js/menu` |
|
|
15
|
-
| Focusable lookup, visibility | `focus` | `actual-css/js/focus` |
|
|
16
|
-
| One remembered tab stop | `focus-group` | `actual-css/js/focus-group` |
|
|
17
|
-
| Caret-safe value rewriting | `input` | `actual-css/js/input` |
|
|
18
|
-
| Character policies | `filter` | `actual-css/js/filter` |
|
|
19
|
-
| Event namespace | `events` | `actual-css/js/events` |
|
|
20
|
-
| Declarative triggers | `command` | `actual-css/js/command` |
|
|
21
|
-
| State classes the runtime writes | `selectors` | `actual-css/js/selectors` |
|
|
22
|
-
|
|
23
|
-
The named exports each module carries:
|
|
24
|
-
|
|
25
|
-
- `enhance` — `enhance`, `registerEnhancement`, `applyEnhancement`
|
|
26
|
-
- `escape` — `registerEscapeDismissal`
|
|
27
|
-
- `floating` — `autoUpdate`, `reposition`, `repositionAt`, plus
|
|
28
|
-
`--available-height` and `data-placement`
|
|
29
|
-
- `keys` — `itemForKey`, `firstItem`, `lastItem`, `nextItem`, with edge,
|
|
30
|
-
wrapping and RTL handling
|
|
31
|
-
- `focus-group` — `connectFocusGroup`
|
|
32
|
-
- `input` — `onTextInput`, `setCaret`, `dispatchInput`
|
|
33
|
-
- `events` — `EVENTS`, `ACTUAL_EVENT_PREFIX`
|
|
34
|
-
- `command` — `registerCommands`
|
|
35
|
-
- `selectors` — `CLASSES`
|
|
36
|
-
|
|
37
|
-
`surface` also owns outside-click and Escape dismissal, and focus restore.
|
|
38
|
-
A click on an element with `data-flyout-close` closes the open panel around
|
|
39
|
-
it, whichever widget opened that panel. The attribute keeps the `flyout` name
|
|
40
|
-
because the panels authors write are flyouts; `surface` is only the code that
|
|
41
|
-
opens and closes them.
|
|
42
|
-
`menu` filters to usable items.
|
|
43
|
-
|
|
44
|
-
## Focus group
|
|
45
|
-
|
|
46
|
-
`connectFocusGroup(root, options)` gives a composite one remembered tab stop and
|
|
47
|
-
Arrow/Home/End navigation. The consumer supplies `getItems()` because candidate
|
|
48
|
-
discovery and disabled semantics belong to the widget, not to the controller.
|
|
49
|
-
The controller updates only `tabindex` and focus; it does not activate controls
|
|
50
|
-
or write ARIA and application state.
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
import { connectFocusGroup } from "actual-css/js/focus-group";
|
|
54
|
-
|
|
55
|
-
const focusGroup = connectFocusGroup(toolbar, {
|
|
56
|
-
getItems: () => toolbar.querySelectorAll(":scope > button:not(:disabled)"),
|
|
57
|
-
orientation: "horizontal",
|
|
58
|
-
wrap: false,
|
|
59
|
-
signal,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Call this after changing which controls belong to the group.
|
|
63
|
-
focusGroup.sync();
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Candidates are re-read when focus or keyboard input occurs. A consumer that
|
|
67
|
-
changes the candidate list calls `focusGroup.sync()` explicitly; the primitive
|
|
68
|
-
does not observe the subtree. A plain `sync()` preserves the remembered item
|
|
69
|
-
when possible; `sync(item)` explicitly makes an item the group's tab stop.
|
|
70
|
-
Horizontal navigation follows the root's effective text direction.
|
|
71
|
-
`focusGroup.disconnect()` removes its listeners and restores authored
|
|
72
|
-
`tabindex` values. This is a JavaScript responsibility primitive, not a
|
|
73
|
-
`focusgroup` attribute or enhancement token.
|
|
74
|
-
|
|
75
|
-
`menu` consumes this primitive only for `[role="menu"]`. Plain `.menu` action
|
|
76
|
-
lists retain normal tab stops and use the menu layer's lighter directional
|
|
77
|
-
focus behavior.
|
|
78
|
-
|
|
79
|
-
## Compositions
|
|
80
|
-
|
|
81
|
-
### Custom select — A. Owns its popup
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
enhance
|
|
85
|
-
floating
|
|
86
|
-
keys
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Full control. Everything re-implemented. Use when the widget must own dismissal (e.g.
|
|
90
|
-
an inline autocomplete that should survive an outside click).
|
|
91
|
-
|
|
92
|
-
### Custom select — B. Reuses the surface lifecycle
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
enhance
|
|
96
|
-
surface (Escape, outside click, focus restore)
|
|
97
|
-
floating
|
|
98
|
-
keys
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
Less code. Inherits the runtime's dismissal semantics. Use for
|
|
102
|
-
anything that behaves like a popup.
|
|
103
|
-
|
|
104
|
-
> A `[role="listbox"]` surface with `[role="option"]` children gets no key handling and
|
|
105
|
-
> no click-autoclose from `surface.js` — that is the extension seam. `[role="option"]`
|
|
106
|
-
> is deliberately not in the menu-item vocabulary.
|
|
107
|
-
|
|
108
|
-
### Tags input
|
|
109
|
-
|
|
110
|
-
```
|
|
111
|
-
enhance + input + keys + filter (optional character policy)
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
No floating, no surface.
|
|
115
|
-
|
|
116
|
-
### Date picker
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
enhance + surface + floating + keys + events
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
A calendar popup wants Escape/outside-click/sheet. `actual:surface-open` to veto or
|
|
123
|
-
decorate.
|
|
124
|
-
|
|
125
|
-
## What "no Actual class" actually promises
|
|
126
|
-
|
|
127
|
-
> No Actual presentation or component class is required in authored markup for behavior to
|
|
128
|
-
> work. Runtime state classes are still written by the primitives, and remapping them is
|
|
129
|
-
> what `selectors.js` is for.
|
|
130
|
-
|
|
131
|
-
Concretely: no `.flyout`, `.tabs`, `.field`, `.btn`, `.needs-validation`, `.status-bar`
|
|
132
|
-
anywhere in the author's HTML — while `.is-open` may appear in the author's *CSS*, as a
|
|
133
|
-
state to style or ignore.
|
|
134
|
-
|
|
135
|
-
## Honest gaps
|
|
136
|
-
|
|
137
|
-
- No nested surfaces — one Actual surface is open per document, and opening one
|
|
138
|
-
closes the rest. A widget that needs a second level owns its own popup
|
|
139
|
-
(composition A above).
|
|
140
|
-
- No typeahead helper — filter, debounce, render are author concerns.
|
|
141
|
-
- No `aria-activedescendant` helper — the author manages the composite-widget pattern.
|
|
142
|
-
- No virtual-list support.
|
|
143
|
-
- No `<select>` replacement in core — the deliverable is the *surface*, not the widget.
|
|
144
|
-
`<select data-enhance="select">` is the intended shape for an external package.
|