Drawer headers: a shared DrawerHeader component renders the desktop nav-bar layout (back + centered title + close) and a mobile variant (left title, no back button, a single X that dismisses the top sheet — back when there is a parent, otherwise close). Place details uses the place name as its title with a compact, borderless header, and on mobile moves the photos below the place type. The X and back buttons now have aria-labels. Sheet scrolling: the content only scrolls while the sheet is at its largest detent; below that, dragging anywhere on the sheet (including list rows and links, not just the header) resizes it. At the largest detent, pulling down on the content while it is scrolled to the top shrinks the sheet (overscroll to shrink). Place details opens at the medium detent again. The mobile photo carousel no longer bleeds to the sheet edges, gets a wider gap and the same corner radius as the action buttons.
134 lines
3.9 KiB
Plaintext
134 lines
3.9 KiB
Plaintext
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 { htmlSafe } from '@ember/template';
|
|
import DrawerHeader from './drawer-header';
|
|
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
|
|
}}
|
|
>
|
|
<DrawerHeader
|
|
@title="Saved Places"
|
|
@icon="bookmark"
|
|
@onBack={{this.backToMenu}}
|
|
@onClose={{this.close}}
|
|
/>
|
|
|
|
<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>
|
|
}
|