Files
raucao c56917e122 WIP: Stack parent sheets behind the mobile bottom drawer
Derive the sheet stack from the URL instead of mutating it: the route
template keeps rendering the top sheet, and application.gjs renders the
service-driven parent (search results, lists index, app menu) behind it on
mobile, inert, so closing the top sheet reveals the parent at its
remembered size.

- bottom-sheet modifier: `background` arg — background instances settle
  immediately, inject no handle, take no gestures, never own the inset slot,
  and never write the remembered detent (restore-only).
- z-index: demote background sheets below the top sheet, including the app
  menu whose desktop z-index was inverted.
- outside tap on mobile pops to the parent without hideSidebar(), keeping
  the session and detent alive; desktop keeps today's close-all.
- tracked matchMedia-backed viewport service for the mobile breakpoint.
- lists index extracted into a component so it can render top or background.
- scope .sidebar-content lookups and test selectors to .sheet-top.

Known v1 limitation: popping hard-cuts to the parent route (no exit
animation). The full derived stack with independent detents for 3-level
chains is deferred.
2026-11-30 15:17:20 +04:00

34 lines
1.1 KiB
JavaScript

import Service from '@ember/service';
import { tracked } from '@glimmer/tracking';
// Must match the CSS `width <= 768px` query and the modifier's MOBILE_QUERY.
const MOBILE_QUERY = '(max-width: 768px)';
// Tracked breakpoint state so "desktop renders one sheet, mobile renders the
// stack" can re-render when the viewport crosses the breakpoint. Backed by
// matchMedia rather than a resize listener so it stays in sync with the CSS
// media queries that drive the sheet layout.
export default class ViewportService extends Service {
@tracked isMobile = false;
mediaQuery = null;
constructor() {
super(...arguments);
if (typeof window === 'undefined' || !window.matchMedia) return;
this.mediaQuery = window.matchMedia(MOBILE_QUERY);
this.isMobile = this.mediaQuery.matches;
this.onChange = (event) => {
this.isMobile = event.matches;
};
this.mediaQuery.addEventListener('change', this.onChange);
}
willDestroy() {
if (this.mediaQuery && this.onChange) {
this.mediaQuery.removeEventListener('change', this.onChange);
}
super.willDestroy(...arguments);
}
}