Skip to content

Commit 54275fc

Browse files
committed
spec(architecture): components are built from minimal DOM (component-style-authoring INV7, theming-surface INV3), decided by AST-017 FR60/DEC-26
1 parent 3a1e95a commit 54275fc

3 files changed

Lines changed: 115 additions & 29 deletions

File tree

‎docs/architecture/component-style-authoring.md‎

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ verified_by:
1717
internal/eslint-plugin-astryx/no-stylex-null-override.test.mjs,
1818
internal/eslint-plugin-astryx/no-style-only-wrapper.test.mjs,
1919
]
20-
deciding_specs: [spec:AST-080/DEC-4]
20+
deciding_specs: [spec:AST-080/DEC-4, spec:AST-017/DEC-26]
2121
---
2222

2323
# Component style authoring architecture
@@ -28,7 +28,7 @@ deciding_specs: [spec:AST-080/DEC-4]
2828
{
2929
"scope": "global",
3030
"triggers": {
31-
"styling": ["INV1", "INV2", "INV3", "INV4", "INV5", "INV6"]
31+
"styling": ["INV1", "INV2", "INV3", "INV4", "INV5", "INV6", "INV7"]
3232
}
3333
}
3434
```
@@ -39,7 +39,7 @@ Astryx component styling should lower to valid maintained CSS, compose predictab
3939
with supported consumer styling, keep relational state scoped to the intended
4040
component, and avoid DOM wrappers with no runtime responsibility.
4141

42-
This record owns six component-level authoring outcomes. It does not redefine
42+
This record owns seven component-level authoring outcomes. It does not redefine
4343
semantic tokens, public theme targets, extensible prop axes, public styling props,
4444
icon resolution, bidirectionality, or React Server Component boundaries.
4545

@@ -115,6 +115,54 @@ not evidence of conformance or violation.
115115
variable groups follow `spec:AST-066` FR3, and message catalogs follow
116116
`architecture:internationalization` INV15.
117117

118+
- **INV7 — Components are built from minimal DOM.** Every component, at
119+
rest and open, renders one element per semantic or interactive role it
120+
owns, one element for each themable part a current theme target paints
121+
(`architecture:component-theming-surface` INV4), and a wrapper only where
122+
INV5 names its responsibility: a semantic role (an ARIA need included),
123+
behavior or ref, a formatting context, outside spacing, or a style-bearing
124+
boundary the child cannot host. States and variants
125+
are expressed through attributes, classes, and styles on those elements,
126+
never through extra elements. A pseudo-element carries decoration that has
127+
no semantic role and never repeats content. Content renders once: no hidden
128+
twin to measure or reserve space, because CSS can size and reserve it on the
129+
element that shows it (INV2). A layer mounts exactly one presentation. The
130+
only second copy is one transient copy during an exit, a presentation
131+
switch, or a handoff between sheets, such as the cross-fade
132+
`design:reduced-motion` DR2 requires; it is made by one Core mechanism that
133+
every layer uses, rather than by each component, and is removed within 1
134+
second of the transition ending. Until that shared mechanism exists, a
135+
layer's own exit, presentation-switch, or handoff copy is a recorded conformance gap, not an
136+
exception. A change to a component prefers removing or
137+
merging nodes; any added element is justified against this invariant with
138+
measured element counts before and after. Two budgets follow from it:
139+
- **Surface components at rest** — Button, IconButton, ToggleButton, Item and
140+
other list rows, SegmentedControl, Switch, Badge, text and other inputs,
141+
CheckboxInput, and radio controls: no element beyond their roles, their
142+
themable parts, and the wrappers INV5 names, and no duplicated content,
143+
under any pointer. A pointer-specific presentation is a change of
144+
attributes and styles on the same elements; a pseudo-element stands in for
145+
an element only as decoration.
146+
- **Layers while open** — Popover, BottomSheet, DropdownMenu, ContextMenu,
147+
Lightbox, and Dialog: one presentation mounted, no content mounted twice
148+
outside the transient copy above, and the open layer under a coarse
149+
pointer has at most as many elements as under a fine pointer.
150+
151+
Good: when a segmented control's selected label gets heavier, CSS on that
152+
one label element keeps the segment's width; Popover mounts its surface once
153+
and changes placement and presentation through styles. Bad: a hidden second
154+
copy of a label kept to reserve its width; a sheet and a popover both
155+
mounted with one hidden; a wrapper added only to carry a touch style.
156+
157+
A component may exceed the budgets only through an exception its pull
158+
request states, with why existing elements cannot do the job and the
159+
measured element count before and after. Each exception is recorded as its
160+
own owner decision, in the component's current record or, when the
161+
component has none, in this record; either way it passes the spec-owner
162+
approval gate, and none is accepted silently. Element
163+
counts are `document.body.querySelectorAll('*').length` for the component's
164+
story, at rest and open, under a fine and a coarse pointer.
165+
118166
## Authoring guidance
119167

120168
The following guidance helps satisfy the invariants but does not independently
@@ -170,7 +218,8 @@ This record does not absorb adjacent audit rules:
170218

171219
This record supplies shared authority for:
172220

173-
- **Q6 / T14:** wrapper responsibility through INV5;
221+
- **Q6 / T14:** wrapper responsibility through INV5 and minimal construction
222+
through INV7;
174223
- the durable composability outcome behind **Q7** through INV3;
175224
- **T8:** component-local StyleX lowering and CSS-over-JS ownership through
176225
INV1–INV2;
@@ -201,7 +250,8 @@ Focused style-authoring review triggers when a component change adds or alters:
201250
- shorthand/reset/null behavior that can prevent independent consumer property
202251
composition;
203252
- ancestor, descendant, or sibling visual state;
204-
- a DOM wrapper around one component or one visual child;
253+
- a DOM wrapper around one component or one visual child, or any added
254+
element, pseudo-element, or mounted presentation (INV7);
205255
- a component-owned inline SVG that may represent a shared semantic glyph; or
206256
- code or styles that run only on a coarse pointer, or a shared value table a
207257
component reads (INV6).
@@ -222,18 +272,22 @@ before assigning a verdict.
222272
- `spec:AST-080/DEC-4` — every pull request reports component JavaScript and
223273
CSS size; touch-only JavaScript over 2 KB or CSS over 1 KB is flagged, and
224274
shared value tables ship only the rows a component uses (INV6).
275+
- `spec:AST-017/DEC-26` — components are built from minimal DOM, with two
276+
budgets and an owner-recorded exception path; reducing DOM is compatible
277+
(INV7).
225278

226279
The icon, theme-token, component-theming, public-API, bidirectionality, and
227280
RSC owners retain the delegated decisions above.
228281

229282
## Verification
230283

231-
| Invariant | Evidence | Failure signal |
232-
| ------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
233-
| INV1 | StyleX capability scan plus component-source mutation | Shipped component styling bypasses the maintained lowering path without another named owner, including component-local raw CSS where that path supports the same result |
234-
| INV2 | Equivalent CSS/JS mutation fixtures and real-browser presentation | JavaScript recreates CSS-resolvable presentation, flashes intermediate state, or disagrees with CSS conditions |
235-
| INV3 | StyleX compile fixtures and independent consumer-property override mutations | Input lowers to invalid CSS or changing one supported property cannot compose without removing another |
236-
| INV4 | Nested unrelated-owner browser fixture across hover, focus-within, active, and disabled states | Outer component state activates an inner component's visual treatment |
237-
| INV5 | Wrapper mutations in default and host-composed render paths | Removing a wrapper changes no semantic, behavior/ref, formatting-context, outside-border-spacing, or required style-bearing DOM boundary |
238-
| INV6 | Pull-request size report against base, with value-table import fixtures | A changed component with no base-against-head gzip JavaScript or CSS figure; a touch-only feature over 2 KB gzip JavaScript or 1 KB gzip CSS per component that is not flagged; importing a component pulls in value-table rows only other components read |
239-
| Capability registry | Registry generation against the installed StyleX package | Recorded and installed StyleX versions differ, so capability-dependent cases are untestable |
284+
| Invariant | Evidence | Failure signal |
285+
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
286+
| INV1 | StyleX capability scan plus component-source mutation | Shipped component styling bypasses the maintained lowering path without another named owner, including component-local raw CSS where that path supports the same result |
287+
| INV2 | Equivalent CSS/JS mutation fixtures and real-browser presentation | JavaScript recreates CSS-resolvable presentation, flashes intermediate state, or disagrees with CSS conditions |
288+
| INV3 | StyleX compile fixtures and independent consumer-property override mutations | Input lowers to invalid CSS or changing one supported property cannot compose without removing another |
289+
| INV4 | Nested unrelated-owner browser fixture across hover, focus-within, active, and disabled states | Outer component state activates an inner component's visual treatment |
290+
| INV5 | Wrapper mutations in default and host-composed render paths | Removing a wrapper changes no semantic, behavior/ref, formatting-context, outside-border-spacing, or required style-bearing DOM boundary |
291+
| INV6 | Pull-request size report against base, with value-table import fixtures | A changed component with no base-against-head gzip JavaScript or CSS figure; a touch-only feature over 2 KB gzip JavaScript or 1 KB gzip CSS per component that is not flagged; importing a component pulls in value-table rows only other components read |
292+
| INV7 | Story element counts (`document.body.querySelectorAll('*').length`) at rest and open under a fine and a coarse pointer, base against head, plus render inspection for duplicated content | An element beyond the component's roles, themable parts, and INV5 wrappers, or a duplicated or hidden twin of content; a state or variant rendered as an extra element; a pseudo-element repeating content; a layer with two presentations mounted outside the transient copy, content mounted twice, more elements under a coarse pointer than a fine one, a transient copy made by a component itself, or one left past 1 second; an added element with no measured counts, or a budget exceeded with no recorded owner exception |
293+
| Capability registry | Registry generation against the installed StyleX package | Recorded and installed StyleX versions differ, so capability-dependent cases are untestable |

0 commit comments

Comments
 (0)