@astryxdesign/core 0.7.5-canary.34d2513 → 0.7.5-canary.37a16c0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/core",
|
|
3
|
-
"version": "0.7.5-canary.
|
|
3
|
+
"version": "0.7.5-canary.37a16c0",
|
|
4
4
|
"displayName": "Astryx Core",
|
|
5
5
|
"description": "The component library. Accessible, themeable React components with built-in spacing, dark mode, and StyleX styling.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -847,8 +847,8 @@
|
|
|
847
847
|
"react-dom": ">=19.0.0"
|
|
848
848
|
},
|
|
849
849
|
"devDependencies": {
|
|
850
|
-
"@astryxdesign/a11y-spec": "0.7.5-canary.
|
|
851
|
-
"@astryxdesign/cli": "0.7.5-canary.
|
|
850
|
+
"@astryxdesign/a11y-spec": "0.7.5-canary.37a16c0",
|
|
851
|
+
"@astryxdesign/cli": "0.7.5-canary.37a16c0",
|
|
852
852
|
"@babel/cli": "^7.29.7",
|
|
853
853
|
"@babel/core": "^7.29.7",
|
|
854
854
|
"@babel/preset-react": "^7.29.7",
|
|
@@ -278,18 +278,18 @@ reachability, not a decision that it must stay unthemeable.
|
|
|
278
278
|
|
|
279
279
|
## Verification map
|
|
280
280
|
|
|
281
|
-
| Contract | Verification
|
|
282
|
-
| ------------------- |
|
|
283
|
-
| FR1–FR4, AR1 | `AppShell.test.tsx` slot, landmark, banner, and ref suites
|
|
284
|
-
| FR5, AR2 | `AppShell.test.tsx` skip-link and keyboard suites
|
|
285
|
-
| FR6, PR1 | `AppShell.test.tsx` height-mode suites
|
|
286
|
-
| FR8 | `AppShell.test.tsx` breakpoint suites
|
|
287
|
-
| FR9–FR12 | `AppShell.test.tsx` mobile suites; `MobileNavCloseEdgeCases.test.tsx` AppShell drawer suites
|
|
288
|
-
| FR13, AR3 | `AppShell.test.tsx` keyboard drawer and `useAppShellMobile` suites
|
|
289
|
-
| FR14, AR4 | `AppShell.test.tsx` breakpoint continuity test
|
|
290
|
-
| FR17 | `SideNavRailMotion.test.tsx`, `animatedLayout.boundary.test.ts`;
|
|
291
|
-
| FR7, FR16 | `AppShell.stories.tsx` and visual baselines
|
|
292
|
-
| Theming anatomy map | `scripts/check-knowledge.mjs`
|
|
281
|
+
| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
|
|
282
|
+
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
|
|
283
|
+
| FR1–FR4, AR1 | `AppShell.test.tsx` slot, landmark, banner, and ref suites | Content only; each slot; mobile top bar with banner | A missing or duplicate landmark, or a nested banner, fails role queries. | `audit:AppShell/anatomy` |
|
|
284
|
+
| FR5, AR2 | `AppShell.test.tsx` skip-link and keyboard suites | First Tab; Enter; click; translated text | Losing the href, the focus move, or tab order fails. | `audit:AppShell/accessibility` |
|
|
285
|
+
| FR6, PR1 | `AppShell.test.tsx` height-mode suites | `fill`, `auto`, section header in `auto` | Dropping the header's sticky placement or measuring in `fill` fails. | `audit:AppShell/behavior` |
|
|
286
|
+
| FR8 | `AppShell.test.tsx` breakpoint suites | `lg`, `xl`, `2xl`, explicit `md`, `none`; nearest, root, and built themes; SSR hint | Wrong map, inclusive edge, or `none` entering mobile fails. | `audit:AppShell/behavior` |
|
|
287
|
+
| FR9–FR12 | `AppShell.test.tsx` mobile suites; `MobileNavCloseEdgeCases.test.tsx` AppShell drawer suites | Sidenav only; both navs; heading-only TopNav; custom node | A missing toggle, duplicated items, a stale drawer, or an early hide fails. | `audit:AppShell/behavior` |
|
|
288
|
+
| FR13, AR3 | `AppShell.test.tsx` keyboard drawer and `useAppShellMobile` suites | Outside a shell; inside, closed and open | A wrong id link or stale state fails. | `audit:AppShell/accessibility` |
|
|
289
|
+
| FR14, AR4 | `AppShell.test.tsx` breakpoint continuity test | Desktop to mobile and back with a focused input | Remounting content loses the value or focus. | `audit:AppShell/behavior` |
|
|
290
|
+
| FR17 | `SideNavRailMotion.test.tsx`, `animatedLayout.boundary.test.ts`; real-browser frame evidence of the content area during a side nav collapse (pending) | collapse and expand with an inline side nav; Reduce Motion under a coarse and under a fine primary pointer; `fill` and a scrolled `auto` page; a theme with `reducedMotion: 'always'`; a second toggle while the swap runs; an expand whose old wrap is not copied | a visible gap between the rail and the content, a content area that animates its width or moves on its own clock, an old wrap reachable by assistive technology or left after the swap, travel under Reduce Motion, anything but an opacity-only cross-fade of 200 ms or less under Reduce Motion on a coarse pointer (DR2), or any animated property under Reduce Motion on a fine pointer (DR3) fails | `audit:AppShell/behavior` |
|
|
291
|
+
| FR7, FR16 | `AppShell.stories.tsx` and visual baselines | `elevated` with both navs, at desktop width | A changed `elevated` background or missing corner shows in visual review. | `audit:AppShell/visual` |
|
|
292
|
+
| Theming anatomy map | `scripts/check-knowledge.mjs` | Consumer anatomy and current targets | Missing, extra, stale, or multiply assigned mappings fail repository validation. | `audit:AppShell/theming` |
|
|
293
293
|
|
|
294
294
|
Read from source, with no focused test or baseline yet:
|
|
295
295
|
|
|
@@ -112,14 +112,14 @@ Consumer migration instructions belong in consumer docs and release notes.
|
|
|
112
112
|
|
|
113
113
|
## Behavioral and layout contract
|
|
114
114
|
|
|
115
|
-
| ID | Invariant | Basis | Draft review state
|
|
116
|
-
| --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
117
|
-
| FR1 | SideNav renders its navigation children in a scrollable list, which may be grouped by SideNavSection. A SideNavItem with children renders them, after its own row, in a group labelled by the parent's label; unless `collapsible` is `false`, the group expands and collapses and is hidden from assistive technology and inert while collapsed. | Current source, docs, and tests | Current behavior
|
|
118
|
-
| FR2 | In a collapsed rail, a SideNavItem without an icon is not rendered; a leaf item renders icon-only, named by a non-blank caller `aria-label` or else its label; an item with children renders an icon-only trigger that opens a flyout listing its children as the flyout's top level. | Current source, docs, and tests | Current behavior
|
|
119
|
-
| FR3 | In an expanded rail, in a flyout, and in the mobile navigation drawer, every SideNavItem row MUST span the full inline size of its list at any depth. A row at depth `n` MUST start its content `n` × `--spacing-6` beyond the row's own inline-start padding for its size, inside the row; the nested group MUST add no inset. A flyout's top level is depth 0. | `component:SideNav/DEC-1` | Settled intent; implementation may be staged
|
|
120
|
-
| FR4 | The indent area MUST be part of the row's target: a click there, including a modified or middle click on a link row, does what the same click on the row's primary element does. When the row also carries an independent expand toggle or `actions`, the indent belongs to the primary link or button, and the toggle and actions keep their own activation at the row's trailing edge. | `component:SideNav/DEC-1`; `family:navigation-destinations` | Settled intent; implementation may be staged
|
|
121
|
-
| FR5 | An expanded nested group MUST NOT clip its rows once it has finished opening, so a nested row's focus ring paints in full. The group MAY clip while collapsed and while it opens or closes. | `component:SideNav/DEC-1` | Settled intent; implementation may be staged
|
|
122
|
-
| FR6 | Collapsing or expanding the rail plays one motion on one clock, `spec:AST-105` FR4's one shared motion (`springs.settle`): layout snaps to the final rail width at once, with no width animation, and the rail reveals or covers its labels by a clip: a collapse ends in the real collapsed state, icons only, and an expand ends in the real expanded state, with its labels. On a collapse or an expand the rail's old state is one transient copy, inert and hidden from assistive technology, removed when the motion ends. The main content moves on the same clock, as `component:AppShell` FR17 states. Under reduced motion the rail follows `design:reduced-motion` DR2 under a coarse primary pointer and DR3 otherwise. | `component:SideNav/DEC-2`; `component:AppShell` FR17; `spec:AST-105` FR8 | Verified by `SideNavRailMotion.test.tsx
|
|
115
|
+
| ID | Invariant | Basis | Draft review state |
|
|
116
|
+
| --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | ----------------------------------------------------------------------------- |
|
|
117
|
+
| FR1 | SideNav renders its navigation children in a scrollable list, which may be grouped by SideNavSection. A SideNavItem with children renders them, after its own row, in a group labelled by the parent's label; unless `collapsible` is `false`, the group expands and collapses and is hidden from assistive technology and inert while collapsed. | Current source, docs, and tests | Current behavior |
|
|
118
|
+
| FR2 | In a collapsed rail, a SideNavItem without an icon is not rendered; a leaf item renders icon-only, named by a non-blank caller `aria-label` or else its label; an item with children renders an icon-only trigger that opens a flyout listing its children as the flyout's top level. | Current source, docs, and tests | Current behavior |
|
|
119
|
+
| FR3 | In an expanded rail, in a flyout, and in the mobile navigation drawer, every SideNavItem row MUST span the full inline size of its list at any depth. A row at depth `n` MUST start its content `n` × `--spacing-6` beyond the row's own inline-start padding for its size, inside the row; the nested group MUST add no inset. A flyout's top level is depth 0. | `component:SideNav/DEC-1` | Settled intent; implementation may be staged |
|
|
120
|
+
| FR4 | The indent area MUST be part of the row's target: a click there, including a modified or middle click on a link row, does what the same click on the row's primary element does. When the row also carries an independent expand toggle or `actions`, the indent belongs to the primary link or button, and the toggle and actions keep their own activation at the row's trailing edge. | `component:SideNav/DEC-1`; `family:navigation-destinations` | Settled intent; implementation may be staged |
|
|
121
|
+
| FR5 | An expanded nested group MUST NOT clip its rows once it has finished opening, so a nested row's focus ring paints in full. The group MAY clip while collapsed and while it opens or closes. | `component:SideNav/DEC-1` | Settled intent; implementation may be staged |
|
|
122
|
+
| FR6 | Collapsing or expanding the rail plays one motion on one clock, `spec:AST-105` FR4's one shared motion (`springs.settle`): layout snaps to the final rail width at once, with no width animation, and the rail reveals or covers its labels by a clip: a collapse ends in the real collapsed state, icons only, and an expand ends in the real expanded state, with its labels. On a collapse or an expand the rail's old state is one transient copy, inert and hidden from assistive technology, removed when the motion ends. The main content moves on the same clock, as `component:AppShell` FR17 states. Under reduced motion the rail follows `design:reduced-motion` DR2 under a coarse primary pointer and DR3 otherwise. | `component:SideNav/DEC-2`; `component:AppShell` FR17; `spec:AST-105` FR8 | Verified by `SideNavRailMotion.test.tsx`; real-browser frame evidence pending |
|
|
123
123
|
|
|
124
124
|
### Allowed variation
|
|
125
125
|
|
|
@@ -195,16 +195,16 @@ Consumer migration instructions belong in consumer docs and release notes.
|
|
|
195
195
|
|
|
196
196
|
## Verification map
|
|
197
197
|
|
|
198
|
-
| Contract | Verification
|
|
199
|
-
| --------- |
|
|
200
|
-
| FR1, FR2 | `SideNav.test.tsx` nesting, collapsible, and collapsed-rail suites
|
|
201
|
-
| FR3, ORD1 | Focused `SideNav.test.tsx` indent coverage, required with implementation
|
|
202
|
-
| FR3, DD1 | Real-browser geometry over the SideNav nested stories
|
|
203
|
-
| FR4 | Real-browser click in the indent area of plain, split, and actions rows
|
|
204
|
-
| FR5, AR2 | `SideNav.test.tsx` group clipping case and real-browser keyboard focus on nested rows
|
|
205
|
-
| FR2, FR3 | Real-browser collapsed rail and flyout
|
|
206
|
-
| AR1 | Accessibility-tree comparison of nested rows
|
|
207
|
-
| FR6 | `SideNavRailMotion.test.tsx`;
|
|
198
|
+
| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
|
|
199
|
+
| --------- | ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ |
|
|
200
|
+
| FR1, FR2 | `SideNav.test.tsx` nesting, collapsible, and collapsed-rail suites | Nested, collapsible, collapsed rail, flyout | Removing the labelled group, its collapsed inert state, or the collapsed icon-only and flyout paths fails. | `audit:SideNav/anatomy` |
|
|
201
|
+
| FR3, ORD1 | Focused `SideNav.test.tsx` indent coverage, required with implementation | Depth 1 and 2; `sm` and `md`; split and actions rows; caller `style`; flyout | A group inset, a missing or wrong indent, a dropped caller `style`, an indent that overrides a caller-set inline-start padding, or an indented flyout top level fails. | `audit:SideNav/layout` |
|
|
202
|
+
| FR3, DD1 | Real-browser geometry over the SideNav nested stories | Depths 1–3; `sm`, `md`, `lg`; light and dark; right-to-left; mobile drawer | A nested row's box narrower than a top-level row's, or a label moved from its per-depth position, fails. | `audit:SideNav/layout` |
|
|
203
|
+
| FR4 | Real-browser click in the indent area of plain, split, and actions rows | Link and button rows; plain, modified, and middle clicks; nested rows with toggle and actions | A click in the indent that does nothing or differs from the same click on the primary element, or a toggle or action that activates the row, fails. | `audit:SideNav/behavior` |
|
|
204
|
+
| FR5, AR2 | `SideNav.test.tsx` group clipping case and real-browser keyboard focus on nested rows | Only-child and last nested rows; after opening; collapsed | A focus ring cut at any edge of an expanded group, or an expanded group that still clips, fails. | `audit:SideNav/a11y` |
|
|
205
|
+
| FR2, FR3 | Real-browser collapsed rail and flyout | Collapsed rail with nested children | Any change to the collapsed rail, or an indent on the flyout's top level, fails. | `audit:SideNav/layout` |
|
|
206
|
+
| AR1 | Accessibility-tree comparison of nested rows | Plain, split, and actions rows | Any change in role, name, state, or order fails. | `audit:SideNav/a11y` |
|
|
207
|
+
| FR6 | `SideNavRailMotion.test.tsx`; real-browser frame evidence of a collapse and an expand at desktop width (pending) | collapse and expand; a mouse and a finger; Reduce Motion under a coarse and under a fine primary pointer; a theme with `reducedMotion: 'always'`; a second toggle while the motion runs | an animated width, a collapse that does not end icons-only, an expand that does not end with its labels, a rail copy reachable by assistive technology or left after the motion ends, travel under Reduce Motion, anything but an opacity-only change of 200 ms or less under Reduce Motion on a coarse pointer (DR2), or any animated property under Reduce Motion on a fine pointer (DR3) fails | `audit:SideNav/behavior` |
|
|
208
208
|
|
|
209
209
|
## Decision log
|
|
210
210
|
|
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file SideNavRailMotion.interaction.browser.spec.ts
|
|
5
|
-
* @input The built Storybook's `Core/AppShell` rail-collapse stories: an
|
|
6
|
-
* AppShell whose collapsible SideNav's collapsed state the app holds, on a
|
|
7
|
-
* phone (finger, coarse pointer) and at desktop width (mouse, fine pointer)
|
|
8
|
-
* @output The real-browser frame evidence `component:SideNav` FR6 and
|
|
9
|
-
* `component:AppShell` FR17 ask for: every frame of a collapse and an
|
|
10
|
-
* expand keeps the rail's edge on the content's edge with no width
|
|
11
|
-
* animation, the rail's copy is hidden from assistive technology and gone at
|
|
12
|
-
* rest, the rail ends icons-only or with its labels, a second press mid-motion
|
|
13
|
-
* stays continuous, an expand whose old wrap is not copied keeps the edges
|
|
14
|
-
* together, and Reduce Motion cross-fades under a finger (DR2) and changes at
|
|
15
|
-
* once under a mouse (DR3)
|
|
16
|
-
* @position Testing; the components' unit cases are
|
|
17
|
-
* SideNav/SideNavRailMotion.test.tsx
|
|
18
|
-
*
|
|
19
|
-
* SYNC: When modified, update FR6's state cell and Verification row in
|
|
20
|
-
* SideNav.spec.md and the FR17 Verification row in AppShell.spec.md.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import {expect, test, type Page} from '@playwright/test';
|
|
24
|
-
import {
|
|
25
|
-
DEFAULT_STORYBOOK_DIR,
|
|
26
|
-
serveStorybook,
|
|
27
|
-
type StaticServer,
|
|
28
|
-
} from '@astryxdesign/a11y-spec/storybook';
|
|
29
|
-
|
|
30
|
-
// The frame evidence is Chromium's: CI's interaction proofs run the chromium
|
|
31
|
-
// project, and these cases have not been run in WebKit.
|
|
32
|
-
test.skip(
|
|
33
|
-
({browserName}) => browserName === 'webkit',
|
|
34
|
-
'Chromium frame evidence; not yet verified in WebKit',
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
let storybook: StaticServer | undefined;
|
|
38
|
-
test.beforeAll(async () => {
|
|
39
|
-
storybook = await serveStorybook(
|
|
40
|
-
process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
test.afterAll(async () => {
|
|
44
|
-
await storybook?.close();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const PHONE_STORY = 'core-appshell--rail-collapse-motion-phone';
|
|
48
|
-
const DESKTOP_STORY = 'core-appshell--rail-collapse-motion';
|
|
49
|
-
|
|
50
|
-
/** Loads a story and waits for its first render, its fonts and two frames. */
|
|
51
|
-
async function openStory(page: Page, story: string): Promise<void> {
|
|
52
|
-
await page.goto(
|
|
53
|
-
`${storybook?.origin ?? ''}/iframe.html?id=${story}&viewMode=story`,
|
|
54
|
-
);
|
|
55
|
-
await page.locator('[role="main"]').first().waitFor({state: 'attached'});
|
|
56
|
-
await page.evaluate(async () => {
|
|
57
|
-
await document.fonts.ready;
|
|
58
|
-
await new Promise<void>(resolve => {
|
|
59
|
-
requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** What the frames of one motion showed, sampled every animation frame. */
|
|
65
|
-
interface Frames {
|
|
66
|
-
readonly frames: number;
|
|
67
|
-
/** The largest distance between the rail's shown edge and the content's. */
|
|
68
|
-
readonly maxGap: number;
|
|
69
|
-
/** Whether any running animation changed a width. */
|
|
70
|
-
readonly animatesWidth: boolean;
|
|
71
|
-
/** Whether every rail copy seen was inert and hidden from AT. */
|
|
72
|
-
readonly copiesHidden: boolean;
|
|
73
|
-
/** Rail copies seen during the motion. */
|
|
74
|
-
readonly copiesSeen: number;
|
|
75
|
-
/** Other inert copies seen: the content's old wrap. */
|
|
76
|
-
readonly wrapCopiesSeen: number;
|
|
77
|
-
/** Distinct rail-edge positions seen: more than a few means it moved. */
|
|
78
|
-
readonly edges: number;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Presses the rail's collapse/expand button (`press` runs the press itself:
|
|
83
|
-
* a tap or a click) after `delays` ms each, then samples every frame until
|
|
84
|
-
* `durationMs` after the last press.
|
|
85
|
-
*/
|
|
86
|
-
async function sampleMotion(
|
|
87
|
-
page: Page,
|
|
88
|
-
press: () => Promise<void>,
|
|
89
|
-
{presses = 1, gapMs = 0, durationMs = 1000} = {},
|
|
90
|
-
): Promise<Frames> {
|
|
91
|
-
await page.evaluate(() => {
|
|
92
|
-
const state = {
|
|
93
|
-
frames: 0,
|
|
94
|
-
maxGap: 0,
|
|
95
|
-
animatesWidth: false,
|
|
96
|
-
copiesHidden: true,
|
|
97
|
-
copiesSeen: 0,
|
|
98
|
-
wrapCopiesSeen: 0,
|
|
99
|
-
edges: new Set<number>(),
|
|
100
|
-
running: true,
|
|
101
|
-
};
|
|
102
|
-
(window as unknown as {railFrames: typeof state}).railFrames = state;
|
|
103
|
-
const panel = document.querySelector('.astryx-layout-panel');
|
|
104
|
-
const main = document.querySelector('[role="main"]');
|
|
105
|
-
if (panel == null || main == null) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
let column = main;
|
|
109
|
-
while (
|
|
110
|
-
column.parentElement != null &&
|
|
111
|
-
!column.parentElement.contains(panel)
|
|
112
|
-
) {
|
|
113
|
-
column = column.parentElement;
|
|
114
|
-
}
|
|
115
|
-
const shownRight = (element: Element) => {
|
|
116
|
-
const inset = /inset\(0px ([\d.]+)px/.exec(
|
|
117
|
-
getComputedStyle(element).clipPath,
|
|
118
|
-
);
|
|
119
|
-
return (
|
|
120
|
-
element.getBoundingClientRect().right - (inset ? Number(inset[1]) : 0)
|
|
121
|
-
);
|
|
122
|
-
};
|
|
123
|
-
const sample = () => {
|
|
124
|
-
if (!state.running) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
state.frames++;
|
|
128
|
-
const copies = [...document.querySelectorAll('[inert]')].filter(
|
|
129
|
-
element => element.querySelector('nav') != null,
|
|
130
|
-
);
|
|
131
|
-
state.copiesSeen = Math.max(state.copiesSeen, copies.length);
|
|
132
|
-
state.wrapCopiesSeen = Math.max(
|
|
133
|
-
state.wrapCopiesSeen,
|
|
134
|
-
document.querySelectorAll('[inert]').length - copies.length,
|
|
135
|
-
);
|
|
136
|
-
for (const copy of copies) {
|
|
137
|
-
if (copy.getAttribute('aria-hidden') !== 'true') {
|
|
138
|
-
state.copiesHidden = false;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
const edge = Math.max(shownRight(panel), ...copies.map(shownRight));
|
|
142
|
-
state.edges.add(Math.round(edge));
|
|
143
|
-
state.maxGap = Math.max(
|
|
144
|
-
state.maxGap,
|
|
145
|
-
Math.abs(edge - column.getBoundingClientRect().left),
|
|
146
|
-
);
|
|
147
|
-
for (const animation of document.getAnimations()) {
|
|
148
|
-
const frames = (animation.effect as KeyframeEffect).getKeyframes();
|
|
149
|
-
if (frames.some(frame => 'width' in frame || 'inlineSize' in frame)) {
|
|
150
|
-
state.animatesWidth = true;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
requestAnimationFrame(sample);
|
|
154
|
-
};
|
|
155
|
-
requestAnimationFrame(sample);
|
|
156
|
-
});
|
|
157
|
-
for (let index = 0; index < presses; index++) {
|
|
158
|
-
if (index > 0) {
|
|
159
|
-
await page.waitForTimeout(gapMs);
|
|
160
|
-
}
|
|
161
|
-
await press();
|
|
162
|
-
}
|
|
163
|
-
await page.waitForTimeout(durationMs);
|
|
164
|
-
return page.evaluate(() => {
|
|
165
|
-
const state = (
|
|
166
|
-
window as unknown as {
|
|
167
|
-
railFrames: Omit<Frames, 'edges'> & {
|
|
168
|
-
running: boolean;
|
|
169
|
-
edges: Set<number>;
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
).railFrames;
|
|
173
|
-
state.running = false;
|
|
174
|
-
const {frames, maxGap, animatesWidth, copiesHidden, copiesSeen} = state;
|
|
175
|
-
const {wrapCopiesSeen} = state;
|
|
176
|
-
const edges = state.edges.size;
|
|
177
|
-
return {
|
|
178
|
-
frames,
|
|
179
|
-
maxGap,
|
|
180
|
-
animatesWidth,
|
|
181
|
-
copiesHidden,
|
|
182
|
-
copiesSeen,
|
|
183
|
-
wrapCopiesSeen,
|
|
184
|
-
edges,
|
|
185
|
-
};
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/** The rail's width and whether its labels show, at rest. */
|
|
190
|
-
async function railAtRest(page: Page) {
|
|
191
|
-
return page.evaluate(() => {
|
|
192
|
-
const panel = document.querySelector('.astryx-layout-panel') as HTMLElement;
|
|
193
|
-
const label = [...panel.querySelectorAll('span, div')].find(
|
|
194
|
-
element =>
|
|
195
|
-
element.children.length === 0 && element.textContent === 'Analytics',
|
|
196
|
-
);
|
|
197
|
-
const shown =
|
|
198
|
-
label != null &&
|
|
199
|
-
label.getBoundingClientRect().width > 0 &&
|
|
200
|
-
label.checkVisibility({
|
|
201
|
-
opacityProperty: true,
|
|
202
|
-
visibilityProperty: true,
|
|
203
|
-
}) &&
|
|
204
|
-
label.getBoundingClientRect().right <=
|
|
205
|
-
panel.getBoundingClientRect().right + 0.5;
|
|
206
|
-
return {
|
|
207
|
-
width: Math.round(panel.getBoundingClientRect().width),
|
|
208
|
-
labelsShown: shown,
|
|
209
|
-
copies: document.querySelectorAll('[inert]').length,
|
|
210
|
-
running: document.getAnimations().length,
|
|
211
|
-
};
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function toggleButton(page: Page) {
|
|
216
|
-
return page.getByRole('button', {name: /^(Collapse|Expand) sidebar$/});
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/** Every running animation's animated properties and duration. */
|
|
220
|
-
async function runningMotion(page: Page) {
|
|
221
|
-
return page.evaluate(() =>
|
|
222
|
-
document.getAnimations().map(animation => {
|
|
223
|
-
const effect = animation.effect as KeyframeEffect;
|
|
224
|
-
const properties = new Set<string>();
|
|
225
|
-
for (const frame of effect.getKeyframes()) {
|
|
226
|
-
for (const key of Object.keys(frame)) {
|
|
227
|
-
if (
|
|
228
|
-
!['offset', 'computedOffset', 'easing', 'composite'].includes(key)
|
|
229
|
-
) {
|
|
230
|
-
properties.add(key);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return {
|
|
235
|
-
properties: [...properties],
|
|
236
|
-
duration: Number(effect.getTiming().duration),
|
|
237
|
-
holdsPage:
|
|
238
|
-
effect.target instanceof Element &&
|
|
239
|
-
effect.target.contains(document.querySelector('[role="main"]')),
|
|
240
|
-
};
|
|
241
|
-
}),
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
test.describe('component:SideNav FR6 and component:AppShell FR17 under a finger', () => {
|
|
246
|
-
test('a tap collapses and expands the rail with its edge on the content on every frame, no width animation, and a hidden copy gone at rest', async ({
|
|
247
|
-
page,
|
|
248
|
-
}) => {
|
|
249
|
-
await openStory(page, PHONE_STORY);
|
|
250
|
-
expect(
|
|
251
|
-
await page.evaluate(() => matchMedia('(pointer: coarse)').matches),
|
|
252
|
-
).toBe(true);
|
|
253
|
-
const expanded = await railAtRest(page);
|
|
254
|
-
expect(expanded.labelsShown).toBe(true);
|
|
255
|
-
|
|
256
|
-
const collapse = await sampleMotion(page, async () => {
|
|
257
|
-
await toggleButton(page).tap();
|
|
258
|
-
});
|
|
259
|
-
expect(collapse.frames).toBeGreaterThan(20);
|
|
260
|
-
expect(collapse.maxGap).toBeLessThanOrEqual(1);
|
|
261
|
-
expect(collapse.edges).toBeGreaterThan(5);
|
|
262
|
-
expect(collapse.animatesWidth).toBe(false);
|
|
263
|
-
expect(collapse.copiesSeen).toBe(1);
|
|
264
|
-
expect(collapse.copiesHidden).toBe(true);
|
|
265
|
-
const collapsed = await railAtRest(page);
|
|
266
|
-
expect(collapsed).toMatchObject({
|
|
267
|
-
labelsShown: false,
|
|
268
|
-
copies: 0,
|
|
269
|
-
running: 0,
|
|
270
|
-
});
|
|
271
|
-
expect(collapsed.width).toBeLessThan(expanded.width);
|
|
272
|
-
|
|
273
|
-
const expand = await sampleMotion(page, async () => {
|
|
274
|
-
await toggleButton(page).tap();
|
|
275
|
-
});
|
|
276
|
-
expect(expand.maxGap).toBeLessThanOrEqual(1);
|
|
277
|
-
expect(expand.edges).toBeGreaterThan(5);
|
|
278
|
-
expect(expand.animatesWidth).toBe(false);
|
|
279
|
-
expect(expand.copiesHidden).toBe(true);
|
|
280
|
-
expect(await railAtRest(page)).toMatchObject({
|
|
281
|
-
width: expanded.width,
|
|
282
|
-
labelsShown: true,
|
|
283
|
-
copies: 0,
|
|
284
|
-
running: 0,
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
test('a second tap while the motion runs keeps the rail and the content together and lands in the second state', async ({
|
|
289
|
-
page,
|
|
290
|
-
}) => {
|
|
291
|
-
await openStory(page, PHONE_STORY);
|
|
292
|
-
const expanded = await railAtRest(page);
|
|
293
|
-
const frames = await sampleMotion(
|
|
294
|
-
page,
|
|
295
|
-
async () => {
|
|
296
|
-
await toggleButton(page).tap();
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
presses: 2,
|
|
300
|
-
gapMs: 150,
|
|
301
|
-
},
|
|
302
|
-
);
|
|
303
|
-
expect(frames.maxGap).toBeLessThanOrEqual(1);
|
|
304
|
-
expect(frames.edges).toBeGreaterThan(5);
|
|
305
|
-
expect(frames.animatesWidth).toBe(false);
|
|
306
|
-
expect(frames.copiesSeen).toBeLessThanOrEqual(1);
|
|
307
|
-
expect(await railAtRest(page)).toMatchObject({
|
|
308
|
-
width: expanded.width,
|
|
309
|
-
labelsShown: true,
|
|
310
|
-
copies: 0,
|
|
311
|
-
running: 0,
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
test('an expand whose old wrap cannot be copied keeps the rail and the content together', async ({
|
|
316
|
-
page,
|
|
317
|
-
}) => {
|
|
318
|
-
await openStory(page, PHONE_STORY);
|
|
319
|
-
await sampleMotion(page, async () => {
|
|
320
|
-
await toggleButton(page).tap();
|
|
321
|
-
});
|
|
322
|
-
// More elements than the swap copies: the old wrap is not copied.
|
|
323
|
-
await page.evaluate(() => {
|
|
324
|
-
const holder = document.createElement('div');
|
|
325
|
-
for (let index = 0; index < 1600; index++) {
|
|
326
|
-
holder.appendChild(document.createElement('span'));
|
|
327
|
-
}
|
|
328
|
-
document.querySelector('[role="main"]')?.appendChild(holder);
|
|
329
|
-
});
|
|
330
|
-
const expand = await sampleMotion(page, async () => {
|
|
331
|
-
await toggleButton(page).tap();
|
|
332
|
-
});
|
|
333
|
-
expect(expand.maxGap).toBeLessThanOrEqual(1);
|
|
334
|
-
expect(expand.edges).toBeGreaterThan(5);
|
|
335
|
-
expect(expand.animatesWidth).toBe(false);
|
|
336
|
-
// The fallback branch ran: no copy of the old wrap was made.
|
|
337
|
-
expect(expand.wrapCopiesSeen).toBe(0);
|
|
338
|
-
expect(await railAtRest(page)).toMatchObject({
|
|
339
|
-
labelsShown: true,
|
|
340
|
-
copies: 0,
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
test('under Reduce Motion a tap only cross-fades, in 200 ms or less, with the page surface still (design:reduced-motion DR2)', async ({
|
|
345
|
-
page,
|
|
346
|
-
}) => {
|
|
347
|
-
await page.emulateMedia({reducedMotion: 'reduce'});
|
|
348
|
-
await openStory(page, PHONE_STORY);
|
|
349
|
-
await toggleButton(page).tap();
|
|
350
|
-
const motion = await runningMotion(page);
|
|
351
|
-
expect(motion.length).toBeGreaterThan(0);
|
|
352
|
-
for (const {properties, duration, holdsPage} of motion) {
|
|
353
|
-
expect(properties).toEqual(['opacity']);
|
|
354
|
-
expect(duration).toBeLessThanOrEqual(200);
|
|
355
|
-
expect(holdsPage).toBe(false);
|
|
356
|
-
}
|
|
357
|
-
await page.waitForTimeout(400);
|
|
358
|
-
expect(await railAtRest(page)).toMatchObject({
|
|
359
|
-
labelsShown: false,
|
|
360
|
-
copies: 0,
|
|
361
|
-
});
|
|
362
|
-
});
|
|
363
|
-
});
|
|
364
|
-
|
|
365
|
-
test.describe('component:SideNav FR6 and component:AppShell FR17 under a mouse', () => {
|
|
366
|
-
test.use({
|
|
367
|
-
isMobile: false,
|
|
368
|
-
hasTouch: false,
|
|
369
|
-
viewport: {width: 1280, height: 800},
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
test('a click collapses and expands the rail with its edge on the content on every frame and no width animation', async ({
|
|
373
|
-
page,
|
|
374
|
-
}) => {
|
|
375
|
-
await openStory(page, DESKTOP_STORY);
|
|
376
|
-
expect(
|
|
377
|
-
await page.evaluate(() => matchMedia('(pointer: fine)').matches),
|
|
378
|
-
).toBe(true);
|
|
379
|
-
const expanded = await railAtRest(page);
|
|
380
|
-
const collapse = await sampleMotion(page, async () => {
|
|
381
|
-
await toggleButton(page).click();
|
|
382
|
-
});
|
|
383
|
-
expect(collapse.maxGap).toBeLessThanOrEqual(1);
|
|
384
|
-
expect(collapse.edges).toBeGreaterThan(5);
|
|
385
|
-
expect(collapse.animatesWidth).toBe(false);
|
|
386
|
-
expect(collapse.copiesHidden).toBe(true);
|
|
387
|
-
expect(await railAtRest(page)).toMatchObject({
|
|
388
|
-
labelsShown: false,
|
|
389
|
-
copies: 0,
|
|
390
|
-
running: 0,
|
|
391
|
-
});
|
|
392
|
-
const expand = await sampleMotion(page, async () => {
|
|
393
|
-
await toggleButton(page).click();
|
|
394
|
-
});
|
|
395
|
-
expect(expand.maxGap).toBeLessThanOrEqual(1);
|
|
396
|
-
expect(expand.edges).toBeGreaterThan(5);
|
|
397
|
-
expect(expand.animatesWidth).toBe(false);
|
|
398
|
-
expect(await railAtRest(page)).toMatchObject({
|
|
399
|
-
width: expanded.width,
|
|
400
|
-
labelsShown: true,
|
|
401
|
-
copies: 0,
|
|
402
|
-
});
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
test('under Reduce Motion a click changes the rail and the page at once (design:reduced-motion DR3)', async ({
|
|
406
|
-
page,
|
|
407
|
-
}) => {
|
|
408
|
-
await page.emulateMedia({reducedMotion: 'reduce'});
|
|
409
|
-
await openStory(page, DESKTOP_STORY);
|
|
410
|
-
await toggleButton(page).click();
|
|
411
|
-
expect(await runningMotion(page)).toEqual([]);
|
|
412
|
-
expect(await railAtRest(page)).toMatchObject({
|
|
413
|
-
labelsShown: false,
|
|
414
|
-
copies: 0,
|
|
415
|
-
});
|
|
416
|
-
});
|
|
417
|
-
});
|