Skip to content

Commit 571da6f

Browse files
committed
feat(lab): under a finger, NavigationStack's bar takes the iOS 26 look
Under a finger, NavigationStack's bars paint no background and no hairline, as iOS 26's do. Each screen carries a scroll edge effect: a veil of the body colour that fades in once its content has moved 10px under the bar, on UIKit's measured springs. A push, a pop and a back swipe carry each screen's veil with its card, and the bar a card covers is cut at that card's leading edge. A mouse keeps opaque bars. The veil and the UIKit bar constants live in Lab. The veil reads Core's finger-scroll hook, with its end call, and Core's internal touch entry also names the gesture host and the coarse-pointer check: export-only additions, with no change to Core's behavior.
1 parent 1a51596 commit 571da6f

13 files changed

Lines changed: 2342 additions & 68 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[chore] Internal: Core's internal touch entry also names, for Lab's NavigationStack, the gesture host and the coarse-pointer check. Its scroll edge effect reads the internal finger-scroll hook and its end call. Apps import nothing new.
6+
7+
@vjeux

‎apps/storybook/stories/NavigationStack.stories.tsx‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,75 @@ export const LargeTitle: Story = {
308308
name: 'Large title',
309309
render: () => <LargeTitleStack />,
310310
};
311+
312+
// =============================================================================
313+
// Scrolling — content passing under the bar
314+
// =============================================================================
315+
316+
const MESSAGES = Array.from({length: 40}, (_, index) => `Message ${index + 1}`);
317+
318+
function MessageRows() {
319+
const nav = useNavigationStack<string>();
320+
return (
321+
<List>
322+
{MESSAGES.map(message => (
323+
<ListItem
324+
key={message}
325+
label={message}
326+
description="Tap to open; scroll the list under the bar."
327+
endContent={<Icon icon="chevronRight" color="secondary" />}
328+
onClick={() => nav.push(message)}
329+
/>
330+
))}
331+
</List>
332+
);
333+
}
334+
335+
function MessageBody({title}: {title: string}) {
336+
return (
337+
<List>
338+
{Array.from({length: 30}, (_, index) => (
339+
<ListItem
340+
key={index}
341+
label={`${title}, line ${index + 1}`}
342+
description="Long content scrolls under the bar."
343+
/>
344+
))}
345+
</List>
346+
);
347+
}
348+
349+
function ScrollingStack() {
350+
const [path, setPath] = useState<string[]>([]);
351+
return (
352+
<div style={{height: '100vh'}}>
353+
<NavigationStack
354+
label="Mail"
355+
root={
356+
<NavigationScreen title="Inbox">
357+
<MessageRows />
358+
</NavigationScreen>
359+
}
360+
path={path}
361+
onPathChange={setPath}
362+
getKey={entry => entry}
363+
renderScreen={entry => (
364+
<NavigationScreen title={entry}>
365+
<MessageBody title={entry} />
366+
</NavigationScreen>
367+
)}
368+
data-testid="navigation-stack"
369+
/>
370+
</div>
371+
);
372+
}
373+
374+
/**
375+
* Screens long enough to scroll under the bar. On a touch screen the bar
376+
* paints no background. Once a screen's content has moved 10px under it, a
377+
* veil of the body colour fades in, as iOS 26's scroll edge effect does.
378+
* Each screen keeps its own veil through a push, a pop or a back swipe.
379+
*/
380+
export const Scrolling: Story = {
381+
render: () => <ScrollingStack />,
382+
};

‎packages/core/src/internal/touch.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,23 @@ describe('internal/touch', () => {
137137
expect(entry.navigation).toBeDefined();
138138
});
139139

140+
it("re-exports by name what NavigationStack's bars and scroll edge effect read", async () => {
141+
const entry: Record<string, unknown> = await import('./touch');
142+
const host = await import('../gestures/GestureHost');
143+
const pointer = await import('../utils/coarsePointer');
144+
const fingerScroll = await import('../gestures/useFingerScroll');
145+
expect(entry.getGestureHost).toBe(host.getGestureHost);
146+
expect(entry.isCoarsePointer).toBe(pointer.isCoarsePointer);
147+
expect(entry.useFingerScroll).toBe(fingerScroll.useFingerScroll);
148+
for (const name of [
149+
'getGestureHost',
150+
'isCoarsePointer',
151+
'useFingerScroll',
152+
]) {
153+
expect(typeof entry[name], name).toBe('function');
154+
}
155+
});
156+
140157
it('attaches no window or document listeners when it loads', async () => {
141158
vi.resetModules();
142159
const onWindow = vi.spyOn(window, 'addEventListener');

‎packages/core/src/internal/touch.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,10 @@ export {useInteractionModalityTracking} from '../utils/interactionModality';
100100
// and flushes its held writes when that scroll ends.
101101
export {useFingerScroll} from '../gestures/useFingerScroll';
102102
export type {UseFingerScrollOptions} from '../gestures/useFingerScroll';
103+
104+
// Lab's NavigationStack scroll edge effect reads the finger-scroll hook
105+
// above, and drops the veil's compositing layer when a finger's scroll ends.
106+
// It reads the gesture host for a finger's landing. The stack's bars read the
107+
// coarse-pointer check.
108+
export {getGestureHost} from '../gestures/GestureHost';
109+
export {isCoarsePointer} from '../utils/coarsePointer';

‎packages/lab/src/NavigationStack/NavigationStack.doc.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const docs = {
2525
name: 'NavigationStack',
2626
displayName: 'Navigation Stack',
2727
description:
28-
"The navigator. You own the path: pass the entries pushed on the root screen and update them in onPathChange. The stack renders the root screen and one screen per entry, the top one last, keeps covered screens and their scroll positions alive, and makes them inert. The bar shows the top screen's title, its end content and a round Back button with a chevron, named by the screen it returns to. A push moves focus to the new screen's title; a pop returns it to the control that pushed the screen.",
28+
"The navigator. You own the path: pass the entries pushed on the root screen and update them in onPathChange. The stack renders the root screen and one screen per entry, the top one last, keeps covered screens and their scroll positions alive, and makes them inert. The bar shows the top screen's title, its end content and a round Back button with a chevron, named by the screen it returns to. A push moves focus to the new screen's title; a pop returns it to the control that pushed the screen. Under a finger the bar paints no background and no hairline, as iOS 26's does. Once a screen's content has moved 10px under the bar, a veil of the body colour fades in at the top of that screen. Each screen keeps its own veil through a push, a pop or a back swipe. With a mouse the bar keeps its surface and hairline.",
2929
props: [
3030
{
3131
name: 'root',

‎packages/lab/src/NavigationStack/NavigationStack.test.tsx‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,23 @@ describe('NavigationStack', () => {
219219
);
220220
});
221221

222+
it('puts the scroll edge sentinel right after the large title', () => {
223+
render(<LargeHarness />);
224+
const scroller = screenCard('Settings')?.firstElementChild;
225+
const content = scroller?.firstElementChild;
226+
const [title, sentinel] = Array.from(content?.children ?? []);
227+
expect(title).toBe(
228+
screen.getByRole('heading', {level: 1, name: 'Settings'}),
229+
);
230+
// It ends where the large title ends, so the veil comes on as the
231+
// bar's title takes over. The scroller holds no other sentinel.
232+
expect(sentinel).toHaveAttribute('data-navigation-scroll-edge-sentinel');
233+
expect(sentinel).toHaveAttribute('aria-hidden', 'true');
234+
expect(
235+
scroller?.querySelectorAll('[data-navigation-scroll-edge-sentinel]'),
236+
).toHaveLength(1);
237+
});
238+
222239
it('moves focus to the pushed screen’s large title', async () => {
223240
render(<LargeHarness />);
224241
const general = screen.getByRole('button', {name: 'General'});
@@ -234,6 +251,24 @@ describe('NavigationStack', () => {
234251
});
235252
});
236253

254+
it('marks the top of an inline screen’s content with the scroll edge sentinel, under its veil', () => {
255+
render(<Harness />);
256+
const card = screenCard('Settings');
257+
const [sentinel, content] = Array.from(
258+
card?.firstElementChild?.children ?? [],
259+
);
260+
// The sentinel sits just above the content, at its static position in
261+
// the scroller. The screen's first element stays the content's first.
262+
expect(sentinel).toHaveAttribute('data-navigation-scroll-edge-sentinel');
263+
expect(
264+
content?.querySelector('[data-navigation-scroll-edge-sentinel]'),
265+
).toBeNull();
266+
// The veil is the card's own child, over the scroller, hidden from
267+
// assistive technology.
268+
const veil = card?.querySelector(':scope > [data-navigation-scroll-edge]');
269+
expect(veil).toHaveAttribute('aria-hidden', 'true');
270+
});
271+
237272
it('shows a screen’s end content in its bar, out of reach once a screen covers it', async () => {
238273
render(<Harness rootEndContent={<button type="button">Edit</button>} />);
239274
const edit = screen.getByRole('button', {name: 'Edit'});

0 commit comments

Comments
 (0)