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.
This commit is contained in:
21 files changed
+535
-181
No files matched your search
@@ -37,7 +37,11 @@ export default class AppMenu extends Component {
|
||||
<template>
|
||||
<div
|
||||
class="sidebar app-menu-pane"
|
||||
{{bottomSheet detent="expanded" onDismiss=@onClose}}
|
||||
{{bottomSheet
|
||||
detent="expanded"
|
||||
onDismiss=@onClose
|
||||
background=@background
|
||||
}}
|
||||
>
|
||||
{{#if (eq this.currentView "menu")}}
|
||||
<AppMenuHome
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
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>
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
import { fn } from '@ember/helper';
|
||||
import { on } from '@ember/modifier';
|
||||
import Icon from './icon';
|
||||
import { htmlSafe } from '@ember/template';
|
||||
import restoreScroll from '../modifiers/restore-scroll';
|
||||
import bottomSheet from '../modifiers/bottom-sheet';
|
||||
|
||||
// The "Saved Places" collections index. Extracted from the route template so
|
||||
// it can render both as the interactive top sheet and as an inert background
|
||||
// sheet behind a list (see components/background-sheets.gjs).
|
||||
export default class ListsIndexSheetComponent extends Component {
|
||||
@service storage;
|
||||
@service router;
|
||||
@service mapUi;
|
||||
|
||||
savedList = {
|
||||
id: 'saved',
|
||||
title: 'Saved',
|
||||
color: 'var(--default-list-color)',
|
||||
};
|
||||
|
||||
styleFor(color) {
|
||||
const finalColor =
|
||||
color ||
|
||||
getComputedStyle(document.documentElement)
|
||||
.getPropertyValue('--default-list-color')
|
||||
.trim();
|
||||
return htmlSafe(`background-color: ${finalColor}`);
|
||||
}
|
||||
|
||||
get scrollTop() {
|
||||
return this.mapUi.getScrollPosition('lists-index');
|
||||
}
|
||||
|
||||
@action
|
||||
selectList(listId) {
|
||||
// Scope to the interactive top sheet: a background parent may also have a
|
||||
// .sidebar-content, and that is not the element being scrolled.
|
||||
const sidebarContent = document.querySelector(
|
||||
'.sheet-top .sidebar-content'
|
||||
);
|
||||
if (sidebarContent) {
|
||||
this.mapUi.saveScrollPosition('lists-index', sidebarContent.scrollTop);
|
||||
}
|
||||
this.router.transitionTo('lists.list', listId);
|
||||
}
|
||||
|
||||
@action
|
||||
close() {
|
||||
this.router.transitionTo('index');
|
||||
}
|
||||
|
||||
@action
|
||||
backToMenu() {
|
||||
this.router.transitionTo('menu');
|
||||
}
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="sidebar"
|
||||
{{bottomSheet
|
||||
detent="medium"
|
||||
onDismiss=this.close
|
||||
background=@background
|
||||
}}
|
||||
>
|
||||
<div class="sidebar-header has-back-btn">
|
||||
<button type="button" class="back-btn" {{on "click" this.backToMenu}}>
|
||||
<Icon @name="arrow-left" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
<h2 class="sidebar-header-text-centered">
|
||||
<span class="sidebar-header-icon-wrapper">
|
||||
<Icon @name="bookmark" @size={{20}} @color="#898989" />
|
||||
</span>
|
||||
Saved Places
|
||||
</h2>
|
||||
<button type="button" class="close-btn" {{on "click" this.close}}>
|
||||
<Icon @name="x" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-content" {{restoreScroll this.scrollTop}}>
|
||||
<ul class="places-list">
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
class="lists-index-item"
|
||||
{{on "click" (fn this.selectList this.savedList.id)}}
|
||||
>
|
||||
<div class="lists-index-item-left">
|
||||
{{! template-lint-disable no-inline-styles }}
|
||||
<span
|
||||
class="list-color-dot"
|
||||
style={{this.styleFor this.savedList.color}}
|
||||
></span>
|
||||
<div class="lists-index-name">{{this.savedList.title}}</div>
|
||||
</div>
|
||||
<div class="lists-index-count">
|
||||
{{#if this.storage.savedPlaces.length}}
|
||||
{{this.storage.savedPlaces.length}}
|
||||
places
|
||||
{{else}}
|
||||
empty
|
||||
{{/if}}
|
||||
</div>
|
||||
</button>
|
||||
</li>
|
||||
{{#each this.storage.lists as |list|}}
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
class="lists-index-item"
|
||||
{{on "click" (fn this.selectList list.id)}}
|
||||
>
|
||||
<div class="lists-index-item-left">
|
||||
{{! template-lint-disable no-inline-styles }}
|
||||
<span
|
||||
class="list-color-dot"
|
||||
style={{this.styleFor list.color}}
|
||||
></span>
|
||||
<div class="lists-index-name">{{list.title}}</div>
|
||||
</div>
|
||||
<div class="lists-index-count">
|
||||
{{#if list.placeRefs.length}}
|
||||
{{list.placeRefs.length}}
|
||||
places
|
||||
{{else}}
|
||||
empty
|
||||
{{/if}}
|
||||
</div>
|
||||
</button>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
}
|
||||
@@ -105,7 +105,7 @@ export default class PlaceDetails extends Component {
|
||||
|
||||
// Allow DOM to update first, then scroll to the top to show the new photo in the carousel
|
||||
setTimeout(() => {
|
||||
const sidebar = document.querySelector('.sidebar-content');
|
||||
const sidebar = document.querySelector('.sheet-top .sidebar-content');
|
||||
if (sidebar) {
|
||||
sidebar.scrollTop = 0;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,10 @@ export default class PlacesSidebar extends Component {
|
||||
}
|
||||
|
||||
<template>
|
||||
<div class="sidebar" {{bottomSheet detent="medium" onDismiss=@onClose}}>
|
||||
<div
|
||||
class="sidebar"
|
||||
{{bottomSheet detent="medium" onDismiss=@onClose background=@background}}
|
||||
>
|
||||
<div
|
||||
class="sidebar-header
|
||||
{{if this.hasHeaderPhoto 'no-border'}}
|
||||
|
||||
@@ -55,7 +55,9 @@ export default class ActivityController extends Controller {
|
||||
selectItem(item) {
|
||||
if (!item || !item.placeIdentifier) return;
|
||||
|
||||
const sidebarContent = document.querySelector('.sidebar-content');
|
||||
const sidebarContent = document.querySelector(
|
||||
'.sheet-top .sidebar-content'
|
||||
);
|
||||
if (sidebarContent) {
|
||||
this.mapUi.saveScrollPosition('activity', sidebarContent.scrollTop);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,9 @@ export default class ContributionsController extends Controller {
|
||||
selectContribution(item) {
|
||||
if (!item) return;
|
||||
|
||||
const sidebarContent = document.querySelector('.sidebar-content');
|
||||
const sidebarContent = document.querySelector(
|
||||
'.sheet-top .sidebar-content'
|
||||
);
|
||||
if (sidebarContent) {
|
||||
this.mapUi.saveScrollPosition('contributions', sidebarContent.scrollTop);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,9 @@ export default class ListsListController extends Controller {
|
||||
@action
|
||||
selectPlace(place) {
|
||||
if (place) {
|
||||
const sidebarContent = document.querySelector('.sidebar-content');
|
||||
const sidebarContent = document.querySelector(
|
||||
'.sheet-top .sidebar-content'
|
||||
);
|
||||
if (sidebarContent) {
|
||||
this.mapUi.saveScrollPosition(
|
||||
`list-${this.listId}`,
|
||||
|
||||
@@ -69,6 +69,13 @@ export default class BottomSheetModifier extends Modifier {
|
||||
this.element = element;
|
||||
this.named = named ?? {};
|
||||
|
||||
// Mark the sheet so selectors can tell the interactive top sheet from the
|
||||
// inert background (parent) sheet, even on desktop where the modifier does
|
||||
// not activate. This runs on every modify, before the active-state check.
|
||||
const background = !!this.named.background;
|
||||
element.classList.toggle('sheet-background', background);
|
||||
element.classList.toggle('sheet-top', !background);
|
||||
|
||||
if (firstRun) {
|
||||
this.mediaQuery = window.matchMedia(MOBILE_QUERY);
|
||||
this.reducedMotionQuery = window.matchMedia(REDUCED_MOTION_QUERY);
|
||||
@@ -105,9 +112,16 @@ export default class BottomSheetModifier extends Modifier {
|
||||
// A pending release from an earlier deactivate must not fire after we have
|
||||
// re-claimed the slot (breakpoint flip / disabled arg flip).
|
||||
this.cancelRelease();
|
||||
this.mapUi.claimSheetInset(this);
|
||||
this.injectHandle();
|
||||
this.element.addEventListener('pointerdown', this.onPointerDown);
|
||||
|
||||
// A background sheet sits behind the interactive one: it must not steal
|
||||
// inset ownership, take gestures, or inject a handle. It only restores the
|
||||
// remembered detent so the parent shows at the right size.
|
||||
if (!this.named.background) {
|
||||
this.mapUi.claimSheetInset(this);
|
||||
this.injectHandle();
|
||||
this.element.addEventListener('pointerdown', this.onPointerDown);
|
||||
}
|
||||
|
||||
this.measure();
|
||||
|
||||
const restored = this.mapUi.sheetDetent;
|
||||
@@ -126,7 +140,9 @@ export default class BottomSheetModifier extends Modifier {
|
||||
this.element.style.removeProperty('--sheet-height');
|
||||
this.element.style.removeProperty('--sheet-offset');
|
||||
this.cancelFlush();
|
||||
this.scheduleRelease();
|
||||
if (!this.named.background) {
|
||||
this.scheduleRelease();
|
||||
}
|
||||
}
|
||||
|
||||
teardown() {
|
||||
@@ -152,11 +168,14 @@ export default class BottomSheetModifier extends Modifier {
|
||||
this.element.removeEventListener('pointerdown', this.onPointerDown);
|
||||
this.removeHandle();
|
||||
}
|
||||
// Only release if we actually owned the slot; a modifier that never
|
||||
// activated (desktop) must not touch the service.
|
||||
// Only release if we actually owned the slot; a background sheet never
|
||||
// claims it, and a modifier that never activated (desktop) must not touch
|
||||
// the service at all.
|
||||
if (this.active) {
|
||||
this.cancelFlush();
|
||||
this.scheduleRelease();
|
||||
if (!this.named.background) {
|
||||
this.scheduleRelease();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +301,11 @@ export default class BottomSheetModifier extends Modifier {
|
||||
this.currentOffset = detent.offset;
|
||||
this.element.style.setProperty('--sheet-offset', `${detent.offset}px`);
|
||||
this.queueInset(this.sheetHeight - detent.offset);
|
||||
this.mapUi.setSheetDetent(detent.name);
|
||||
// Background sheets restore from the detent slot but must never write it:
|
||||
// the top sheet's position is the one worth remembering.
|
||||
if (!this.named.background) {
|
||||
this.mapUi.setSheetDetent(detent.name);
|
||||
}
|
||||
this.queueSnap();
|
||||
}
|
||||
|
||||
@@ -290,17 +313,20 @@ export default class BottomSheetModifier extends Modifier {
|
||||
const detent =
|
||||
findDetent(this.layout, name) ?? this.layout[this.layout.length - 1];
|
||||
|
||||
// Background sheets appear in place immediately (no entrance animation):
|
||||
// the top sheet animates over them, so a second animation would be a
|
||||
// distracting double-slide.
|
||||
if (this.named.background || this.reducedMotionQuery.matches) {
|
||||
this.settleAt(detent);
|
||||
return;
|
||||
}
|
||||
|
||||
// Start fully hidden, then slide to the detent on the next frame so the
|
||||
// transform transition animates the entrance.
|
||||
this.currentOffset = this.sheetHeight;
|
||||
this.element.style.setProperty('--sheet-offset', `${this.sheetHeight}px`);
|
||||
this.queueInset(0);
|
||||
|
||||
if (this.reducedMotionQuery.matches) {
|
||||
this.settleAt(detent);
|
||||
return;
|
||||
}
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
if (!this.active || this.destroyed) return;
|
||||
this.settleAt(detent);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1647,6 +1647,18 @@ button.create-place {
|
||||
/* Ensure content doesn't get hidden behind bottom safe areas on mobile */
|
||||
padding-bottom: env(safe-area-inset-bottom, 20px);
|
||||
}
|
||||
|
||||
/* A background (parent) sheet sits behind the interactive top sheet. Its
|
||||
z-index must stay below .sidebar (3100) and below the app menu's desktop
|
||||
3200, and it must not react to pointer events (it is also `inert`). */
|
||||
.sidebar.sheet-background {
|
||||
z-index: 3050;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.sheet-background-layer {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Search Box Component */
|
||||
|
||||
@@ -3,14 +3,17 @@ import { pageTitle } from 'ember-page-title';
|
||||
import Map from '#components/map';
|
||||
import AppHeader from '#components/app-header';
|
||||
import Toast from '#components/toast';
|
||||
import BackgroundSheets from '#components/background-sheets';
|
||||
import { service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
import { on } from '@ember/modifier';
|
||||
import { parentTransitionFor } from '../utils/sheet-parent';
|
||||
|
||||
export default class ApplicationComponent extends Component {
|
||||
@service storage;
|
||||
@service mapUi;
|
||||
@service router;
|
||||
@service viewport;
|
||||
|
||||
get isSidebarOpen() {
|
||||
// We consider the sidebar "open" if we are in search, menu, lists, contributions or place routes AND it's visible.
|
||||
@@ -47,35 +50,61 @@ export default class ApplicationComponent extends Component {
|
||||
@action
|
||||
handleOutsideClick() {
|
||||
const name = this.router.currentRouteName;
|
||||
if (
|
||||
const isSheetRoute =
|
||||
name === 'search' ||
|
||||
name === 'place' ||
|
||||
name === 'menu' ||
|
||||
name === 'contributions' ||
|
||||
name === 'activity' ||
|
||||
name.startsWith('lists');
|
||||
if (!isSheetRoute) return;
|
||||
|
||||
this.mapUi.clearSelection();
|
||||
|
||||
// Mobile: pop to the parent sheet and keep the session (and its remembered
|
||||
// detent) alive, so the parent is revealed underneath instead of the whole
|
||||
// stack being torn down. Routes with no parent fall through to close-all.
|
||||
if (this.viewport.isMobile) {
|
||||
const parent = parentTransitionFor(name, this.mapUi);
|
||||
if (parent) {
|
||||
this.transitionToParent(parent);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Desktop, or a mobile route with no parent: today's close-all.
|
||||
this.mapUi.hideSidebar();
|
||||
|
||||
if (
|
||||
name === 'menu' ||
|
||||
name === 'contributions' ||
|
||||
name === 'activity' ||
|
||||
name.startsWith('lists')
|
||||
) {
|
||||
this.mapUi.clearSelection();
|
||||
this.mapUi.hideSidebar();
|
||||
if (
|
||||
name === 'menu' ||
|
||||
name === 'contributions' ||
|
||||
name === 'activity' ||
|
||||
name.startsWith('lists')
|
||||
) {
|
||||
this.router.transitionTo('index');
|
||||
} else if (name === 'place') {
|
||||
if (this.mapUi.returnToSearch && this.mapUi.currentSearch) {
|
||||
this.router.transitionTo('search', {
|
||||
queryParams: this.mapUi.currentSearch,
|
||||
});
|
||||
} else {
|
||||
this.router.transitionTo('index');
|
||||
} else if (name === 'place') {
|
||||
if (this.mapUi.returnToSearch && this.mapUi.currentSearch) {
|
||||
this.router.transitionTo('search', {
|
||||
queryParams: this.mapUi.currentSearch,
|
||||
});
|
||||
} else {
|
||||
this.router.transitionTo('index');
|
||||
}
|
||||
} else if (name === 'search' && this.mapUi.searchResults.length === 0) {
|
||||
// An empty search has no markers worth keeping, so clear the route
|
||||
this.router.replaceWith('index');
|
||||
}
|
||||
} else if (name === 'search' && this.mapUi.searchResults.length === 0) {
|
||||
// An empty search has no markers worth keeping, so clear the route
|
||||
this.router.replaceWith('index');
|
||||
}
|
||||
}
|
||||
|
||||
transitionToParent(parent) {
|
||||
if (parent.model !== undefined) {
|
||||
this.router.transitionTo(parent.name, parent.model);
|
||||
} else if (parent.queryParams) {
|
||||
this.router.transitionTo(parent.name, {
|
||||
queryParams: parent.queryParams,
|
||||
});
|
||||
} else {
|
||||
this.router.transitionTo(parent.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +139,9 @@ export default class ApplicationComponent extends Component {
|
||||
|
||||
<Toast />
|
||||
|
||||
{{! Rendered before the outlet so the top sheet paints above it. }}
|
||||
<BackgroundSheets @isMobile={{this.viewport.isMobile}} />
|
||||
|
||||
{{outlet}}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,129 +1,13 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
import { fn } from '@ember/helper';
|
||||
import { on } from '@ember/modifier';
|
||||
import Icon from '#components/icon';
|
||||
import { htmlSafe } from '@ember/template';
|
||||
import restoreScroll from '../../modifiers/restore-scroll';
|
||||
import bottomSheet from '../../modifiers/bottom-sheet';
|
||||
import ListsIndexSheet from '#components/lists-index-sheet';
|
||||
|
||||
export default class ListsIndexTemplate extends Component {
|
||||
@service storage;
|
||||
@service router;
|
||||
@service mapUi;
|
||||
|
||||
savedList = {
|
||||
id: 'saved',
|
||||
title: 'Saved',
|
||||
color: 'var(--default-list-color)',
|
||||
};
|
||||
|
||||
styleFor(color) {
|
||||
const finalColor =
|
||||
color ||
|
||||
getComputedStyle(document.documentElement)
|
||||
.getPropertyValue('--default-list-color')
|
||||
.trim();
|
||||
return htmlSafe(`background-color: ${finalColor}`);
|
||||
}
|
||||
|
||||
get scrollTop() {
|
||||
return this.mapUi.getScrollPosition('lists-index');
|
||||
}
|
||||
|
||||
@action
|
||||
selectList(listId) {
|
||||
const sidebarContent = document.querySelector('.sidebar-content');
|
||||
if (sidebarContent) {
|
||||
this.mapUi.saveScrollPosition('lists-index', sidebarContent.scrollTop);
|
||||
}
|
||||
this.router.transitionTo('lists.list', listId);
|
||||
}
|
||||
|
||||
@action
|
||||
close() {
|
||||
this.router.transitionTo('index');
|
||||
}
|
||||
|
||||
@action
|
||||
backToMenu() {
|
||||
this.router.transitionTo('menu');
|
||||
}
|
||||
|
||||
<template>
|
||||
{{#if this.mapUi.isSidebarVisible}}
|
||||
<div class="sidebar" {{bottomSheet detent="medium" onDismiss=this.close}}>
|
||||
<div class="sidebar-header has-back-btn">
|
||||
<button type="button" class="back-btn" {{on "click" this.backToMenu}}>
|
||||
<Icon @name="arrow-left" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
<h2 class="sidebar-header-text-centered">
|
||||
<span class="sidebar-header-icon-wrapper">
|
||||
<Icon @name="bookmark" @size={{20}} @color="#898989" />
|
||||
</span>
|
||||
Saved Places
|
||||
</h2>
|
||||
<button type="button" class="close-btn" {{on "click" this.close}}>
|
||||
<Icon @name="x" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-content" {{restoreScroll this.scrollTop}}>
|
||||
<ul class="places-list">
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
class="lists-index-item"
|
||||
{{on "click" (fn this.selectList this.savedList.id)}}
|
||||
>
|
||||
<div class="lists-index-item-left">
|
||||
{{! template-lint-disable no-inline-styles }}
|
||||
<span
|
||||
class="list-color-dot"
|
||||
style={{this.styleFor this.savedList.color}}
|
||||
></span>
|
||||
<div class="lists-index-name">{{this.savedList.title}}</div>
|
||||
</div>
|
||||
<div class="lists-index-count">
|
||||
{{#if this.storage.savedPlaces.length}}
|
||||
{{this.storage.savedPlaces.length}}
|
||||
places
|
||||
{{else}}
|
||||
empty
|
||||
{{/if}}
|
||||
</div>
|
||||
</button>
|
||||
</li>
|
||||
{{#each this.storage.lists as |list|}}
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
class="lists-index-item"
|
||||
{{on "click" (fn this.selectList list.id)}}
|
||||
>
|
||||
<div class="lists-index-item-left">
|
||||
{{! template-lint-disable no-inline-styles }}
|
||||
<span
|
||||
class="list-color-dot"
|
||||
style={{this.styleFor list.color}}
|
||||
></span>
|
||||
<div class="lists-index-name">{{list.title}}</div>
|
||||
</div>
|
||||
<div class="lists-index-count">
|
||||
{{#if list.placeRefs.length}}
|
||||
{{list.placeRefs.length}}
|
||||
places
|
||||
{{else}}
|
||||
empty
|
||||
{{/if}}
|
||||
</div>
|
||||
</button>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<ListsIndexSheet />
|
||||
{{/if}}
|
||||
</template>
|
||||
}
|
||||
@@ -10,7 +10,9 @@ export default class SearchTemplate extends Component {
|
||||
@action
|
||||
selectPlace(place) {
|
||||
if (place) {
|
||||
const sidebarContent = document.querySelector('.sidebar-content');
|
||||
const sidebarContent = document.querySelector(
|
||||
'.sheet-top .sidebar-content'
|
||||
);
|
||||
if (sidebarContent) {
|
||||
this.mapUi.saveScrollPosition('search', sidebarContent.scrollTop);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
// Which sheet sits behind the current route's sheet on mobile.
|
||||
//
|
||||
// The URL stays authoritative: the stack is derived from the current route plus
|
||||
// the map-ui session flags, never pushed or popped imperatively. This module is
|
||||
// the single source of truth for both the background renderer
|
||||
// (components/background-sheets.gjs) and the mobile outside-tap behaviour
|
||||
// (templates/application.gjs).
|
||||
//
|
||||
// v1 only renders service-driven parents: the search results (map-ui), the
|
||||
// lists index (storage) and the app menu (self-contained). A place opened from
|
||||
// a list / contributions / activity timeline is deliberately parentless: those
|
||||
// parents are controller-driven, so revealing them needs a data hand-off that
|
||||
// is out of scope here. The pop still navigates to them; it just hard-cuts
|
||||
// instead of revealing a background sheet.
|
||||
|
||||
// Routes whose parent sheet is the app menu.
|
||||
const MENU_CHILD_ROUTES = new Set(['lists.index', 'contributions', 'activity']);
|
||||
|
||||
// The parent sheet to render behind `routeName`, or null when there is none.
|
||||
// Returns { type: 'search' | 'lists-index' | 'menu' }.
|
||||
export function parentSheetFor(routeName, mapUi) {
|
||||
if (routeName === 'place') {
|
||||
if (mapUi.returnToSearch && mapUi.currentSearch) {
|
||||
return { type: 'search' };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (routeName === 'lists.list') {
|
||||
return { type: 'lists-index' };
|
||||
}
|
||||
|
||||
if (MENU_CHILD_ROUTES.has(routeName)) {
|
||||
return { type: 'menu' };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// The route an outside tap should pop to on mobile, or null when the current
|
||||
// route has no parent (the sheet should close instead). This is broader than
|
||||
// parentSheetFor: it also covers controller-driven parents that are not
|
||||
// rendered as background sheets, so the session still survives the pop.
|
||||
// Returns a transition descriptor: { name, model? } or { name, queryParams }.
|
||||
export function parentTransitionFor(routeName, mapUi) {
|
||||
if (routeName === 'place') {
|
||||
if (mapUi.returnToSearch && mapUi.currentSearch) {
|
||||
return { name: 'search', queryParams: mapUi.currentSearch };
|
||||
}
|
||||
if (mapUi.returnToRoute) {
|
||||
return { ...mapUi.returnToRoute };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (routeName === 'lists.list') {
|
||||
return { name: 'lists.index' };
|
||||
}
|
||||
|
||||
if (MENU_CHILD_ROUTES.has(routeName)) {
|
||||
return { name: 'menu' };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -99,8 +99,10 @@ module('Acceptance | activity', function (hooks) {
|
||||
await visit('/activity');
|
||||
assert.strictEqual(currentURL(), '/activity');
|
||||
|
||||
assert.dom('.sidebar').exists('Sidebar is rendered');
|
||||
assert.dom('.sidebar-header-text-centered').includesText('Activity');
|
||||
assert.dom('.sheet-top').exists('Sidebar is rendered');
|
||||
assert
|
||||
.dom('.sheet-top .sidebar-header-text-centered')
|
||||
.includesText('Activity');
|
||||
});
|
||||
|
||||
test('activity items are rendered as zap rows', async function (assert) {
|
||||
@@ -118,14 +120,14 @@ module('Acceptance | activity', function (hooks) {
|
||||
await visit('/activity');
|
||||
assert.strictEqual(currentURL(), '/activity');
|
||||
|
||||
await click('.sidebar-header .close-btn');
|
||||
await click('.sheet-top .sidebar-header .close-btn');
|
||||
assert.strictEqual(currentURL(), '/', 'Returns to index');
|
||||
});
|
||||
|
||||
test('clicking back button returns to menu', async function (assert) {
|
||||
await visit('/activity');
|
||||
|
||||
await click('.sidebar-header .back-btn');
|
||||
await click('.sheet-top .sidebar-header .back-btn');
|
||||
assert.strictEqual(currentURL(), '/menu', 'Returns to menu');
|
||||
});
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
click,
|
||||
currentURL,
|
||||
triggerEvent,
|
||||
waitFor,
|
||||
waitUntil,
|
||||
} from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'marco/tests/helpers';
|
||||
@@ -188,7 +189,7 @@ module('Acceptance | bottom sheet', function (hooks) {
|
||||
// the new sheet's modifier). click() already settles.
|
||||
await click('.place-item');
|
||||
|
||||
assert.dom('.sidebar').exists('the place sheet is rendered');
|
||||
assert.dom('.sheet-top').exists('the place sheet is rendered');
|
||||
assert.ok(currentURL().includes('/place/'), 'navigated to the place');
|
||||
|
||||
await waitUntil(() => mapUi.sheetInsetPx > 0);
|
||||
@@ -201,6 +202,87 @@ module('Acceptance | bottom sheet', function (hooks) {
|
||||
}
|
||||
});
|
||||
|
||||
test('opening a place keeps the search sheet stacked behind it (mobile)', async function (assert) {
|
||||
const matchMediaStub = installMobileMatchMedia();
|
||||
try {
|
||||
await visit('/search?lat=1&lon=1');
|
||||
assert.dom('.place-item').exists('search results are rendered');
|
||||
|
||||
await click('.place-item');
|
||||
|
||||
assert.dom('.sheet-top').exists('the interactive top sheet is marked');
|
||||
assert
|
||||
.dom('.sheet-top.sheet-background')
|
||||
.doesNotExist('the top sheet is not a background sheet');
|
||||
assert
|
||||
.dom('.sheet-background')
|
||||
.exists('the parent sheet is rendered behind the top sheet');
|
||||
assert
|
||||
.dom('.sheet-background-layer[inert]')
|
||||
.exists('the background layer is inert');
|
||||
assert
|
||||
.dom('.sheet-background .place-item')
|
||||
.exists('the parent shows the search results');
|
||||
} finally {
|
||||
matchMediaStub.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('tapping the map on mobile pops to the parent search sheet (mobile)', async function (assert) {
|
||||
const matchMediaStub = installMobileMatchMedia();
|
||||
window.localStorage.setItem(
|
||||
'marco:map-view',
|
||||
JSON.stringify({ center: [13.4, 52.5], zoom: 18 })
|
||||
);
|
||||
try {
|
||||
const mapUi = this.owner.lookup('service:map-ui');
|
||||
|
||||
await visit('/search?lat=1&lon=1');
|
||||
await click('.place-item');
|
||||
assert.ok(currentURL().includes('/place/'), 'on the place sheet');
|
||||
assert.strictEqual(
|
||||
mapUi.sheetDetent,
|
||||
'medium',
|
||||
'the place sheet opened at the medium detent'
|
||||
);
|
||||
|
||||
await waitFor('canvas', { timeout: 2000 });
|
||||
const canvas = document.querySelector('canvas');
|
||||
await triggerEvent(canvas, 'pointerdown', {
|
||||
clientX: 200,
|
||||
clientY: 120,
|
||||
button: 0,
|
||||
isPrimary: true,
|
||||
});
|
||||
await triggerEvent(canvas, 'pointerup', {
|
||||
clientX: 200,
|
||||
clientY: 120,
|
||||
button: 0,
|
||||
isPrimary: true,
|
||||
});
|
||||
await triggerEvent(canvas, 'click', {
|
||||
clientX: 200,
|
||||
clientY: 120,
|
||||
bubbles: true,
|
||||
});
|
||||
|
||||
await waitUntil(() => currentURL().includes('/search'));
|
||||
assert.ok(
|
||||
currentURL().includes('/search'),
|
||||
'the outside tap popped back to the search route'
|
||||
);
|
||||
assert.strictEqual(
|
||||
mapUi.sheetDetent,
|
||||
'medium',
|
||||
'the remembered detent survives the pop'
|
||||
);
|
||||
assert.dom('.sheet-top').exists('a top sheet is still open');
|
||||
} finally {
|
||||
matchMediaStub.restore();
|
||||
window.localStorage.removeItem('marco:map-view');
|
||||
}
|
||||
});
|
||||
|
||||
test('dragging past the collapsed detent dismisses the sheet', async function (assert) {
|
||||
const matchMediaStub = installMobileMatchMedia();
|
||||
try {
|
||||
|
||||
@@ -79,7 +79,7 @@ module('Acceptance | collections navigation', function (hooks) {
|
||||
|
||||
// 2. Open the App Menu overlay
|
||||
await click('.menu-btn-integrated');
|
||||
assert.dom('.sidebar.app-menu-pane').exists('App menu sidebar is open');
|
||||
assert.dom('.sheet-top.app-menu-pane').exists('App menu sidebar is open');
|
||||
assert
|
||||
.dom('.app-menu')
|
||||
.includesText('Saved Places', 'Menu contains Saved Places link');
|
||||
@@ -88,7 +88,7 @@ module('Acceptance | collections navigation', function (hooks) {
|
||||
await click(document.querySelectorAll('.app-menu button')[0]); // Click "Saved Places"
|
||||
assert.strictEqual(currentURL(), '/lists', 'Transitions to /lists index');
|
||||
assert
|
||||
.dom('.sidebar-header-text-centered')
|
||||
.dom('.sheet-top .sidebar-header-text-centered')
|
||||
.includesText(
|
||||
'Saved Places',
|
||||
'Header is centered and titled Saved Places'
|
||||
@@ -120,7 +120,7 @@ module('Acceptance | collections navigation', function (hooks) {
|
||||
.hasText('Mountain Trail', 'Saved Places includes all saved places');
|
||||
|
||||
// 5. Go back to the Saved Places index
|
||||
await click('.sidebar-header .back-btn');
|
||||
await click('.sheet-top .sidebar-header .back-btn');
|
||||
assert.strictEqual(currentURL(), '/lists', 'Goes back to /lists index');
|
||||
|
||||
// 6. Transition to a specific real list (Want to go)
|
||||
@@ -141,15 +141,15 @@ module('Acceptance | collections navigation', function (hooks) {
|
||||
.hasText('Saved place', 'Place type displays Saved place correctly');
|
||||
|
||||
// 8. Click back button in collection list header
|
||||
await click('.sidebar-header .back-btn');
|
||||
await click('.sheet-top .sidebar-header .back-btn');
|
||||
assert.strictEqual(currentURL(), '/lists', 'Goes back to /lists index');
|
||||
|
||||
// 9. Click back button in collections index header
|
||||
await click('.sidebar-header .back-btn');
|
||||
await click('.sheet-top .sidebar-header .back-btn');
|
||||
assert.strictEqual(currentURL(), '/menu', 'Goes back to main menu route');
|
||||
|
||||
// 10. Close sidebar
|
||||
await click('.sidebar-header .close-btn');
|
||||
await click('.sheet-top .sidebar-header .close-btn');
|
||||
assert.strictEqual(currentURL(), '/', 'Sidebar closed and returned home');
|
||||
});
|
||||
|
||||
@@ -325,7 +325,9 @@ module('Acceptance | collections navigation', function (hooks) {
|
||||
await visit('/lists/to-go');
|
||||
await waitFor('.places-list');
|
||||
|
||||
const sidebarContent = document.querySelector('.sidebar-content');
|
||||
const sidebarContent = document.querySelector(
|
||||
'.sheet-top .sidebar-content'
|
||||
);
|
||||
sidebarContent.scrollTop = 300;
|
||||
assert.strictEqual(sidebarContent.scrollTop, 300, 'List is scrolled');
|
||||
|
||||
@@ -334,7 +336,7 @@ module('Acceptance | collections navigation', function (hooks) {
|
||||
// then return via the back button.
|
||||
const visibleItem = document.querySelectorAll('.place-item')[5];
|
||||
await click(visibleItem);
|
||||
await waitFor('.sidebar-content');
|
||||
await waitFor('.sheet-top .sidebar-content');
|
||||
await click('.back-btn');
|
||||
await waitFor('.places-list');
|
||||
|
||||
@@ -342,7 +344,7 @@ module('Acceptance | collections navigation', function (hooks) {
|
||||
await new Promise((resolve) => requestAnimationFrame(resolve));
|
||||
await new Promise((resolve) => requestAnimationFrame(resolve));
|
||||
|
||||
const restored = document.querySelector('.sidebar-content');
|
||||
const restored = document.querySelector('.sheet-top .sidebar-content');
|
||||
assert.strictEqual(
|
||||
restored.scrollTop,
|
||||
300,
|
||||
|
||||
@@ -94,7 +94,7 @@ module('Acceptance | contributions navigation', function (hooks) {
|
||||
|
||||
// Open the app menu
|
||||
await click('.menu-btn-integrated');
|
||||
assert.dom('.sidebar.app-menu-pane').exists('App menu sidebar is open');
|
||||
assert.dom('.sheet-top.app-menu-pane').exists('App menu sidebar is open');
|
||||
|
||||
// Click "My Contributions"
|
||||
const buttons = document.querySelectorAll('.app-menu button');
|
||||
@@ -109,7 +109,7 @@ module('Acceptance | contributions navigation', function (hooks) {
|
||||
'Transitions to /contributions'
|
||||
);
|
||||
assert
|
||||
.dom('.sidebar-header-text-centered')
|
||||
.dom('.sheet-top .sidebar-header-text-centered')
|
||||
.includesText('My Contributions', 'Header shows the title');
|
||||
|
||||
// Contribution item should be visible
|
||||
@@ -117,7 +117,7 @@ module('Acceptance | contributions navigation', function (hooks) {
|
||||
assert.dom('.contribution-place').includesText('Test Place');
|
||||
|
||||
// Click back button -> returns to menu
|
||||
await click('.sidebar-header .back-btn');
|
||||
await click('.sheet-top .sidebar-header .back-btn');
|
||||
assert.strictEqual(currentURL(), '/menu', 'Goes back to /menu');
|
||||
});
|
||||
|
||||
@@ -152,7 +152,7 @@ module('Acceptance | contributions navigation', function (hooks) {
|
||||
await visit('/contributions');
|
||||
await waitFor('.sidebar');
|
||||
|
||||
await click('.sidebar-header .close-btn');
|
||||
await click('.sheet-top .sidebar-header .close-btn');
|
||||
assert.strictEqual(currentURL(), '/', 'Returns to index');
|
||||
});
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ module('Acceptance | map search reset', function (hooks) {
|
||||
// 1. Visit a category search URL
|
||||
await visit('/search?category=coffee&lat=52.52&lon=13.405');
|
||||
|
||||
assert.dom('.sidebar-header').includesText('Results');
|
||||
assert.dom('.sheet-top .sidebar-header').includesText('Results');
|
||||
assert.ok(
|
||||
currentURL().includes('category=coffee'),
|
||||
'URL should have category param'
|
||||
|
||||
@@ -69,7 +69,7 @@ module('Acceptance | search', function (hooks) {
|
||||
await visit('/search?q=Berlin');
|
||||
|
||||
assert.strictEqual(currentURL(), '/search?q=Berlin');
|
||||
assert.dom('.sidebar-header h2').includesText('Results');
|
||||
assert.dom('.sheet-top .sidebar-header h2').includesText('Results');
|
||||
assert.dom('.places-list li').exists({ count: 2 });
|
||||
assert.dom('.places-list li:first-child .place-name').hasText('Berlin');
|
||||
});
|
||||
@@ -116,7 +116,7 @@ module('Acceptance | search', function (hooks) {
|
||||
await visit('/search?lat=52.52&lon=13.405');
|
||||
|
||||
assert.strictEqual(currentURL(), '/search?lat=52.52&lon=13.405');
|
||||
assert.dom('.sidebar-header h2').includesText('Nearby');
|
||||
assert.dom('.sheet-top .sidebar-header h2').includesText('Nearby');
|
||||
assert.dom('.places-list li').exists({ count: 1 });
|
||||
assert.dom('.places-list li .place-name').hasText('Nearby Cafe');
|
||||
});
|
||||
@@ -226,7 +226,7 @@ module('Acceptance | search', function (hooks) {
|
||||
assert.dom('.places-list li').exists({ count: 1 });
|
||||
assert.dom('.places-list li .place-name').hasText('Latte Art Cafe');
|
||||
// Ensure it shows "Results" not "Nearby"
|
||||
assert.dom('.sidebar-header h2').includesText('Results');
|
||||
assert.dom('.sheet-top .sidebar-header h2').includesText('Results');
|
||||
});
|
||||
|
||||
test('search error handling prevents opening empty panel and shows toast', async function (assert) {
|
||||
@@ -441,7 +441,7 @@ module('Acceptance | search', function (hooks) {
|
||||
|
||||
await visit('/search?category=nearby&lat=52.52&lon=13.405');
|
||||
|
||||
assert.dom('.sidebar-header h2').includesText('Nearby');
|
||||
assert.dom('.sheet-top .sidebar-header h2').includesText('Nearby');
|
||||
assert.dom('.search-input').hasValue('Nearby', 'Input indicates Nearby');
|
||||
|
||||
// Closing the sidebar keeps the search (and its markers) active, so the
|
||||
|
||||
Reference in new issue
Block a user