actual-css 0.19.4 → 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 +8 -0
- package/README.md +2 -2
- package/dist/actual.full.css +6 -2
- package/dist/actual.full.min.css +1 -1
- package/docs/pages/forms/joined-controls.md +1 -1
- package/docs/pages/forms/switch.md +4 -2
- 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/forms/switch.css +6 -2
- package/src/tooling/theme-contrast.js +6 -2
- package/docs/design-notes/accessibility-decisions.md +0 -63
- 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,74 +0,0 @@
|
|
|
1
|
-
# Cascade layer strategy
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
|
|
5
|
-
Actual CSS is designed for new projects where its bare class names don't
|
|
6
|
-
conflict. For existing projects that need coexistence, `actual.layer.css`
|
|
7
|
-
wraps the core entrypoint in a single `@layer actual` so its specificity
|
|
8
|
-
is lower than unlayered author styles. `actual.layer.css` is layered core —
|
|
9
|
-
it does not include the functional families. Use it as the base and import
|
|
10
|
-
the families you need from `actual-css/css/*` outside the layer.
|
|
11
|
-
|
|
12
|
-
## Usage
|
|
13
|
-
|
|
14
|
-
`actual.layer.css` wraps only the core entrypoint in the layer. The family
|
|
15
|
-
manifests (components, forms, layout, …) are imported separately, outside the
|
|
16
|
-
layer by default:
|
|
17
|
-
|
|
18
|
-
```css
|
|
19
|
-
/* Before — classes may override existing project styles */
|
|
20
|
-
@import "actual-css";
|
|
21
|
-
|
|
22
|
-
/* After — core rules are scoped to the `actual` layer */
|
|
23
|
-
@import "actual-css/css/layer";
|
|
24
|
-
@import "actual-css/css/layout";
|
|
25
|
-
@import "actual-css/css/forms";
|
|
26
|
-
@import "actual-css/css/components";
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Author styles outside any layer will win over layer styles with equal
|
|
30
|
-
specificity.
|
|
31
|
-
|
|
32
|
-
For an existing project, the collisions that matter are component classes
|
|
33
|
-
(`.card`, `.btn`, `.grid`, `.input`, `.navbar`), not the core tokens. If the
|
|
34
|
-
whole framework must sit below the project's own styles, layer the full bundle
|
|
35
|
-
in the project entrypoint:
|
|
36
|
-
|
|
37
|
-
```css
|
|
38
|
-
@layer actual;
|
|
39
|
-
@import "actual-css/full" layer(actual);
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
There is no separate `full`-layer bundle; the two declarations above are the
|
|
43
|
-
official recipe.
|
|
44
|
-
|
|
45
|
-
## Layer structure
|
|
46
|
-
|
|
47
|
-
A single `actual` layer. The internal import order is a contract: later imports
|
|
48
|
-
can override earlier ones within the layer. Sublayers (`actual.reset`,
|
|
49
|
-
`actual.components`, etc.) are reserved for future use if the single layer
|
|
50
|
-
causes real-world override issues.
|
|
51
|
-
|
|
52
|
-
## Import order contract
|
|
53
|
-
|
|
54
|
-
Within `actual.css` (the minimal core) the order is:
|
|
55
|
-
|
|
56
|
-
1. Reset
|
|
57
|
-
2. Tokens
|
|
58
|
-
3. Theme
|
|
59
|
-
4. Base (document defaults)
|
|
60
|
-
5. Intents
|
|
61
|
-
6. Variants
|
|
62
|
-
7. Focus
|
|
63
|
-
8. Print
|
|
64
|
-
|
|
65
|
-
This order is stable. If a future version introduces sublayers, the relative
|
|
66
|
-
order will be preserved.
|
|
67
|
-
|
|
68
|
-
## Limitations
|
|
69
|
-
|
|
70
|
-
- `actual.layer.css` cannot protect against conflicts with other layered
|
|
71
|
-
frameworks that also use `@layer actual`. If both projects use the same
|
|
72
|
-
layer name, the later `@layer` declaration wins.
|
|
73
|
-
- The layer applies only when importing from `actual.layer.css`. Direct
|
|
74
|
-
imports of individual files bypass the layer.
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
# Explicit Column Layout
|
|
2
|
-
|
|
3
|
-
## Problem
|
|
4
|
-
|
|
5
|
-
Actual CSS already provides several layout primitives with distinct responsive contracts:
|
|
6
|
-
|
|
7
|
-
* `.grid` for intrinsic collections whose item width drives reflow;
|
|
8
|
-
* `.grid-N` for equal-width structural collections with a known peer density;
|
|
9
|
-
* `.switcher` for peer regions that must switch together between horizontal and stacked layouts;
|
|
10
|
-
* `.sidebar-layout` for main content paired with a secondary region;
|
|
11
|
-
* `.media` for media paired with flexible content.
|
|
12
|
-
|
|
13
|
-
These primitives intentionally encode common layout relationships rather than exposing a general coordinate system.
|
|
14
|
-
|
|
15
|
-
There is still one legitimate case they do not cover well: **explicit composition where the placement of individual regions is itself part of the design**.
|
|
16
|
-
|
|
17
|
-
Examples include:
|
|
18
|
-
|
|
19
|
-
* an 8-column main region beside a 4-column supporting region;
|
|
20
|
-
* a centered 10-column article starting on column 2;
|
|
21
|
-
* a 3 / 6 / 3 application shell;
|
|
22
|
-
* editorial or dashboard compositions where regions must align to a shared column canvas.
|
|
23
|
-
|
|
24
|
-
These layouts can be expressed with `--grid-columns` and application-specific `grid-column` rules, but that gives no shared canvas and makes every application redefine the same conventions — including the auto-placement trap described below.
|
|
25
|
-
|
|
26
|
-
## Decision
|
|
27
|
-
|
|
28
|
-
An opt-in 12-column horizontal composition primitive, placed through two hooks on each direct child:
|
|
29
|
-
|
|
30
|
-
```css
|
|
31
|
-
.column-layout {
|
|
32
|
-
display: grid;
|
|
33
|
-
gap: var(--gap);
|
|
34
|
-
grid-template-columns: repeat(12, minmax(0, 1fr));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
:where(.column-layout) > * {
|
|
38
|
-
--column-start: initial;
|
|
39
|
-
--column-span: initial;
|
|
40
|
-
|
|
41
|
-
grid-column-start: var(--column-start, auto);
|
|
42
|
-
grid-column-end: span var(--column-span, calc(13 - var(--column-start, 1)));
|
|
43
|
-
min-inline-size: 0;
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
```css
|
|
48
|
-
.main {
|
|
49
|
-
--column-span: 8;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.aside {
|
|
53
|
-
--column-span: 4;
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
The public API is one class and two hooks. No responsive behavior is implied. No row placement, ordering, named areas, breakpoint variants, offsets, or configurable column counts are part of the primitive.
|
|
58
|
-
|
|
59
|
-
## Why hooks rather than placement classes
|
|
60
|
-
|
|
61
|
-
A span and a start are two numbers. As classes they need twenty-four adapters (`.column-span-1` … `.column-start-12`) to encode CSS coordinates, and those adapters interact: a start class must also set the end line so it can stand alone, a span class must refine that end, and the only thing separating them at zero specificity is source order. The primitive then depended on a file order no browser reports when it breaks, guarded by a test whose only job was that order.
|
|
62
|
-
|
|
63
|
-
As custom properties the two inputs are independent. One rule reads both, and there is nothing to order.
|
|
64
|
-
|
|
65
|
-
Recomposition also stays inside the primitive's API. With classes, an application's container query had to leave the vocabulary and write `grid-column` itself. With hooks, it sets the same two properties the region was placed with.
|
|
66
|
-
|
|
67
|
-
The API does not require inline styles. The documented form puts the hooks on an application class; `style="--column-span: 8"` is a shortcut for a composition that never changes. An inline value outranks every rule, so coordinates that a container query recomposes belong on a class.
|
|
68
|
-
|
|
69
|
-
## One rule, four placements
|
|
70
|
-
|
|
71
|
-
```text
|
|
72
|
-
neither set start auto, span 12 auto-placed, full canvas
|
|
73
|
-
span only start auto, span N auto-placed over N units
|
|
74
|
-
start only start S, span 13 - S from line S to the canvas end
|
|
75
|
-
start and span start S, span N explicit
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### The start defaults to `auto`
|
|
79
|
-
|
|
80
|
-
The obvious way to write "full canvas" is `grid-column: 1 / -1`. It gives every child a **definite** column start of line 1, which removes it from column auto-placement. Two placed peers then both resolve to column 1 and the second is pushed to the next row:
|
|
81
|
-
|
|
82
|
-
```text
|
|
83
|
-
<section style="--column-span: 8"> row 1, columns 1-8
|
|
84
|
-
<aside style="--column-span: 4"> row 2, columns 1-4 ← not 9-12
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Measured, not reasoned: the pair renders on two rows with a definite default start and on one row with an `auto` start, which `tests/browser/column-layout.test.js` asserts. Keeping the start `auto` until an author sets it lets auto-placement flow peers across the canvas.
|
|
88
|
-
|
|
89
|
-
### A start alone runs to the edge
|
|
90
|
-
|
|
91
|
-
With a fixed `span 12` default, `--column-start: 9` would place a region across lines 9 to 21 and add nine implicit columns. The span fallback is therefore derived from the start, `calc(13 - start)`, so a start alone always ends on the canvas edge. With no start, the same expression resolves to `span 12`.
|
|
92
|
-
|
|
93
|
-
`calc()` in an integer position resolves to a whole number once `var()` is substituted. Support for `calc()` in number contexts predates the CSS floor by years (Chrome 31, Firefox 48, Safari 6); the browser tests prove the four placements in Chromium.
|
|
94
|
-
|
|
95
|
-
### Coordinates are local to the grid item
|
|
96
|
-
|
|
97
|
-
Custom properties inherit. A nested `.column-layout` placed with `--column-start: 3; --column-span: 8` would hand those values to each of its own children, which would all land on line 3.
|
|
98
|
-
|
|
99
|
-
The reset is declared on each child, not on the canvas: the nested canvas needs its coordinates for its own position in the parent, and its children must start from nothing. `--column-start: initial` makes the property guaranteed-invalid, so `var()` takes its fallback. The rule has zero specificity, so any author rule on the child wins.
|
|
100
|
-
|
|
101
|
-
`@property { inherits: false }` would express the same thing, but it is above the CSS floor and two declarations already do the job.
|
|
102
|
-
|
|
103
|
-
## Why this is separate from `.grid`
|
|
104
|
-
|
|
105
|
-
`.grid` and `.grid-N` are collection primitives. They answer:
|
|
106
|
-
|
|
107
|
-
> How many peer items should fit here?
|
|
108
|
-
|
|
109
|
-
`.column-layout` answers a different question:
|
|
110
|
-
|
|
111
|
-
> Where should these distinct regions sit on a shared composition canvas?
|
|
112
|
-
|
|
113
|
-
A layout that happens to contain three regions is not automatically a column layout. If those regions are peers that should switch together, `.switcher` is the correct primitive. If one region is secondary to another, `.sidebar-layout` is usually the better choice.
|
|
114
|
-
|
|
115
|
-
Use `.column-layout` because **placement is part of the design**, not merely because the design contains columns.
|
|
116
|
-
|
|
117
|
-
| Need | Primitive |
|
|
118
|
-
| ------------------------------------------------------ | ----------------- |
|
|
119
|
-
| Independent repeated items with intrinsic reflow | `.grid` |
|
|
120
|
-
| Equal-width peers with a known structural density | `.grid-N` |
|
|
121
|
-
| Peer regions that must switch together | `.switcher` |
|
|
122
|
-
| Main content with a secondary region | `.sidebar-layout` |
|
|
123
|
-
| Media paired with flexible content | `.media` |
|
|
124
|
-
| Explicit region placement on a shared 12-column canvas | `.column-layout` |
|
|
125
|
-
|
|
126
|
-
> If local CSS mainly makes one layout primitive behave like another, reconsider the primitive before adding more CSS.
|
|
127
|
-
|
|
128
|
-
## Why twelve columns
|
|
129
|
-
|
|
130
|
-
Twelve provides useful subdivisions without requiring a configurable grid system: `6 + 6`, `4 + 4 + 4`, `3 + 3 + 3 + 3`, `8 + 4`, `9 + 3`, `2 + 8 + 2`.
|
|
131
|
-
|
|
132
|
-
A configurable `--column-count` would weaken the shared canvas: a span of 8 would mean different widths in different layouts, and the start-only fallback would need the count too. Applications that genuinely require a different track system should use `--grid-columns`.
|
|
133
|
-
|
|
134
|
-
## Base recipe
|
|
135
|
-
|
|
136
|
-
`minmax(0, 1fr)` is an invariant, not responsive behavior. It prevents the track definition itself from creating a min-content floor that forces the layout wider than its container. It does **not** guarantee that arbitrary content remains usable inside a very narrow span; that is an application composition problem.
|
|
137
|
-
|
|
138
|
-
The track template never reads `--gap`, so `gap` and the track count are independent at every width. This is worth stating because an author who has read the grid page will reasonably assume the opposite.
|
|
139
|
-
|
|
140
|
-
## Exceeding the canvas
|
|
141
|
-
|
|
142
|
-
When combining a start and a span, the author keeps `start + span - 1 <= 12`. Actual CSS does not guard against invalid combinations, and the failure is worth stating precisely because it is not local.
|
|
143
|
-
|
|
144
|
-
When a placement exceeds the explicit canvas, CSS Grid adds implicit columns at the end. `grid-auto-columns` defaults to `auto`, so an implicit column is sized by its content while the twelve `1fr` tracks divide whatever inline size is left. Every region shifts, not just the one carrying the invalid placement.
|
|
145
|
-
|
|
146
|
-
A pair that does not fit *without* explicit starts wraps instead: two eight-unit regions occupy sixteen units, so the second moves to the next row. That is correct grid behavior, not a canvas violation.
|
|
147
|
-
|
|
148
|
-
## Responsive contract
|
|
149
|
-
|
|
150
|
-
`.column-layout` has **no automatic responsive collapse**. Different compositions have different useful breakpoints:
|
|
151
|
-
|
|
152
|
-
* `8 + 4` may remain useful longer than `3 + 9`;
|
|
153
|
-
* a centered article may only need reduced side gutters;
|
|
154
|
-
* a dashboard may recombine from three regions into two before eventually stacking;
|
|
155
|
-
* an editorial layout may switch to a completely different representation on narrow screens.
|
|
156
|
-
|
|
157
|
-
A single framework threshold would be arbitrary, and a hidden one would force authors to undo it before writing their own. The author owns narrow-container behavior, and writes it with the same hooks:
|
|
158
|
-
|
|
159
|
-
```css
|
|
160
|
-
@container (width < 48rem) {
|
|
161
|
-
.profile-main {
|
|
162
|
-
--column-start: 1;
|
|
163
|
-
--column-span: 6;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.profile-aside {
|
|
167
|
-
--column-start: 7;
|
|
168
|
-
--column-span: 6;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
@container (width < 32rem) {
|
|
173
|
-
.profile-main,
|
|
174
|
-
.profile-aside {
|
|
175
|
-
--column-start: 1;
|
|
176
|
-
--column-span: 12;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
The ability to recompose through intermediate states is part of the value of a coordinate system; the framework should not reduce every narrow layout to a single automatic stack.
|
|
182
|
-
|
|
183
|
-
`.container-query` is not required by `.column-layout`. An author uses it because their own rules use `@container` — the author uses a query container because the author wrote a container query.
|
|
184
|
-
|
|
185
|
-
## Narrow containers
|
|
186
|
-
|
|
187
|
-
With the default `--gap: 0.75rem` and a container measuring 279px at a 360px viewport, the eleven gaps take 132px. The twelve tracks divide the remaining 147px, roughly **12px per unit**: a four-unit region is 84px wide.
|
|
188
|
-
|
|
189
|
-
That number is the argument. There is no useful composition to guess at that width, which is precisely why the primitive does not try. For intrinsic responsive behavior, prefer `.grid`, `.switcher`, or `.sidebar-layout`.
|
|
190
|
-
|
|
191
|
-
## One-dimensional scope
|
|
192
|
-
|
|
193
|
-
Despite being implemented with CSS Grid, `.column-layout` exposes only horizontal column placement. There are no row, area, end-line, or order hooks. Applications remain free to use native CSS Grid where a genuinely two-dimensional composition requires it:
|
|
194
|
-
|
|
195
|
-
```css
|
|
196
|
-
.dashboard-summary {
|
|
197
|
-
grid-row: 1 / span 2;
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
Keeping the API one-dimensional prevents the primitive from growing into a general-purpose grid DSL.
|
|
202
|
-
|
|
203
|
-
Visual reordering has consequences for reading order, keyboard navigation, and accessibility, and is not specific to this primitive. Authors should prefer DOM order that stays sensible when the composition changes.
|
|
204
|
-
|
|
205
|
-
## Direct-child box requirement
|
|
206
|
-
|
|
207
|
-
Placement applies to grid items. A direct child carrying coordinates must generate a box: with `display: contents`, its own box is removed, its descendants become grid items, and the coordinates no longer control them.
|
|
208
|
-
|
|
209
|
-
## Why this is opt-in
|
|
210
|
-
|
|
211
|
-
A general coordinate system is easy to misuse. Given `main + aside`, it is tempting to write an 8 + 4 composition even when `.sidebar-layout` already expresses the relationship with intrinsic responsive behavior. Likewise, three peer panels should not become three four-unit regions merely because the canvas makes that possible.
|
|
212
|
-
|
|
213
|
-
The primitive belongs to the Layout family but is not part of the core baseline, and its documentation makes the selection boundary explicit.
|
|
214
|
-
|
|
215
|
-
## Rejected alternatives
|
|
216
|
-
|
|
217
|
-
### Placement classes (`.column-span-N`, `.column-start-N`)
|
|
218
|
-
|
|
219
|
-
Rejected. Twenty-four classes encode two numbers, the start and span classes must be ordered in the source for a start alone to end on the canvas edge, and application recomposition has to leave the vocabulary to write `grid-column`. See [Why hooks rather than placement classes](#why-hooks-rather-than-placement-classes).
|
|
220
|
-
|
|
221
|
-
### Reset the hooks on the canvas
|
|
222
|
-
|
|
223
|
-
Rejected. A nested canvas is also a grid item of its parent; resetting on `.column-layout` would erase the coordinates it needs for its own placement.
|
|
224
|
-
|
|
225
|
-
### `@property` with `inherits: false`
|
|
226
|
-
|
|
227
|
-
Rejected for the base contract: above the CSS floor, and the per-child reset already keeps coordinates local.
|
|
228
|
-
|
|
229
|
-
### Make `.grid-N` support arbitrary spans
|
|
230
|
-
|
|
231
|
-
Rejected. `.grid-N` represents structural peer density. Arbitrary child placement would blur the distinction between a collection and a composition canvas.
|
|
232
|
-
|
|
233
|
-
### Use `.layout-grid` or `.columns`
|
|
234
|
-
|
|
235
|
-
Rejected. `.layout-grid` is confusing beside `.grid` and `.grid-N`; `.columns` is too generic and reads as CSS multi-column layout.
|
|
236
|
-
|
|
237
|
-
### Add `--column-count`
|
|
238
|
-
|
|
239
|
-
Rejected. Twelve columns are part of the primitive's contract.
|
|
240
|
-
|
|
241
|
-
### Add automatic container-query collapse, breakpoint variants, or offsets
|
|
242
|
-
|
|
243
|
-
Rejected. There is no universally correct threshold; breakpoint variants would move responsive strategy back into markup; `--column-start` already expresses native grid placement without a second, margin-based model.
|
|
244
|
-
|
|
245
|
-
### Add row placement, named areas, or ordering
|
|
246
|
-
|
|
247
|
-
Rejected for this scope. Row placement and areas belong to native Grid on an application class; ordering carries separate accessibility concerns.
|
|
248
|
-
|
|
249
|
-
## Decision summary
|
|
250
|
-
|
|
251
|
-
The primitive:
|
|
252
|
-
|
|
253
|
-
* uses twelve equal `minmax(0, 1fr)` tracks;
|
|
254
|
-
* places each direct child from `--column-start` and `--column-span`, in one rule;
|
|
255
|
-
* keeps the start `auto` until set, so auto-placement composes spans;
|
|
256
|
-
* derives the default span from the start, so a start alone ends on the canvas edge;
|
|
257
|
-
* resets both hooks on each child, so coordinates never leak into a nested canvas;
|
|
258
|
-
* provides no automatic responsive behavior and leaves recomposition to the application, through the same hooks;
|
|
259
|
-
* remains horizontal-only;
|
|
260
|
-
* complements rather than replaces `.grid`, `.grid-N`, `.switcher`, `.sidebar-layout`, and `.media`.
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# CSS anchor positioning
|
|
2
|
-
|
|
3
|
-
Placement stays in JavaScript. This note records why, so the question is not
|
|
4
|
-
reopened on browser-support figures alone.
|
|
5
|
-
|
|
6
|
-
## What owns placement today
|
|
7
|
-
|
|
8
|
-
`@lekoala/floating` positions every anchored surface. `surface.js` calls
|
|
9
|
-
`reposition()` for an element anchor and `repositionAt()` for a pointer
|
|
10
|
-
coordinate, both inside an `autoUpdate()` loop.
|
|
11
|
-
|
|
12
|
-
The positioner is not only a placement engine. It writes outputs the components
|
|
13
|
-
read as ordinary CSS:
|
|
14
|
-
|
|
15
|
-
```text
|
|
16
|
-
left / top the placement itself
|
|
17
|
-
data-placement resolved side, after flip
|
|
18
|
-
--arrow-x / --arrow-y arrow offset along the panel edge
|
|
19
|
-
--available-height space left for the panel
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
`tooltip.css` draws its arrow from `data-placement` and `--arrow-x/-y`;
|
|
23
|
-
`flyout.css` caps its panel with `--available-height`. Replacing the engine
|
|
24
|
-
means replacing those, not only the coordinates.
|
|
25
|
-
|
|
26
|
-
## The blocker is not support
|
|
27
|
-
|
|
28
|
-
Support is the obvious gate and the wrong one. The blocking output is the one
|
|
29
|
-
that is not CSS at all — the positioner's return value:
|
|
30
|
-
|
|
31
|
-
```js
|
|
32
|
-
if (!positionSurface(menu)) closeSurface(menu); // surface.js
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
`reposition()` returns `false` when positioning cannot be performed: a hidden
|
|
36
|
-
floating element, a missing reference rect, an anchor outside the boundary, or
|
|
37
|
-
a document with no browsing context. `surface.js` runs that check on every
|
|
38
|
-
`autoUpdate` tick, so an anchor that leaves its boundary **closes** the surface.
|
|
39
|
-
|
|
40
|
-
CSS anchor positioning offers no equivalent signal. `position-try-fallbacks`
|
|
41
|
-
re-places the box and `position-visibility` can hide it, but hiding is not
|
|
42
|
-
closing: no event fires, `.is-open` stays set, focus is never restored, and the
|
|
43
|
-
Escape stack keeps an entry for a panel the user can no longer see.
|
|
44
|
-
|
|
45
|
-
This is the boundary the manual Popover transport was adopted on, in the other
|
|
46
|
-
direction — a capability takes one responsibility without being handed the
|
|
47
|
-
neighbouring one. See [platform-alignment](platform-alignment.md).
|
|
48
|
-
|
|
49
|
-
## The pointer-coordinate case
|
|
50
|
-
|
|
51
|
-
Context menus open at `clientX`/`clientY`, not at a DOM element
|
|
52
|
-
(`context-menu.js` stores the point, `surface.js` passes it to
|
|
53
|
-
`repositionAt()`). Anchor positioning anchors to elements, so this path needs a
|
|
54
|
-
script layer whatever happens to the element-anchored one. Adoption would split
|
|
55
|
-
the positioner in two rather than delete it.
|
|
56
|
-
|
|
57
|
-
## The one output with a declarative equivalent
|
|
58
|
-
|
|
59
|
-
`--surface-anchor-width` is measured from the trigger's rect on every
|
|
60
|
-
reposition, solely so a flyout can match its trigger's width. `anchor-size()`
|
|
61
|
-
expresses that relationship directly and would remove both the measurement and
|
|
62
|
-
the property.
|
|
63
|
-
|
|
64
|
-
It is not free either: the panel would need an `anchor-name` on its trigger and
|
|
65
|
-
a `position-anchor` written at runtime, which is the same plumbing the
|
|
66
|
-
positioner already does. Worth doing only alongside a wider move, not as a
|
|
67
|
-
standalone saving.
|
|
68
|
-
|
|
69
|
-
## What would unblock the move
|
|
70
|
-
|
|
71
|
-
One of:
|
|
72
|
-
|
|
73
|
-
- a script-observable anchor-visibility signal, so the lifecycle keeps its
|
|
74
|
-
close decision while CSS takes the geometry; or
|
|
75
|
-
- a deliberate contract change — an out-of-view surface hides instead of
|
|
76
|
-
closing. That is a component decision, not a transport swap, and it has the
|
|
77
|
-
same shape as the `popover="auto"` rejection in
|
|
78
|
-
[popover-manual-poc](popover-manual-poc.md). It has been taken for tooltips,
|
|
79
|
-
which have no focus restoration, event or Escape entry to lose — see
|
|
80
|
-
[tooltip-coordinate-space](tooltip-coordinate-space.md).
|
|
81
|
-
|
|
82
|
-
Browser support is a precondition for either, never the trigger on its own.
|
|
83
|
-
|
|
84
|
-
## Review trigger
|
|
85
|
-
|
|
86
|
-
Revisit when a script-observable anchor-visibility signal appears, or when a
|
|
87
|
-
project need makes hide-instead-of-close the wanted behavior.
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
# Enhancement contract
|
|
2
|
-
|
|
3
|
-
Actual CSS splits CSS and JavaScript into two independent layers with a shared
|
|
4
|
-
opt-in mechanism. Every component uses the same grammar.
|
|
5
|
-
|
|
6
|
-
## Popover ownership
|
|
7
|
-
|
|
8
|
-
The runtime owns `popover="manual"` and native show/hide calls on managed
|
|
9
|
-
surfaces and tooltips. Native automatic dismissal would compete with Actual's
|
|
10
|
-
close policy. Canceling `beforetoggle` would leave the runtime's open state
|
|
11
|
-
out of sync with platform visibility, so applications cancel
|
|
12
|
-
`actual:surface-open` before promotion instead.
|
|
13
|
-
|
|
14
|
-
Explicit tooltips stay in place to preserve inherited context. Generated
|
|
15
|
-
tooltips are mounted outside the trigger's sibling sequence: inserting one
|
|
16
|
-
beside the trigger would change structural selectors such as
|
|
17
|
-
`.join > :last-child`. Generated tooltips therefore make no promise to inherit
|
|
18
|
-
the trigger's theme or density.
|
|
19
|
-
|
|
20
|
-
## The four-layer contract
|
|
21
|
-
|
|
22
|
-
```text
|
|
23
|
-
class = presentation (.tabs, .flyout, .needs-validation)
|
|
24
|
-
data-enhance = JavaScript behavior (data-enhance="tabs")
|
|
25
|
-
ARIA / HTML = semantics (role="tab", aria-controls, hidden)
|
|
26
|
-
data-* = behavior configuration (data-mask, data-tooltip, data-filter)
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
The duplication is deliberate:
|
|
30
|
-
|
|
31
|
-
```html
|
|
32
|
-
<div class="tabs" data-enhance="tabs" role="tablist">
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
- `.tabs` opts into the Actual CSS presentation;
|
|
36
|
-
- `data-enhance="tabs"` opts into the JavaScript behavior;
|
|
37
|
-
- `role="tablist"` declares semantics to assistive technology.
|
|
38
|
-
|
|
39
|
-
Each layer can be removed independently:
|
|
40
|
-
|
|
41
|
-
```html
|
|
42
|
-
<!-- CSS only: no JS behavior, just styling -->
|
|
43
|
-
<div class="tabs" role="tablist">…</div>
|
|
44
|
-
|
|
45
|
-
<!-- JS only: custom CSS, Actual behavior -->
|
|
46
|
-
<div class="my-tabs" data-enhance="tabs" role="tablist">…</div>
|
|
47
|
-
|
|
48
|
-
<!-- Both: standard Actual look and behavior -->
|
|
49
|
-
<div class="tabs" data-enhance="tabs" role="tablist">…</div>
|
|
50
|
-
|
|
51
|
-
<!-- Semantic only: author handles everything else -->
|
|
52
|
-
<div role="tablist">…</div>
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## `data-enhance` grammar
|
|
56
|
-
|
|
57
|
-
Tokens are whitespace-separated, matched with the `~=` attribute selector, case-sensitive,
|
|
58
|
-
and must match `[a-z][a-z0-9-]*`. Order is irrelevant; duplicates are harmless.
|
|
59
|
-
|
|
60
|
-
```html
|
|
61
|
-
<form data-enhance="validation autosubmit"> <!-- two behaviors -->
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
`applyEnhancement()` is an application-owned authoring convenience: it writes
|
|
65
|
-
the same tokens and refreshes their containing registrations. It does not watch
|
|
66
|
-
presentation classes or establish a second discovery contract. Walking the
|
|
67
|
-
scope's ancestors finds lifecycle owners even when the query scope is narrower
|
|
68
|
-
than the registration root, without crossing shadow boundaries.
|
|
69
|
-
|
|
70
|
-
## When a token, when a `data-*`
|
|
71
|
-
|
|
72
|
-
> `data-enhance` is a generic opt-in for when HTML does not already provide an unambiguous one.
|
|
73
|
-
|
|
74
|
-
- **A token** is for a named behavior whose opt-in carries no configuration,
|
|
75
|
-
whether it owns a subtree or enhances one leaf (tabs, flyout, range,
|
|
76
|
-
scrollspy, validation).
|
|
77
|
-
- **A self-describing `data-*`** is for a leaf whose attribute is simultaneously
|
|
78
|
-
the opt-in and the configuration (`data-tooltip`, `data-mask`, `data-filter`,
|
|
79
|
-
`data-context-menu`).
|
|
80
|
-
- **Elements that are their own opt-in** need nothing (`<dialog>` outside a
|
|
81
|
-
Web Component).
|
|
82
|
-
|
|
83
|
-
`data-enhance` is explicitly **not** a mandatory prefix for every module.
|
|
84
|
-
|
|
85
|
-
## One registration per enhancement per root
|
|
86
|
-
|
|
87
|
-
`registerEnhancement()` owns a name per root. Registering the same token twice
|
|
88
|
-
on the same root throws; `disconnect()` releases the name; re-registration
|
|
89
|
-
after disconnect is allowed; the same token on a different root is independent.
|
|
90
|
-
|
|
91
|
-
Named registrations share one `[data-enhance]` discovery gate per root: however
|
|
92
|
-
many behaviors are registered, the observer queries that single selector and
|
|
93
|
-
each registration matches its own `[data-enhance~="name"]` against what it finds.
|
|
94
|
-
`enhance()` records share the same observer and lifecycle with their arbitrary
|
|
95
|
-
selectors. Behaviors on one element start in no guaranteed order and must not
|
|
96
|
-
depend on each other.
|
|
97
|
-
|
|
98
|
-
`enhance()` stays generic and unguarded — registering the same selector twice
|
|
99
|
-
creates two independent records that both run.
|
|
100
|
-
|
|
101
|
-
The owner of a custom enhancement root must call `disconnect()` when disposing
|
|
102
|
-
that root; the default `document.documentElement` root is not affected.
|
|
103
|
-
|
|
104
|
-
`enhance(…, root)` owns the lifecycle boundary. It scans additions inside that
|
|
105
|
-
root, preserves instances moved within it, and requests cleanup once an instance
|
|
106
|
-
leaves it—even when the element remains connected elsewhere. An enhancer's
|
|
107
|
-
cleanup must therefore be authoritative and idempotent: it releases its state
|
|
108
|
-
when called and must not repeat the root-membership decision.
|
|
109
|
-
|
|
110
|
-
An optional `enhance()` acceptance predicate narrows lifecycle membership
|
|
111
|
-
without another observer. Discovery and the removal sweep recheck it, so moves
|
|
112
|
-
across a behavioral boundary clean up or initialize the element as needed.
|
|
113
|
-
|
|
114
|
-
Core lifecycle primitives accept a `Document`, `Element`, or `DocumentFragment`
|
|
115
|
-
root, and command targets resolve in the trigger's document or shadow root.
|
|
116
|
-
Built-in auto-registration observes the document tree. It does not discover or
|
|
117
|
-
manage built-ins created inside shadow roots. Applications that own a custom
|
|
118
|
-
root can install their own enhancements with the core APIs and must dispose
|
|
119
|
-
those registrations explicitly.
|
|
120
|
-
|
|
121
|
-
## Choosing a JavaScript primitive
|
|
122
|
-
|
|
123
|
-
- Use a command for an immediate trigger-to-current-target action. Commands
|
|
124
|
-
resolve the DOM at event time and do not own element lifecycle.
|
|
125
|
-
- Use `registerEnhancement()` for a named, opted-in behavior that owns listeners
|
|
126
|
-
or state for a subtree or leaf.
|
|
127
|
-
- Use `enhance()` for a self-describing leaf behavior that needs connection and
|
|
128
|
-
cleanup lifecycle without a named token.
|
|
129
|
-
- Prefer delegation when no persistent per-element state is required.
|
|
130
|
-
- Give instance-owned listeners an `AbortController`, and abort it from the
|
|
131
|
-
instance cleanup.
|
|
132
|
-
|
|
133
|
-
## CSS must never select on `data-enhance`
|
|
134
|
-
|
|
135
|
-
CSS rules must not select on `data-enhance` or the runtime marker
|
|
136
|
-
`data-actual-surface`. Selecting on either would make the CSS API depend on the JS API,
|
|
137
|
-
defeating the split.
|
|
138
|
-
|
|
139
|
-
## Design decisions recorded
|
|
140
|
-
|
|
141
|
-
**D2 — `selectors.js` drops its 5 discovery entries and keeps 9 state
|
|
142
|
-
entries.** The file's job changes from *CSS↔init bridge* to *state vocabulary
|
|
143
|
-
the runtime writes*. It stays the single file to alias for another CSS
|
|
144
|
-
framework.
|
|
145
|
-
|
|
146
|
-
**D4 — `status.js` uses `[data-status][role="status"]`, with no class and no
|
|
147
|
-
token.** The markup already carries `role="status"` everywhere, so semantics
|
|
148
|
-
alone scope the document-wide lookup.
|
|
149
|
-
|
|
150
|
-
**D5 — `<dialog>` is its own opt-in outside Web Components.** Custom-element
|
|
151
|
-
ancestors and shadow roots reserve lifecycle ownership for the component.
|
|
152
|
-
`data-enhance="dialog"` delegates it explicitly to Actual, independently of
|
|
153
|
-
presentation classes. Both discovery and dialog command resolution apply this
|
|
154
|
-
boundary; the command router leaves rejected targets' native clicks alone.
|
|
155
|
-
|
|
156
|
-
**D6 — `validation.js` accepts `[data-field-error]` as an alias for
|
|
157
|
-
`.field-error`, and keeps `.field` / `.danger` as an optional, degrading
|
|
158
|
-
presentation adapter.** Validation is the one module with intentional, optional
|
|
159
|
-
CSS coupling. The adapter degrades to a no-op under foreign CSS, while
|
|
160
|
-
`aria-invalid`, focus management, custom rules and server errors all keep
|
|
161
|
-
working.
|
|
162
|
-
|
|
163
|
-
**D7 — Context-menu reuses `surface`, not `flyout`.** The panel gets no token;
|
|
164
|
-
`menuFor()` validates semantically (`menu, [role="menu"]`). A context menu may
|
|
165
|
-
legitimately want the flyout *look* without the flyout *behavior*.
|
|
166
|
-
|
|
167
|
-
**D9 — An orphaned surface is torn down by a reaper observing
|
|
168
|
-
`data-actual-surface`.** `prepareSurface()` writes the marker; the reaper
|
|
169
|
-
closes and forgets a surface once it leaves the document. A `fix:`, not part
|
|
170
|
-
of the contract itself.
|
|
171
|
-
|
|
172
|
-
## Token vocabulary
|
|
173
|
-
|
|
174
|
-
| Token | Behavior | Existing class |
|
|
175
|
-
| ------------ | ------------------------------------------------ | ------------------------ |
|
|
176
|
-
| `tabs` | Tab panel switching, arrow-key navigation | `.tabs` |
|
|
177
|
-
| `flyout` | Trigger → panel positioning, open/close | `.flyout` |
|
|
178
|
-
| `range` | Fill share and named-value synchronization | `.range` |
|
|
179
|
-
| `scrollspy` | Scroll-driven nav highlighting | `.scrollspy` |
|
|
180
|
-
| `in-view` | One-shot viewport appearance state | `.reveal`, `.mark-sweep` |
|
|
181
|
-
| `validation` | Form validation, focus management, server errors | `.needs-validation` |
|
|
182
|
-
| `dirty` | Unsaved-changes state on a form | — |
|
|
183
|
-
| `ajax` | Form submission through `fetch` | — |
|
|
184
|
-
|
|
185
|
-
Eight tokens. Everything else stays self-describing.
|
|
186
|
-
|
|
187
|
-
`in-view` is a presentation trigger, not an animation system: it writes
|
|
188
|
-
`is-pending` while an element waits outside the viewport and removes it on the
|
|
189
|
-
first intersection. The effect's CSS owns what that state looks like, and the
|
|
190
|
-
element is never hidden before the observer's first callback reports it off
|
|
191
|
-
screen. Its one concession to motion is focus: a release by `focusin` finishes
|
|
192
|
-
the animations that removing the state started, found by difference, because
|
|
193
|
-
a CSS `:focus-within` override lapses on blur and replays the entrance.
|