Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/_album.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
</div>

{#snippet actions(target: string, isPopover: boolean)}
<div class="stack-lg">
<div class="container-md stack-lg">
<header class="row-md row-justify">
<div class="row-md">
<Artwork {covers} id={menuTrack?.artworkId ?? album?.artworkId} size="lg" />
Expand Down
2 changes: 1 addition & 1 deletion src/_artist.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
</div>

{#snippet actions(target: string, isPopover: boolean)}
<div class="stack-lg">
<div class="container-md stack-lg">
<header class="row-md row-justify">
<div class="row-md">
<Artwork {covers} id={menuArtwork} size="lg" />
Expand Down
2 changes: 1 addition & 1 deletion src/_library.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
</div>

{#snippet artistActions(id: string, popover: boolean)}
<div class="stack-lg">
<div class="container-md stack-lg">
<header class="row-md row-justify">
<div class="row-md">
<Artwork {covers} id={menuArtist?.artworkId} size="lg" />
Expand Down
2 changes: 1 addition & 1 deletion src/_search.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@
</div>

{#snippet actions(target: string, isPopover: boolean)}
<div class="stack-lg">
<div class="container-md stack-lg">
<header class="row-md row-justify">
<div class="row-md">
<Artwork {covers} id={menuItem?.artworkId} size="lg" />
Expand Down
42 changes: 20 additions & 22 deletions src/app.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
let { network, auth, updaterComponent: Updater, settingsContent, demo = false }: Props = $props();

let navigationDrawer: HTMLDialogElement;
let navigationOpen = $state(false);

let updater = $state<ReturnType<typeof WebappUpdater>>();
const appUpdate = $derived(updater?.getStatus());
Expand Down Expand Up @@ -300,7 +299,6 @@
aria-label="Open menu"
aria-describedby={appUpdate?.hasUpdate ? "navigation-update-hint" : undefined}
aria-controls="navigation-dialog"
aria-expanded={navigationOpen}
commandfor="navigation-dialog"
command="show-modal"
>
Expand Down Expand Up @@ -364,31 +362,31 @@
</div>
{/if}
<dialog
class="right-sheet"
class="top-sheet"
id="navigation-dialog"
data-swiperight="close"
data-swipeup="close"
aria-label="Navigation"
closedby="any"
bind:this={navigationDrawer}
ontoggle={() => {
navigationOpen = navigationDrawer.open;
}}
>
<span class="dialog-handle" data-side="left" aria-hidden="true"></span>
<div class="stack-lg">
<header class="row-md row-justify">
{@render brand()}
<button
class="button"
aria-label="Close menu"
commandfor="navigation-dialog"
command="close"
>
<Icon name="cross" />
</button>
</header>
{@render navigation()}
<div class="sheet-header row-sm row-end">
<button
class="button"
data-variant="ghost"
aria-label="Close menu"
autofocus
commandfor="navigation-dialog"
command="close"
>
<Icon name="cross" />
</button>
</div>
<div class="sheet-body">
<div class="container-md stack-lg">
<div class="row-sm row-center">{@render brand()}</div>
{@render navigation()}
</div>
</div>
<span class="dialog-handle" data-side="bottom" aria-hidden="true"></span>
</dialog>
</div>
</div>
Expand Down
88 changes: 44 additions & 44 deletions src/edgerunner.css
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,18 @@
overflow: hidden;
white-space: nowrap;
}
}

/* App/reference measure; marketing has its own heading container. */
@scope (.app-root, .design-reference) {
.container-md {
inline-size: 100%;
max-inline-size: 22rem;
margin: auto;
}
}

@scope (.app-root, .design-reference, .website) {
/* Typography classes */

/* Visual roles are independent of HTML heading level, layout, and casing. */
Expand Down Expand Up @@ -1287,7 +1298,7 @@

/* Prototype overlay shells share appearance; sheets also share modal motion. */
.bottom-sheet,
.right-sheet,
.top-sheet,
.popover {
box-shadow: var(--shadow-xl);
box-sizing: border-box;
Expand All @@ -1303,8 +1314,14 @@
}

.bottom-sheet,
.right-sheet {
.top-sheet {
border-radius: 0;
&[open] {
translate: 0 var(--swipe-offset, 0px);
}
&[data-dragging] {
transition: none;
}
&:modal {
/* Stop chaining and native rubber-band bounce at modal boundaries. */
overscroll-behavior: none;
Expand Down Expand Up @@ -1334,7 +1351,6 @@
transition-behavior: allow-discrete;
}
&[open] {
translate: 0;
pointer-events: auto;
transition-duration: var(--motion-duration-enter);
transition-timing-function: var(--motion-ease-enter);
Expand All @@ -1356,44 +1372,28 @@
}
}

.bottom-sheet {
.top-sheet {
--sheet-closed-translate: 0 -100%;
inset: 0;
width: 100vw;
height: 100vh;
height: 100dvh;
max-height: none;
padding: 0;
&[open] {
translate: 0 var(--swipe-offset, 0px);
}
&[data-dragging] {
transition: none;
}
@media (prefers-reduced-motion: no-preference) {
@starting-style {
&[open] {
translate: var(--sheet-closed-translate);
}
}
display: grid;
grid-template-rows: auto minmax(min-content, 1fr) auto;
}
}

.right-sheet {
&[open] {
translate: var(--swipe-offset, 0px) 0;
}
&[data-dragging] {
transition: none;
}
@media (prefers-reduced-motion: no-preference) {
@starting-style {
&[open] {
translate: var(--sheet-closed-translate);
}
}
}
--sheet-closed-translate: 100% 0;
inset: 0 0 0 auto;
width: min(360px, calc(100dvw - 2 * var(--space-md)));
height: 100dvh;
max-height: none;
padding-block-start: max(var(--space-lg), env(safe-area-inset-top));
padding-block-end: max(var(--space-lg), env(safe-area-inset-bottom));
padding-inline-end: max(var(--space-lg), env(safe-area-inset-right));
.sheet-header {
padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 16px;
}

.sheet-body {
display: grid;
grid-template-columns: minmax(0, 1fr);
padding: 16px max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left));
}

.notification-popover {
Expand Down Expand Up @@ -1639,13 +1639,13 @@
background: var(--text-secondary);
pointer-events: none;

&[data-side="left"] {
inset-block-start: 50%;
inset-inline-start: var(--space-sm);
translate: 0 -50%;
inline-size: 6px;
block-size: 40px;
opacity: 0.5;
&[data-side="bottom"] {
display: block;
position: static;
inset: auto;
translate: none;
margin-inline: auto;
margin-block: 24px calc(32px + env(safe-area-inset-bottom));
}
}

Expand Down
27 changes: 14 additions & 13 deletions src/swipe-to-dismiss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export function installSwipeToDismiss(root: Document = document) {
let touchId: number | undefined;
let startX = 0;
let startY = 0;
let horizontal = false;
let sign = 1;
let dragging = false;
let threshold = 96;
let suppressed: HTMLDialogElement | undefined;
Expand All @@ -23,16 +23,18 @@ export function installSwipeToDismiss(root: Document = document) {
const target = event.target.closest("dialog");
if (!(target instanceof HTMLDialogElement) || !target.open) return;
const down = target.dataset.swipedown === "close";
const right = target.dataset.swiperight === "close";
// Each dialog opts into exactly one dismissal direction.
if (down === right) return;
horizontal = right;
const up = target.dataset.swipeup === "close";
// Each dialog opts into exactly one vertical dismissal direction.
if (down === up) return;
sign = up ? -1 : 1;
// Inputs keep their native gestures, including the playback seek slider.
if (event.target.closest("input, textarea, select, [contenteditable]")) return;

// Do not steal a gesture from content that can still scroll toward its start.
// Decide ownership only at gesture start. Upward reading scroll wins until
// every ancestor is at its bottom (allow fractional scroll rounding).
for (let node: Element | null = event.target; node; node = node.parentElement) {
if ((horizontal ? node.scrollLeft : node.scrollTop) > 0) return;
if (up ? node.scrollHeight - node.clientHeight - node.scrollTop > 1 : node.scrollTop > 0)
return;
if (node === target) break;
}

Expand All @@ -42,7 +44,7 @@ export function installSwipeToDismiss(root: Document = document) {
startX = touch.clientX;
startY = touch.clientY;
const bounds = dialog.getBoundingClientRect();
threshold = Math.max(72, Math.min(160, (horizontal ? bounds.width : bounds.height) * 0.2));
threshold = Math.max(72, Math.min(160, bounds.height * 0.2));
};

const move = (event: TouchEvent) => {
Expand All @@ -55,12 +57,11 @@ export function installSwipeToDismiss(root: Document = document) {
if (!touch) return;
const dy = touch.clientY - startY;
const dx = touch.clientX - startX;
const distance = horizontal ? dx : dy;
const perpendicular = horizontal ? dy : dx;
const distance = dy * sign;
if (!dragging) {
if (Math.max(Math.abs(dx), Math.abs(dy)) < 8) return;
// Once scrolling or a different direction wins, leave the rest of it native.
if (distance <= 0 || Math.abs(perpendicular) >= distance) {
if (distance <= 0 || Math.abs(dx) >= distance) {
reset();
return;
}
Expand All @@ -74,14 +75,14 @@ export function installSwipeToDismiss(root: Document = document) {
suppressed = dialog;
suppressClickUntil = Date.now() + 750;
dialog.setAttribute("data-dragging", "");
dialog.style.setProperty("--swipe-offset", `${Math.max(0, distance)}px`);
dialog.style.setProperty("--swipe-offset", `${Math.max(0, distance) * sign}px`);
};

const end = (event: TouchEvent) => {
const touch = Array.from(event.changedTouches).find((touch) => touch.identifier === touchId);
if (!touch || !dialog) return;
const target = dialog;
const distance = horizontal ? touch.clientX - startX : touch.clientY - startY;
const distance = (touch.clientY - startY) * sign;
const dismiss = target.isConnected && target.open && dragging && distance >= threshold;
if (dragging) {
if (event.cancelable) event.preventDefault();
Expand Down
Loading
Loading