fix(mobile): one form sheet for every dialog, opaque and placed beside the rail

Every sheet now stands on the opaque sheet surface: the frosting the
translucent one relied on is dropped while the scrim fades, so the page
read through the fields as sharp ghost text.

On a wide window a sheet is centred in the content beside the navigation
rail instead of on the whole window, so it never lies on the rail, and it
grows to the window's height instead of stopping at 880px. On a phone the
card stands between the status bar and the dock rather than across the
dock. A sheet marked as a form fills the height of a window as short as a
phone on its side, with Cancel and Save beside the title (new `short:`
variant, m-form-sheet grid in mobile.css).

The form chrome gains a scrolling body that fades at the edges with more
behind them (useEdgeFade on the vertical axis), a date field whose
keyboard entry moves into the picker, a field wrapper for amounts with a
currency, and two-line titles. The focused sheet no longer draws the
app-wide focus frame or loses its corners, and the desktop's dark field
paint stays out of the touch shell, which painted a dark box inside every
rounded field.
This commit is contained in:
Maurice
2026-11-07 23:19:40 +01:00
parent bb725ac8d8
commit b7a91fc84e
10 changed files with 618 additions and 133 deletions
+26 -14
View File
@@ -1,28 +1,33 @@
import { useEffect, useState } from 'react';
export interface EdgeFade {
/** Content is scrolled past the leading edge. */
/** Content is scrolled past the leading (or top) edge. */
start: boolean;
/** More content waits beyond the trailing edge. */
/** More content waits beyond the trailing (or bottom) edge. */
end: boolean;
}
/** x: a horizontal strip, y: a vertical scroll box such as a form sheet's body. */
export type EdgeFadeAxis = 'x' | 'y';
const NONE: EdgeFade = { start: false, end: false };
/**
* Which ends of a horizontal scroller have more behind them, so the strip can
* fade out there (m-fade-s / m-fade-e in mobile.css) instead of cutting a chip
* in half with nothing to say the row goes on. Follows scrolling and every
* change of size: a rotation, a fold, the pane beside the map opening.
* Which ends of a scroller have more behind them, so it can fade out there
* (m-fade-s / m-fade-e, m-fade-t / m-fade-b in mobile.css) instead of cutting a
* chip or a field in half with nothing to say the content goes on. Follows
* scrolling and every change of size: a rotation, a fold, the pane beside the
* map opening, and on the vertical axis content that grows or shrinks inside
* a box that keeps its height.
*/
export function useEdgeFade(el: HTMLElement | null): EdgeFade {
export function useEdgeFade(el: HTMLElement | null, axis: EdgeFadeAxis = 'x'): EdgeFade {
const [fade, setFade] = useState<EdgeFade>(NONE);
useEffect(() => {
if (!el) return;
const measure = () => {
// scrollLeft runs from 0 towards the negative in a right-to-left strip.
const scrolled = Math.abs(el.scrollLeft);
const room = el.scrollWidth - el.clientWidth;
const scrolled = axis === 'x' ? Math.abs(el.scrollLeft) : el.scrollTop;
const room = axis === 'x' ? el.scrollWidth - el.clientWidth : el.scrollHeight - el.clientHeight;
const next = { start: scrolled > 1, end: room - scrolled > 1 };
setFade((prev) => (prev.start === next.start && prev.end === next.end ? prev : next));
};
@@ -30,18 +35,25 @@ export function useEdgeFade(el: HTMLElement | null): EdgeFade {
el.addEventListener('scroll', measure, { passive: true });
const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure);
observer?.observe(el);
// A form's fields come and go (a booking type, a split mode), which changes
// what there is to scroll without changing the box itself.
const content = axis === 'y' && typeof MutationObserver !== 'undefined' ? new MutationObserver(measure) : null;
content?.observe(el, { childList: true, subtree: true });
return () => {
el.removeEventListener('scroll', measure);
observer?.disconnect();
content?.disconnect();
};
}, [el]);
}, [el, axis]);
return fade;
}
/** The mask classes for a fade state. */
export function edgeFadeClass(fade: EdgeFade): string {
if (fade.start && fade.end) return 'm-fade-se';
if (fade.start) return 'm-fade-s';
if (fade.end) return 'm-fade-e';
export function edgeFadeClass(fade: EdgeFade, axis: EdgeFadeAxis = 'x'): string {
const [both, start, end] =
axis === 'x' ? ['m-fade-se', 'm-fade-s', 'm-fade-e'] : ['m-fade-tb', 'm-fade-t', 'm-fade-b'];
if (fade.start && fade.end) return both;
if (fade.start) return start;
if (fade.end) return end;
return '';
}