Files
marco/app/components/background-sheets.gjs
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

61 lines
2.0 KiB
Plaintext

import Component from '@glimmer/component';
import { service } from '@ember/service';
import { action } from '@ember/object';
import eq from 'ember-truth-helpers/helpers/eq';
import PlacesSidebar from './places-sidebar';
import AppMenu from './app-menu/index';
import ListsIndexSheet from './lists-index-sheet';
import { parentSheetFor } from '../utils/sheet-parent';
// Renders the parent ("background") sheet behind the current route's top sheet
// on mobile. It lives in application.gjs, before {{outlet}}, so it survives the
// route transition and paints below the top sheet at equal z-index (DOM order
// is the tiebreaker).
//
// The stack is derived from the URL + session flags; nothing is pushed or
// popped imperatively. Only service-driven parents are rendered in v1 (see
// utils/sheet-parent.js).
export default class BackgroundSheetsComponent extends Component {
@service mapUi;
@service router;
get parentType() {
return (
parentSheetFor(this.router.currentRouteName, this.mapUi)?.type ?? null
);
}
get shouldRender() {
return (
this.args.isMobile &&
this.mapUi.isSidebarVisible &&
this.parentType !== null
);
}
@action
noop() {}
<template>
{{#if this.shouldRender}}
{{! inert makes the whole subtree non-interactive and hidden from
assistive tech, so taps and focus fall through to the top sheet. }}
<div class="sheet-background-layer" inert>
{{#if (eq this.parentType "search")}}
<PlacesSidebar
@places={{this.mapUi.searchResults}}
@scrollTop={{this.mapUi.getScrollPosition "search"}}
@background={{true}}
@onClose={{this.noop}}
@onSelect={{this.noop}}
/>
{{else if (eq this.parentType "lists-index")}}
<ListsIndexSheet @background={{true}} />
{{else if (eq this.parentType "menu")}}
<AppMenu @background={{true}} @onClose={{this.noop}} />
{{/if}}
</div>
{{/if}}
</template>
}