actual-css 0.19.4 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -0
- package/README.md +6 -6
- package/components.json +6 -3
- package/dist/actual.full.css +249 -50
- package/dist/actual.full.js +2 -2
- package/dist/actual.full.min.css +1 -1
- package/dist/types/menu.d.ts +2 -5
- package/docs/pages/components/accordion.md +11 -6
- package/docs/pages/components/alert.md +64 -62
- package/docs/pages/components/avatar.md +12 -12
- package/docs/pages/components/badge.md +15 -15
- package/docs/pages/components/breadcrumb.md +10 -8
- package/docs/pages/components/button.md +56 -7
- package/docs/pages/components/card.md +21 -21
- package/docs/pages/components/dialog.md +97 -69
- package/docs/pages/components/drawer.md +33 -33
- package/docs/pages/components/indicator.md +12 -12
- package/docs/pages/components/navbar.md +41 -9
- package/docs/pages/components/pagination.md +7 -7
- package/docs/pages/components/progress.md +18 -13
- package/docs/pages/components/rating.md +19 -19
- package/docs/pages/components/reveal.md +2 -0
- package/docs/pages/components/segmented.md +35 -31
- package/docs/pages/components/skeleton.md +10 -8
- package/docs/pages/components/spinner.md +21 -15
- package/docs/pages/components/table.md +26 -28
- package/docs/pages/enhancements/flyout.md +94 -43
- package/docs/pages/enhancements/in-view.md +3 -1
- package/docs/pages/enhancements/scrollspy.md +51 -18
- package/docs/pages/enhancements/tabs.md +43 -37
- package/docs/pages/enhancements/tooltip.md +4 -2
- package/docs/pages/forms/ajax.md +66 -0
- package/docs/pages/forms/choice-cards.md +8 -8
- package/docs/pages/forms/color-swatches.md +12 -12
- package/docs/pages/forms/form-actions.md +23 -0
- package/docs/pages/forms/joined-controls.md +8 -8
- package/docs/pages/forms/labels.md +11 -11
- package/docs/pages/forms/overview.md +35 -29
- package/docs/pages/forms/states-and-sizes.md +9 -9
- package/docs/pages/forms/switch.md +35 -2
- package/docs/pages/forms/validation.md +16 -16
- package/docs/pages/foundations/theming.md +32 -2
- package/docs/pages/foundations/tokens.md +18 -16
- package/docs/pages/guides/coding-agents.md +18 -0
- package/docs/pages/guides/introduction.md +1 -1
- package/llms.txt +3 -3
- package/package.json +5 -5
- package/reserved-classes.json +1 -0
- package/skills/actual-css/SKILL.md +7 -0
- package/src/cli/actual-css.js +3 -3
- package/src/css/components/badge.css +10 -6
- package/src/css/components/button.css +20 -7
- package/src/css/components/join.css +14 -4
- package/src/css/components/navbar.css +83 -1
- package/src/css/components/pagination.css +3 -1
- package/src/css/components/segmented.css +27 -7
- package/src/css/core/theme.css +11 -9
- package/src/css/core/tokens.css +7 -1
- package/src/css/core/variants.css +2 -0
- package/src/css/effects/reveal.css +15 -6
- package/src/css/forms/control.css +11 -1
- package/src/css/forms/form.css +14 -4
- package/src/css/forms/switch.css +32 -3
- package/src/js/ajax.js +18 -1
- package/src/js/context-menu.js +1 -3
- package/src/js/flyout.js +14 -5
- package/src/js/in-view.js +41 -30
- package/src/js/menu.js +9 -21
- package/src/js/surface.js +38 -0
- package/src/tooling/design-tokens.js +1 -0
- package/src/tooling/theme-contrast.js +24 -9
- package/tokens.json +1 -0
- 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,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.
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
# Forced Colors (HCM) Strategy
|
|
2
|
-
|
|
3
|
-
## Principle: let the browser do the work
|
|
4
|
-
|
|
5
|
-
When `forced-colors: active`, the browser automatically remaps these properties to
|
|
6
|
-
the system palette:
|
|
7
|
-
|
|
8
|
-
- `border-color` → `ButtonText`
|
|
9
|
-
- `background` / `background-color` → `Canvas`
|
|
10
|
-
- `color` → `CanvasText`
|
|
11
|
-
|
|
12
|
-
This is the default behavior with `forced-color-adjust: auto` — and it applies to
|
|
13
|
-
**every** element, including pseudo-elements. Components do not need to redeclare
|
|
14
|
-
these properties in a forced-colors block.
|
|
15
|
-
|
|
16
|
-
## What the browser cannot understand
|
|
17
|
-
|
|
18
|
-
The browser sees `background-color`, `box-shadow`, `border-color`, `text-shadow`,
|
|
19
|
-
and non-URL `background-image` — it remaps or drops them all. It does **not**
|
|
20
|
-
understand:
|
|
21
|
-
|
|
22
|
-
- `mask-image` (SVG masks applied via `background-color`)
|
|
23
|
-
- Pseudo-elements whose `background-color` is used as a mask fill
|
|
24
|
-
- `box-shadow` used as a focus ring or shape indicator (the browser drops them)
|
|
25
|
-
- `background-image` carrying essential state or shape
|
|
26
|
-
|
|
27
|
-
These are the most common cases that need explicit forced-colors rules.
|
|
28
|
-
Add local overrides only when testing shows that browser remapping removes
|
|
29
|
-
an essential shape, state, or affordance.
|
|
30
|
-
|
|
31
|
-
## Pattern: custom property + single override
|
|
32
|
-
|
|
33
|
-
The hook-only form below is fine until an application overrides the hook: the
|
|
34
|
-
override sits at the same specificity, loads after the framework, and wins the
|
|
35
|
-
variable — leaving a non-system fill the browser then remaps to `Canvas`. For
|
|
36
|
-
a masked marker, write the forced value on the property itself so no hook
|
|
37
|
-
override can take it away (accordion) — same for range track/thumb fills.
|
|
38
|
-
|
|
39
|
-
```css
|
|
40
|
-
.component {
|
|
41
|
-
--cmp-marker-color: var(--text-muted);
|
|
42
|
-
|
|
43
|
-
background: ...
|
|
44
|
-
color: ...
|
|
45
|
-
border: ...
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.component::marker {
|
|
49
|
-
background-color: var(--cmp-marker-color);
|
|
50
|
-
mask-image: url(...);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@media (forced-colors: active) {
|
|
54
|
-
.component {
|
|
55
|
-
--cmp-marker-color: CanvasText;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/* Masked markers: pin the property, not just the hook. */
|
|
59
|
-
.component::marker {
|
|
60
|
-
background-color: CanvasText;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Color system keywords by role
|
|
66
|
-
|
|
67
|
-
| Context | Color | Why |
|
|
68
|
-
| ------------------------ | --------------------- | ---------------------------------- |
|
|
69
|
-
| Disclosure marker | `CanvasText` | Summary is on Canvas, not a button |
|
|
70
|
-
| Button, switch, checkbox | the `Button*` pair | Interactive controls |
|
|
71
|
-
| Selected / current state | the `Highlight*` pair | Matches OS selection |
|
|
72
|
-
| Disabled state | `GrayText` | Standard disabled system color |
|
|
73
|
-
| Hover indicator | outline or underline | Avoids blocked backgrounds |
|
|
74
|
-
|
|
75
|
-
Controls use `ButtonText` / `ButtonFace`, and `Highlight` / `HighlightText` for
|
|
76
|
-
their selected state. A hover indicator is a `ButtonText` outline or a
|
|
77
|
-
`CanvasText` underline.
|
|
78
|
-
|
|
79
|
-
Prefer `CanvasText` for non-interactive mark-up content. `CanvasText` and
|
|
80
|
-
`ButtonText` are **not guaranteed identical** — custom HCM palettes can set
|
|
81
|
-
them differently.
|
|
82
|
-
|
|
83
|
-
## What to avoid
|
|
84
|
-
|
|
85
|
-
### `forced-color-adjust: none`
|
|
86
|
-
Only use when the color **must not** be remapped — e.g., a `background-color`
|
|
87
|
-
whose value is `currentColor` (the system would turn it into `Canvas` and make
|
|
88
|
-
the element invisible). Every `forced-color-adjust: none` blocks the browser
|
|
89
|
-
from fixing contrast issues automatically. Most components need zero instances.
|
|
90
|
-
When only a pseudo-element carries essential color information, put the
|
|
91
|
-
declaration on that pseudo-element so the interactive host keeps native color
|
|
92
|
-
and focus adaptation.
|
|
93
|
-
|
|
94
|
-
### Redundant rules
|
|
95
|
-
```css
|
|
96
|
-
/* DON'T — the browser already does this */
|
|
97
|
-
@media (forced-colors: active) {
|
|
98
|
-
.component {
|
|
99
|
-
border-color: ButtonText;
|
|
100
|
-
background: Canvas;
|
|
101
|
-
color: CanvasText;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### Redundant hover outlines
|
|
107
|
-
If the default focus is an outline on `:focus-visible`, it's already handled.
|
|
108
|
-
Hover doesn't need an outline duplicate. Reserve hover HCM rules for cases
|
|
109
|
-
where text-decoration (underline) is a better visual than an outline.
|
|
110
|
-
|
|
111
|
-
## Exemptions from forced-colors rules
|
|
112
|
-
|
|
113
|
-
Some components need **no** forced-color block at all because the default
|
|
114
|
-
remapping is perfect:
|
|
115
|
-
|
|
116
|
-
- `.card` — `background: Canvas`, `color: CanvasText` are already the defaults
|
|
117
|
-
- `.flyout` / `.menu` — `Canvas`/`CanvasText` for content, `ButtonText` for borders
|
|
118
|
-
- `.breadcrumb` — pure remapping gets everything right
|
|
119
|
-
- `.status-bar` — `CanvasText` on `Canvas` background
|
|
120
|
-
|
|
121
|
-
The only forced-colors rules that should remain after a full audit are the ones
|
|
122
|
-
truly required by pseudo-element masks (`::after` / `::before` chevrons, custom
|
|
123
|
-
check/radio marks), non-native focus rings, and `currentColor` dependencies.
|