Merge branch 'master' into kosmos
# Conflicts: # release/assets/main-bPhej5rb.js # release/assets/modules-4-12-CLqbt60f.js # release/assets/modules-4-12-CRUhRJ4U.js # release/assets/modules-4-12-D9tfwD7l.js # release/index.html
This commit is contained in:
48 files changed
+3352
-427
No files matched your search
@@ -3,6 +3,7 @@ import { action } from '@ember/object';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { on } from '@ember/modifier';
|
||||
import Icon from './icon';
|
||||
import DrawerHeader from './drawer-header';
|
||||
import TabNav from './tab-nav';
|
||||
import ActivityZapItem from './activity-zap-item';
|
||||
import ActivityPhotoItem from './activity-photo-item';
|
||||
@@ -13,6 +14,7 @@ import eq from 'ember-truth-helpers/helpers/eq';
|
||||
import and from 'ember-truth-helpers/helpers/and';
|
||||
import restoreScroll from '../modifiers/restore-scroll';
|
||||
import observeIntersection from '../modifiers/observe-intersection';
|
||||
import bottomSheet from '../modifiers/bottom-sheet';
|
||||
|
||||
export default class ActivityTimelineComponent extends Component {
|
||||
@tracked isNostrConnectModalOpen = false;
|
||||
@@ -40,21 +42,13 @@ export default class ActivityTimelineComponent extends Component {
|
||||
}
|
||||
|
||||
<template>
|
||||
<div class="sidebar">
|
||||
<div class="sidebar-header has-back-btn">
|
||||
<button type="button" class="back-btn" {{on "click" @onBack}}>
|
||||
<Icon @name="arrow-left" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
<h2 class="sidebar-header-text-centered">
|
||||
<span class="sidebar-header-icon-wrapper">
|
||||
<Icon @name="activity" @size={{20}} @color="#898989" />
|
||||
</span>
|
||||
Activity
|
||||
</h2>
|
||||
<button type="button" class="close-btn" {{on "click" @onClose}}>
|
||||
<Icon @name="x" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="sidebar" {{bottomSheet detent="medium" onDismiss=@onClose}}>
|
||||
<DrawerHeader
|
||||
@title="Activity"
|
||||
@icon="activity"
|
||||
@onBack={{@onBack}}
|
||||
@onClose={{@onClose}}
|
||||
/>
|
||||
|
||||
<TabNav
|
||||
@tabs={{this.tabs}}
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
import { on } from '@ember/modifier';
|
||||
import Icon from '#components/icon';
|
||||
import DrawerHeader from '#components/drawer-header';
|
||||
|
||||
<template>
|
||||
{{! template-lint-disable no-nested-interactive }}
|
||||
<div class="sidebar-header has-back-btn">
|
||||
<button type="button" class="back-btn" {{on "click" @onBack}}>
|
||||
<Icon @name="arrow-left" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
<h2 class="sidebar-header-text-centered">About</h2>
|
||||
<button type="button" class="close-btn" {{on "click" @onClose}}>
|
||||
<Icon @name="x" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
</div>
|
||||
<DrawerHeader @title="About" @onBack={{@onBack}} @onClose={{@onClose}} />
|
||||
|
||||
<div class="sidebar-content">
|
||||
<section class="about-section">
|
||||
|
||||
@@ -2,20 +2,15 @@ import { on } from '@ember/modifier';
|
||||
import { fn } from '@ember/helper';
|
||||
import { htmlSafe } from '@ember/template';
|
||||
import Icon from '#components/icon';
|
||||
import DrawerHeader from '#components/drawer-header';
|
||||
import iconRounded from '../../icons/icon-rounded.svg?raw';
|
||||
|
||||
<template>
|
||||
<div class="sidebar-header">
|
||||
<h2>
|
||||
<span class="app-logo-icon">
|
||||
{{htmlSafe iconRounded}}
|
||||
</span>
|
||||
Marco
|
||||
</h2>
|
||||
<button type="button" class="close-btn" {{on "click" @onClose}}>
|
||||
<Icon @name="x" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
</div>
|
||||
<DrawerHeader
|
||||
@logo={{htmlSafe iconRounded}}
|
||||
@title="Marco"
|
||||
@onClose={{@onClose}}
|
||||
/>
|
||||
|
||||
<div class="sidebar-content">
|
||||
<ul class="app-menu">
|
||||
|
||||
@@ -4,6 +4,7 @@ import { tracked } from '@glimmer/tracking';
|
||||
import { fn } from '@ember/helper';
|
||||
import { service } from '@ember/service';
|
||||
import eq from 'ember-truth-helpers/helpers/eq';
|
||||
import bottomSheet from '../../modifiers/bottom-sheet';
|
||||
|
||||
import AppMenuHome from './home';
|
||||
import AppMenuSettings from './settings';
|
||||
@@ -34,7 +35,10 @@ export default class AppMenu extends Component {
|
||||
}
|
||||
|
||||
<template>
|
||||
<div class="sidebar app-menu-pane">
|
||||
<div
|
||||
class="sidebar app-menu-pane"
|
||||
{{bottomSheet detent="medium" onDismiss=@onClose background=@background}}
|
||||
>
|
||||
{{#if (eq this.currentView "menu")}}
|
||||
<AppMenuHome
|
||||
@onNavigate={{this.setView}}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { on } from '@ember/modifier';
|
||||
import { action } from '@ember/object';
|
||||
import { service } from '@ember/service';
|
||||
import Icon from '#components/icon';
|
||||
import DrawerHeader from '#components/drawer-header';
|
||||
import AppMenuSettingsMapUi from './settings/map-ui';
|
||||
import AppMenuSettingsApis from './settings/apis';
|
||||
import AppMenuSettingsNostr from './settings/nostr';
|
||||
@@ -21,15 +20,7 @@ export default class AppMenuSettings extends Component {
|
||||
}
|
||||
|
||||
<template>
|
||||
<div class="sidebar-header has-back-btn">
|
||||
<button type="button" class="back-btn" {{on "click" @onBack}}>
|
||||
<Icon @name="arrow-left" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
<h2 class="sidebar-header-text-centered">Settings</h2>
|
||||
<button type="button" class="close-btn" {{on "click" @onClose}}>
|
||||
<Icon @name="x" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
</div>
|
||||
<DrawerHeader @title="Settings" @onBack={{@onBack}} @onClose={{@onClose}} />
|
||||
|
||||
<div class="sidebar-content">
|
||||
<section class="settings-section">
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
@@ -3,12 +3,14 @@ import { action } from '@ember/object';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { on } from '@ember/modifier';
|
||||
import Icon from './icon';
|
||||
import DrawerHeader from './drawer-header';
|
||||
import ContributionPhoto from './contribution-photo';
|
||||
import Modal from './modal';
|
||||
import NostrConnect from './nostr-connect';
|
||||
import eq from 'ember-truth-helpers/helpers/eq';
|
||||
import not from 'ember-truth-helpers/helpers/not';
|
||||
import restoreScroll from '../modifiers/restore-scroll';
|
||||
import bottomSheet from '../modifiers/bottom-sheet';
|
||||
|
||||
export default class ContributionsTimelineComponent extends Component {
|
||||
@tracked isNostrConnectModalOpen = false;
|
||||
@@ -31,21 +33,13 @@ export default class ContributionsTimelineComponent extends Component {
|
||||
}
|
||||
|
||||
<template>
|
||||
<div class="sidebar">
|
||||
<div class="sidebar-header has-back-btn">
|
||||
<button type="button" class="back-btn" {{on "click" @onBack}}>
|
||||
<Icon @name="arrow-left" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
<h2 class="sidebar-header-text-centered">
|
||||
<span class="sidebar-header-icon-wrapper">
|
||||
<Icon @name="user-check" @size={{20}} @color="#898989" />
|
||||
</span>
|
||||
My Contributions
|
||||
</h2>
|
||||
<button type="button" class="close-btn" {{on "click" @onClose}}>
|
||||
<Icon @name="x" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="sidebar" {{bottomSheet detent="medium" onDismiss=@onClose}}>
|
||||
<DrawerHeader
|
||||
@title="My Contributions"
|
||||
@icon="user-check"
|
||||
@onBack={{@onBack}}
|
||||
@onClose={{@onClose}}
|
||||
/>
|
||||
|
||||
<div class="sidebar-content" {{restoreScroll @scrollTop}}>
|
||||
{{#if @isLoading}}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { service } from '@ember/service';
|
||||
import { on } from '@ember/modifier';
|
||||
import Icon from './icon';
|
||||
|
||||
// The header row shared by every drawer/sidebar sheet.
|
||||
//
|
||||
// Desktop keeps the original two-button layout (optional back on the left,
|
||||
// centered title, close on the right). On mobile the back button is dropped and
|
||||
// the title is left-aligned, leaving a single trailing X that dismisses the top
|
||||
// sheet: it goes back one level when there is a parent, otherwise it closes.
|
||||
export default class DrawerHeaderComponent extends Component {
|
||||
@service viewport;
|
||||
|
||||
get isMobile() {
|
||||
return this.viewport.isMobile;
|
||||
}
|
||||
|
||||
get hasBack() {
|
||||
return typeof this.args.onBack === 'function';
|
||||
}
|
||||
|
||||
// Only desktop keeps the back button (and the centered title it implies).
|
||||
get desktopWithBack() {
|
||||
return !this.isMobile && this.hasBack;
|
||||
}
|
||||
|
||||
get iconColor() {
|
||||
return this.args.iconColor ?? '#898989';
|
||||
}
|
||||
|
||||
get variantClass() {
|
||||
return this.args.variant ? `sidebar-header-${this.args.variant}` : '';
|
||||
}
|
||||
|
||||
// The trailing X. On mobile it is the "back" affordance.
|
||||
get primaryAction() {
|
||||
if (this.isMobile && this.hasBack) {
|
||||
return this.args.onBack;
|
||||
}
|
||||
return this.args.onClose;
|
||||
}
|
||||
|
||||
get primaryActionLabel() {
|
||||
if (this.isMobile && this.hasBack) {
|
||||
return 'Back';
|
||||
}
|
||||
return 'Close';
|
||||
}
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="sidebar-header
|
||||
{{if @noBorder 'no-border'}}
|
||||
{{if this.desktopWithBack 'has-back-btn'}}
|
||||
{{this.variantClass}}"
|
||||
>
|
||||
{{#if this.desktopWithBack}}
|
||||
<button
|
||||
type="button"
|
||||
class="back-btn"
|
||||
aria-label="Back"
|
||||
{{on "click" @onBack}}
|
||||
>
|
||||
<Icon @name="arrow-left" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
{{/if}}
|
||||
|
||||
{{#if this.isMobile}}
|
||||
{{#if @title}}
|
||||
<h2 class="sidebar-header-title">
|
||||
{{#if @logo}}
|
||||
<span class="app-logo-icon">{{@logo}}</span>
|
||||
{{/if}}
|
||||
{{#if @icon}}
|
||||
<Icon @name={{@icon}} @size={{20}} @color={{this.iconColor}} />
|
||||
{{/if}}
|
||||
<span class="sidebar-header-title-text">{{@title}}</span>
|
||||
</h2>
|
||||
{{/if}}
|
||||
{{else if this.desktopWithBack}}
|
||||
{{#if @title}}
|
||||
<h2 class="sidebar-header-text-centered">
|
||||
{{#if @icon}}
|
||||
<span class="sidebar-header-icon-wrapper">
|
||||
<Icon @name={{@icon}} @size={{20}} @color={{this.iconColor}} />
|
||||
</span>
|
||||
{{/if}}
|
||||
{{@title}}
|
||||
</h2>
|
||||
{{/if}}
|
||||
{{else if @title}}
|
||||
<h2>
|
||||
{{#if @logo}}
|
||||
<span class="app-logo-icon">{{@logo}}</span>
|
||||
{{/if}}
|
||||
{{#if @icon}}
|
||||
<Icon @name={{@icon}} @size={{20}} @color={{this.iconColor}} />
|
||||
{{/if}}
|
||||
{{@title}}
|
||||
</h2>
|
||||
{{/if}}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="close-btn"
|
||||
aria-label={{this.primaryActionLabel}}
|
||||
{{on "click" this.primaryAction}}
|
||||
>
|
||||
<Icon @name="x" @size={{20}} @color="#333" />
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
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>
|
||||
}
|
||||
+39
-16
@@ -42,6 +42,7 @@ export default class MapComponent extends Component {
|
||||
crosshairElement;
|
||||
crosshairOverlay;
|
||||
ignoreNextMapClick = false;
|
||||
lastSheetSnapSeq;
|
||||
|
||||
setupMap = modifier((element) => {
|
||||
if (this.mapInstance) return;
|
||||
@@ -718,13 +719,12 @@ export default class MapComponent extends Component {
|
||||
size[0] * 0.15, // Left
|
||||
];
|
||||
|
||||
// Mobile: Bottom sheet covers 50% of the screen height
|
||||
// Mobile: the bottom sheet covers `sheetInsetPx` pixels from the bottom.
|
||||
if (size[0] <= 768) {
|
||||
// We want the geometry to be centered in the top 50% of the screen.
|
||||
// Top padding: 15% of the VISIBLE height (size[1] * 0.5)
|
||||
const visibleHeight = size[1] * 0.5;
|
||||
const inset = this.mapUi.sheetInsetPx;
|
||||
const visibleHeight = Math.max(size[1] - inset, 1);
|
||||
const topPadding = visibleHeight * 0.15;
|
||||
const bottomPadding = size[1] * 0.5 + visibleHeight * 0.15; // Sheet + padding
|
||||
const bottomPadding = inset + visibleHeight * 0.15;
|
||||
|
||||
padding[0] = topPadding;
|
||||
padding[2] = bottomPadding;
|
||||
@@ -801,17 +801,19 @@ export default class MapComponent extends Component {
|
||||
|
||||
let targetCenter = coords;
|
||||
|
||||
// Check if mobile (width <= 768px matches CSS)
|
||||
// Mobile (width <= 768px matches CSS). The desktop sidebar branch below
|
||||
// must never run here: it shifts the map center left to make room for the
|
||||
// sidebar, which pushes the pin to the right edge on a phone. `inset` is 0
|
||||
// until the sheet publishes its height, which is fine — it just centers.
|
||||
if (size[0] <= 768) {
|
||||
// On mobile, the bottom 50% is covered by the sheet.
|
||||
// We want the pin to be in the center of the TOP 50% (visible area), minus the header.
|
||||
|
||||
const height = size[1];
|
||||
const inset = this.mapUi.sheetInsetPx;
|
||||
const headerEl = document.querySelector('.app-header');
|
||||
const headerHeight = headerEl ? headerEl.offsetHeight : 60;
|
||||
|
||||
// Visible area is from headerHeight to height / 2 (bottom sheet covers bottom 50%)
|
||||
const visibleCenterY = headerHeight + (height / 2 - headerHeight) / 2;
|
||||
// Visible area runs from the header down to the top of the sheet.
|
||||
const visibleHeight = height - inset;
|
||||
const visibleCenterY = headerHeight + (visibleHeight - headerHeight) / 2;
|
||||
|
||||
// The map center is at y = height * 0.50.
|
||||
// So the pin is "above" the center by (height/2 - visibleCenterY) pixels.
|
||||
@@ -879,14 +881,17 @@ export default class MapComponent extends Component {
|
||||
const headerEl = document.querySelector('.app-header');
|
||||
const headerHeight = headerEl ? headerEl.offsetHeight : 60;
|
||||
|
||||
// 1. Mobile Bottom Sheet Logic (Screen <= 768px)
|
||||
// 1. Mobile Bottom Sheet Logic (Screen <= 768px). Always taken on mobile so
|
||||
// the desktop sidebar branch (which shifts the pin right) can never run
|
||||
// there, even before the sheet has published its inset.
|
||||
if (size[0] <= 768) {
|
||||
const height = size[1];
|
||||
const splitPoint = height / 2;
|
||||
const inset = this.mapUi.sheetInsetPx;
|
||||
const visibleHeight = height - inset;
|
||||
|
||||
// If in bottom half
|
||||
if (pixel[1] > splitPoint) {
|
||||
targetPixelY = headerHeight + (height / 2 - headerHeight) / 2; // Target: Center of visible area above bottom sheet
|
||||
// If obscured by the bottom sheet
|
||||
if (pixel[1] > visibleHeight) {
|
||||
targetPixelY = headerHeight + (visibleHeight - headerHeight) / 2; // Target: Center of visible area above bottom sheet
|
||||
needsPan = true;
|
||||
}
|
||||
}
|
||||
@@ -1006,6 +1011,23 @@ export default class MapComponent extends Component {
|
||||
}
|
||||
});
|
||||
|
||||
// Keep the CSS `--sheet-inset` custom property on the map container in sync
|
||||
// with the mobile bottom sheet. The crosshair (a child of the map container)
|
||||
// reads it via CSS. When a drag settles (snapSeq changes) we pan the selected
|
||||
// pin back into the visible area, but never per drag frame.
|
||||
syncSheetInset = modifier((element, [inset, snapSeq]) => {
|
||||
element.style.setProperty('--sheet-inset', `${inset || 0}px`);
|
||||
|
||||
const isInitialRun = this.lastSheetSnapSeq === undefined;
|
||||
if (!isInitialRun && snapSeq !== this.lastSheetSnapSeq) {
|
||||
const place = this.mapUi.selectedPlace;
|
||||
if (place && place.lat && place.lon) {
|
||||
this.panIfObscured(fromLonLat([place.lon, place.lat]));
|
||||
}
|
||||
}
|
||||
this.lastSheetSnapSeq = snapSeq;
|
||||
});
|
||||
|
||||
decodeVectorTileOsmFeature(feature) {
|
||||
if (!feature?.getId || !feature?.get) {
|
||||
return { decoded: null, reason: 'feature does not expose get()/getId()' };
|
||||
@@ -1387,6 +1409,7 @@ export default class MapComponent extends Component {
|
||||
{{this.updateSelectedPin}}
|
||||
{{this.syncPulse}}
|
||||
{{this.syncCreationMode}}
|
||||
{{this.syncSheetInset this.mapUi.sheetInsetPx this.mapUi.sheetSnapSeq}}
|
||||
></div>
|
||||
</template>
|
||||
}
|
||||
@@ -21,6 +21,14 @@ export default class PhotoCarousel extends Component {
|
||||
return this.args.photos || [];
|
||||
}
|
||||
|
||||
// A stable key that only changes when the photo set changes (add, remove or
|
||||
// reorder). `parsePlacePhotos` rebuilds the list on every update, so the
|
||||
// carousel uses this to re-align to the focused slide when the list shifts
|
||||
// underneath it, not only when the focused photo changes.
|
||||
get photoKey() {
|
||||
return this.photos.map((photo) => photo.eventId).join(',');
|
||||
}
|
||||
|
||||
get showChevrons() {
|
||||
// Only show chevrons if there's more than one photo
|
||||
return this.photos.length > 1;
|
||||
@@ -58,58 +66,73 @@ export default class PhotoCarousel extends Component {
|
||||
|
||||
isProgrammaticScroll = false;
|
||||
|
||||
scrollToNewPhoto = modifier((element, [eventId]) => {
|
||||
if (eventId && eventId !== this.lastEventId) {
|
||||
const isInitial = !this.lastEventId;
|
||||
this.lastEventId = eventId;
|
||||
// Scrolls the track to the slide for `eventId`. `instant` jumps without
|
||||
// animating (first paint, and re-aligning when the list shifts under us);
|
||||
// otherwise it uses the CSS smooth scrolling.
|
||||
scrollToSlide(element, eventId, instant) {
|
||||
const targetSlide = element.querySelector(`[data-event-id="${eventId}"]`);
|
||||
if (!targetSlide) {
|
||||
this.isProgrammaticScroll = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent feedback loop if this carousel initiated the change
|
||||
if (this.internalEventId === eventId) {
|
||||
return;
|
||||
}
|
||||
const originalScrollBehavior = element.style.scrollBehavior;
|
||||
if (instant) {
|
||||
element.style.scrollBehavior = 'auto';
|
||||
}
|
||||
element.scrollLeft = targetSlide.offsetLeft;
|
||||
if (instant) {
|
||||
// Restore smooth scrolling after the jump.
|
||||
setTimeout(() => {
|
||||
element.style.scrollBehavior = originalScrollBehavior;
|
||||
}, 50);
|
||||
}
|
||||
setTimeout(
|
||||
() => {
|
||||
this.isProgrammaticScroll = false;
|
||||
},
|
||||
instant ? 50 : 500
|
||||
);
|
||||
}
|
||||
|
||||
this.internalEventId = eventId;
|
||||
this.isProgrammaticScroll = true;
|
||||
scrollToNewPhoto = modifier((element, [eventId, photoKey]) => {
|
||||
if (!eventId) return;
|
||||
|
||||
const scrollAction = () => {
|
||||
const targetSlide = element.querySelector(
|
||||
`[data-event-id="${eventId}"]`
|
||||
);
|
||||
if (targetSlide) {
|
||||
if (isInitial) {
|
||||
const originalScrollBehavior = element.style.scrollBehavior;
|
||||
element.style.scrollBehavior = 'auto';
|
||||
element.scrollLeft = targetSlide.offsetLeft;
|
||||
const eventChanged = eventId !== this.lastEventId;
|
||||
const photosChanged = photoKey !== this.lastPhotoKey;
|
||||
if (!eventChanged && !photosChanged) return;
|
||||
|
||||
// Restore smooth scroll after the jump
|
||||
setTimeout(() => {
|
||||
element.style.scrollBehavior = originalScrollBehavior;
|
||||
this.isProgrammaticScroll = false;
|
||||
}, 50);
|
||||
} else {
|
||||
// Use native CSS smooth scrolling for subsequent clicks
|
||||
element.scrollLeft = targetSlide.offsetLeft;
|
||||
// Clear programmatic scroll flag after a delay to let scroll finish
|
||||
setTimeout(() => {
|
||||
this.isProgrammaticScroll = false;
|
||||
}, 500);
|
||||
}
|
||||
} else {
|
||||
this.isProgrammaticScroll = false;
|
||||
}
|
||||
};
|
||||
const isInitial = !this.lastEventId;
|
||||
this.lastEventId = eventId;
|
||||
this.lastPhotoKey = photoKey;
|
||||
|
||||
if (isInitial) {
|
||||
// Execute immediately for the first render to prevent flash
|
||||
scrollAction();
|
||||
} else {
|
||||
// Allow DOM to update first for subsequent clicks
|
||||
setTimeout(scrollAction, 100);
|
||||
}
|
||||
// Prevent feedback loop if this carousel initiated the change. Skipped when
|
||||
// only the list changed: we do need to re-align to the same event then.
|
||||
if (eventChanged && this.internalEventId === eventId) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.internalEventId = eventId;
|
||||
this.isProgrammaticScroll = true;
|
||||
|
||||
if (isInitial) {
|
||||
// Execute immediately for the first render to prevent flash
|
||||
this.scrollToSlide(element, eventId, true);
|
||||
} else if (eventChanged) {
|
||||
// Allow DOM to update first for subsequent clicks
|
||||
setTimeout(() => this.scrollToSlide(element, eventId, false), 100);
|
||||
} else {
|
||||
// The photo list changed without the focused event changing: a new photo
|
||||
// was inserted before it, so its offset shifted. Re-align once the DOM
|
||||
// has re-rendered, without animating.
|
||||
requestAnimationFrame(() => {
|
||||
if (this.isDestroyed) return;
|
||||
this.scrollToSlide(element, eventId, true);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
setupCarousel = modifier((element) => {
|
||||
setupCarousel = modifier((element, [photoKey]) => {
|
||||
this.carouselElement = element;
|
||||
|
||||
// Defer the initial calculation slightly to ensure CSS and images have applied
|
||||
@@ -151,8 +174,16 @@ export default class PhotoCarousel extends Component {
|
||||
}
|
||||
);
|
||||
|
||||
const slides = element.querySelectorAll('.carousel-slide');
|
||||
slides.forEach((slide) => intersectionObserver.observe(slide));
|
||||
// `photoKey` is part of the modifier's args so this re-runs when the
|
||||
// photo set changes; (re)observe after the DOM update so slides added by
|
||||
// that change are tracked too. The key guard drops a stale frame from a
|
||||
// superseded run.
|
||||
this.observedPhotoKey = photoKey;
|
||||
requestAnimationFrame(() => {
|
||||
if (this.isDestroyed || this.observedPhotoKey !== photoKey) return;
|
||||
const slides = element.querySelectorAll('.carousel-slide');
|
||||
slides.forEach((slide) => intersectionObserver.observe(slide));
|
||||
});
|
||||
}
|
||||
|
||||
return () => {
|
||||
@@ -205,9 +236,9 @@ export default class PhotoCarousel extends Component {
|
||||
<div class="photo-carousel {{this.variantClass}}">
|
||||
<div
|
||||
class="photo-carousel-track"
|
||||
{{this.setupCarousel}}
|
||||
{{this.setupCarousel this.photoKey}}
|
||||
{{this.resetScrollPosition @resetKey}}
|
||||
{{this.scrollToNewPhoto @scrollToEventId}}
|
||||
{{this.scrollToNewPhoto @scrollToEventId this.photoKey}}
|
||||
{{on "scroll" this.updateScrollState}}
|
||||
>
|
||||
{{#each this.photos as |photo|}}
|
||||
|
||||
@@ -136,6 +136,10 @@ export default class PhotoGallery extends Component {
|
||||
@service blossom;
|
||||
@service settings;
|
||||
|
||||
// The focused photo. `parsePlacePhotos` rebuilds the photo objects on every
|
||||
// update, so identity is unstable — comparisons below go through `eventId`
|
||||
// instead. The referenced Nostr event is immutable, so a held object stays
|
||||
// valid even when a newer object for the same event replaces it.
|
||||
@tracked currentPhoto = this.args.selectedPhoto || this.args.photos?.[0];
|
||||
@tracked zapModalOpen = false;
|
||||
|
||||
@@ -216,7 +220,7 @@ export default class PhotoGallery extends Component {
|
||||
|
||||
@action
|
||||
handleVisiblePhotoChange(photo) {
|
||||
if (this.currentPhoto !== photo) {
|
||||
if (this.currentPhoto?.eventId !== photo.eventId) {
|
||||
this.currentPhoto = photo;
|
||||
}
|
||||
}
|
||||
@@ -230,7 +234,9 @@ export default class PhotoGallery extends Component {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentIndex = this.args.photos.indexOf(this.currentPhoto);
|
||||
const currentIndex = this.args.photos.findIndex(
|
||||
(p) => p.eventId === this.currentPhoto?.eventId
|
||||
);
|
||||
if (currentIndex === -1) return;
|
||||
|
||||
if (e.key === 'ArrowLeft' && currentIndex > 0) {
|
||||
@@ -326,15 +332,19 @@ export default class PhotoGallery extends Component {
|
||||
}
|
||||
|
||||
deletePhotoTask = task(async () => {
|
||||
const deletedEventId = this.currentPhoto.eventId;
|
||||
const deletedIndex = this.args.photos?.indexOf(this.currentPhoto) ?? -1;
|
||||
// Hold the photo for the duration of the task: `args.photos` may drop the
|
||||
// event once the kind 5 is added to the store below.
|
||||
const photo = this.currentPhoto;
|
||||
const deletedEventId = photo.eventId;
|
||||
const deletedIndex =
|
||||
this.args.photos?.findIndex((p) => p.eventId === deletedEventId) ?? -1;
|
||||
|
||||
try {
|
||||
// Publish Nostr kind: 5 deletion event first so we don't end up with dead blossom links on a failure
|
||||
const tags = [['e', deletedEventId]];
|
||||
|
||||
if (this.currentPhoto.placeIdentifier) {
|
||||
tags.push(['i', this.currentPhoto.placeIdentifier]);
|
||||
if (photo.placeIdentifier) {
|
||||
tags.push(['i', photo.placeIdentifier]);
|
||||
}
|
||||
|
||||
const event = await withMarcoClientTag(
|
||||
@@ -361,9 +371,9 @@ export default class PhotoGallery extends Component {
|
||||
// to extracting them from the URLs for legacy events without `x`.
|
||||
const hashRegex = /[0-9a-f]{64}/i;
|
||||
const hashes =
|
||||
this.currentPhoto.hashes?.length > 0
|
||||
? this.currentPhoto.hashes
|
||||
: [this.currentPhoto.url, this.currentPhoto.thumbUrl]
|
||||
photo.hashes?.length > 0
|
||||
? photo.hashes
|
||||
: [photo.url, photo.thumbUrl]
|
||||
.map((url) => url?.match(hashRegex)?.[0])
|
||||
.filter(Boolean);
|
||||
|
||||
@@ -377,8 +387,9 @@ export default class PhotoGallery extends Component {
|
||||
|
||||
this.toast.show('Photo deleted successfully');
|
||||
|
||||
// Navigate to the next remaining photo, or close the gallery if none left.
|
||||
// this.args.photos may be stale until Glimmer re-renders, so filter locally.
|
||||
// Navigate to the next remaining photo, or close the gallery if none
|
||||
// left. `this.args.photos` may be stale until Glimmer re-renders, so
|
||||
// filter locally.
|
||||
const remaining = (this.args.photos || []).filter(
|
||||
(p) => p.eventId !== deletedEventId
|
||||
);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { service } from '@ember/service';
|
||||
import { on } from '@ember/modifier';
|
||||
import { scheduleTask } from 'ember-lifeline';
|
||||
import { modifier } from 'ember-modifier';
|
||||
import { htmlSafe } from '@ember/template';
|
||||
import { humanizeOsmTag } from '../utils/format-text';
|
||||
import { getLocalizedName, getPlaceType } from '../utils/osm';
|
||||
@@ -36,6 +38,7 @@ export default class PlaceDetails extends Component {
|
||||
@service mapUi;
|
||||
@service toast;
|
||||
@service router;
|
||||
@service viewport;
|
||||
@tracked isEditing = false;
|
||||
@tracked showLists = false;
|
||||
@tracked showShareMenu = false;
|
||||
@@ -46,6 +49,36 @@ export default class PlaceDetails extends Component {
|
||||
@tracked isPhotoUploadModalOpen = false;
|
||||
@tracked isNostrConnectModalOpen = false;
|
||||
@tracked newlyUploadedPhotoId = null;
|
||||
// Event id of the deep-linked photo we already auto-opened the gallery for,
|
||||
// so late-arriving photos or extra renders never reopen it. A plain field
|
||||
// (not rendered) so the render-time modifier can read and write it freely.
|
||||
autoOpenedPhotoEventId = null;
|
||||
|
||||
// Opens the gallery for a deep-linked photo (from `/e/:event_id`). Photos
|
||||
// load asynchronously (cache first, then relays) and more can arrive at any
|
||||
// time, so wait until the linked photo is present — revealing its author's
|
||||
// untrusted photos first if it is hidden — then open exactly once.
|
||||
//
|
||||
// State changes are deferred to the `actions` queue: the modifier runs during
|
||||
// the render, and both opening the gallery and revealing photos mutate
|
||||
// tracked state that is already being consumed by this render.
|
||||
syncDeepLinkedPhoto = modifier((element, [focusEventId, photos]) => {
|
||||
if (!focusEventId || this.autoOpenedPhotoEventId === focusEventId) return;
|
||||
|
||||
const photo = photos?.find((p) => p.eventId === focusEventId);
|
||||
if (photo) {
|
||||
this.autoOpenedPhotoEventId = focusEventId;
|
||||
scheduleTask(this, 'actions', () => this.openGallery(photo));
|
||||
return;
|
||||
}
|
||||
|
||||
// Not visible yet: if it is in the timeline but hidden as untrusted,
|
||||
// reveal its author's untrusted photos for this place. The resulting
|
||||
// `placePhotos` update re-runs this modifier, which then opens the gallery.
|
||||
scheduleTask(this, 'actions', () =>
|
||||
this.nostrData.revealPlacePhotoAuthor?.(focusEventId)
|
||||
);
|
||||
});
|
||||
|
||||
@action
|
||||
handleUploadStateChange(isActive) {
|
||||
@@ -73,7 +106,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;
|
||||
}
|
||||
@@ -100,6 +133,10 @@ export default class PlaceDetails extends Component {
|
||||
return this.args.place || {};
|
||||
}
|
||||
|
||||
get isMobile() {
|
||||
return this.viewport.isMobile;
|
||||
}
|
||||
|
||||
get saveablePlace() {
|
||||
if (this.place.createdAt) {
|
||||
return this.place;
|
||||
@@ -152,8 +189,14 @@ export default class PlaceDetails extends Component {
|
||||
// route's `photo` query param (see the `/e/:event_id` route), or a photo just
|
||||
// uploaded on this page.
|
||||
get focusPhotoEventId() {
|
||||
const photo = this.router.currentRoute?.queryParams?.photo;
|
||||
return photo || this.newlyUploadedPhotoId || null;
|
||||
return this.deepLinkedPhotoEventId || this.newlyUploadedPhotoId || null;
|
||||
}
|
||||
|
||||
// The event id of a photo deep-linked via the route's `photo` query param.
|
||||
// Unlike `focusPhotoEventId`, this excludes freshly-uploaded photos, which
|
||||
// only scroll the inline carousel and must not auto-open the gallery.
|
||||
get deepLinkedPhotoEventId() {
|
||||
return this.router.currentRoute?.queryParams?.photo || null;
|
||||
}
|
||||
|
||||
get hasMultipleUntrusted() {
|
||||
@@ -531,26 +574,59 @@ export default class PlaceDetails extends Component {
|
||||
return !!this.place.description;
|
||||
}
|
||||
|
||||
// A manual open or close means the user has taken over the gallery, so the
|
||||
// pending deep link is considered handled and must not hijack it later (e.g.
|
||||
// when the linked photo arrives after the user opened or closed the gallery).
|
||||
consumeDeepLink() {
|
||||
if (this.deepLinkedPhotoEventId && !this.autoOpenedPhotoEventId) {
|
||||
this.autoOpenedPhotoEventId = this.deepLinkedPhotoEventId;
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
openGallery(photo) {
|
||||
this.consumeDeepLink();
|
||||
this.selectedGalleryPhoto = photo;
|
||||
this.isGalleryOpen = true;
|
||||
}
|
||||
|
||||
@action
|
||||
closeGallery() {
|
||||
this.consumeDeepLink();
|
||||
this.isGalleryOpen = false;
|
||||
this.selectedGalleryPhoto = null;
|
||||
}
|
||||
|
||||
<template>
|
||||
<div class="place-details">
|
||||
<div
|
||||
class="place-details"
|
||||
{{this.syncDeepLinkedPhoto this.deepLinkedPhotoEventId this.photos}}
|
||||
>
|
||||
{{#if this.isEditing}}
|
||||
<PlaceEditForm
|
||||
@place={{this.place}}
|
||||
@onSave={{this.saveChanges}}
|
||||
@onCancel={{this.cancelEditing}}
|
||||
/>
|
||||
{{else if this.isMobile}}
|
||||
{{! Mobile: the name is the drawer header title, so the body starts at
|
||||
the type and the photos sit directly below it. }}
|
||||
<p class="place-type">
|
||||
{{this.type}}
|
||||
</p>
|
||||
<PhotoCarousel
|
||||
@variant="inline"
|
||||
@photos={{this.photos}}
|
||||
@name={{this.name}}
|
||||
@resetKey={{this.place.osmId}}
|
||||
@scrollToEventId={{this.focusPhotoEventId}}
|
||||
@onPhotoClick={{this.openGallery}}
|
||||
/>
|
||||
{{#if this.showDescription}}
|
||||
<p class="place-description">
|
||||
{{this.place.description}}
|
||||
</p>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
<PhotoCarousel
|
||||
@variant="inline"
|
||||
|
||||
@@ -5,20 +5,21 @@ import { on } from '@ember/modifier';
|
||||
import { fn } from '@ember/helper';
|
||||
import or from 'ember-truth-helpers/helpers/or';
|
||||
import eq from 'ember-truth-helpers/helpers/eq';
|
||||
import and from 'ember-truth-helpers/helpers/and';
|
||||
import not from 'ember-truth-helpers/helpers/not';
|
||||
import PlaceDetails from './place-details';
|
||||
import DrawerHeader from './drawer-header';
|
||||
import Icon from './icon';
|
||||
import humanizeOsmTag from '../helpers/humanize-osm-tag';
|
||||
import { getLocalizedName, getPlaceType } from '../utils/osm';
|
||||
import { getLocalizedName, getPlaceName, getPlaceType } from '../utils/osm';
|
||||
import { NEARBY_CATEGORY } from '../utils/poi-categories';
|
||||
import restoreScroll from '../modifiers/restore-scroll';
|
||||
import bottomSheet from '../modifiers/bottom-sheet';
|
||||
|
||||
export default class PlacesSidebar extends Component {
|
||||
@service storage;
|
||||
@service router;
|
||||
@service mapUi;
|
||||
@service nostrData;
|
||||
@service viewport;
|
||||
|
||||
@action
|
||||
createNewPlace() {
|
||||
@@ -158,6 +159,16 @@ export default class PlacesSidebar extends Component {
|
||||
);
|
||||
}
|
||||
|
||||
get isMobile() {
|
||||
return this.viewport.isMobile;
|
||||
}
|
||||
|
||||
// The place-details drawer header shows the place name as its title on
|
||||
// mobile; on desktop the name stays in the body above the photo carousel.
|
||||
get placeName() {
|
||||
return getPlaceName(this.args.selectedPlace);
|
||||
}
|
||||
|
||||
get hasHeaderPhoto() {
|
||||
return (
|
||||
this.args.selectedPlace &&
|
||||
@@ -167,55 +178,46 @@ export default class PlacesSidebar extends Component {
|
||||
}
|
||||
|
||||
<template>
|
||||
<div class="sidebar">
|
||||
<div
|
||||
class="sidebar-header
|
||||
{{if this.hasHeaderPhoto 'no-border'}}
|
||||
{{if (and (not @selectedPlace) @onBack) 'has-back-btn'}}"
|
||||
>
|
||||
{{#if @selectedPlace}}
|
||||
<button
|
||||
type="button"
|
||||
class="back-btn"
|
||||
{{on "click" this.clearSelection}}
|
||||
><Icon @name="arrow-left" @size={{20}} @color="#333" /></button>
|
||||
{{else}}
|
||||
{{#if @onBack}}
|
||||
<button type="button" class="back-btn" {{on "click" @onBack}}><Icon
|
||||
@name="arrow-left"
|
||||
@size={{20}}
|
||||
@color="#333"
|
||||
/></button>
|
||||
{{/if}}
|
||||
{{#if @onBack}}
|
||||
<h2 class="sidebar-header-text-centered">
|
||||
<span class="sidebar-header-icon-wrapper">
|
||||
<Icon
|
||||
@name="bookmark"
|
||||
@size={{20}}
|
||||
@color={{or @color "#898989"}}
|
||||
/>
|
||||
</span>
|
||||
{{@title}}
|
||||
</h2>
|
||||
{{else}}
|
||||
{{#if this.isNearbySearch}}
|
||||
<h2><Icon @name="target" @size={{20}} @color="#ea4335" />
|
||||
Nearby</h2>
|
||||
{{else}}
|
||||
<h2><Icon @name="search" @size={{20}} @color="#333" />
|
||||
Results</h2>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
<button type="button" class="close-btn" {{on "click" @onClose}}><Icon
|
||||
@name="x"
|
||||
@size={{20}}
|
||||
@color="#333"
|
||||
/></button>
|
||||
</div>
|
||||
<div
|
||||
class="sidebar"
|
||||
{{bottomSheet detent="medium" onDismiss=@onClose background=@background}}
|
||||
>
|
||||
{{#if @selectedPlace}}
|
||||
<DrawerHeader
|
||||
@title={{if this.isMobile this.placeName null}}
|
||||
@variant="place"
|
||||
@onBack={{this.clearSelection}}
|
||||
@onClose={{@onClose}}
|
||||
@noBorder={{or this.hasHeaderPhoto this.isMobile}}
|
||||
/>
|
||||
{{else if @onBack}}
|
||||
<DrawerHeader
|
||||
@title={{@title}}
|
||||
@icon="bookmark"
|
||||
@iconColor={{or @color "#898989"}}
|
||||
@onBack={{@onBack}}
|
||||
@onClose={{@onClose}}
|
||||
/>
|
||||
{{else if this.isNearbySearch}}
|
||||
<DrawerHeader
|
||||
@title="Nearby"
|
||||
@icon="target"
|
||||
@iconColor="#ea4335"
|
||||
@onClose={{@onClose}}
|
||||
/>
|
||||
{{else}}
|
||||
<DrawerHeader
|
||||
@title="Results"
|
||||
@icon="search"
|
||||
@iconColor="#333"
|
||||
@onClose={{@onClose}}
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
<div class="sidebar-content" {{restoreScroll @scrollTop}}>
|
||||
<div
|
||||
class="sidebar-content {{if @selectedPlace 'sidebar-content-place'}}"
|
||||
{{restoreScroll @scrollTop}}
|
||||
>
|
||||
{{#if @selectedPlace}}
|
||||
<PlaceDetails
|
||||
@place={{@selectedPlace}}
|
||||
|
||||
@@ -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}`,
|
||||
|
||||
@@ -0,0 +1,646 @@
|
||||
import Modifier from 'ember-modifier';
|
||||
import { service } from '@ember/service';
|
||||
import { registerDestructor } from '@ember/destroyable';
|
||||
import {
|
||||
clamp,
|
||||
computeDetentLayout,
|
||||
computeSheetHeight,
|
||||
findDetent,
|
||||
nearestDetentIndex,
|
||||
resolveSnap,
|
||||
} from '../utils/sheet-detents';
|
||||
|
||||
// The mobile breakpoint must match the CSS `width <= 768px` query and the
|
||||
// `size[0] <= 768` checks in components/map.gjs. matchMedia needs the
|
||||
// max-width form.
|
||||
const MOBILE_QUERY = '(max-width: 768px)';
|
||||
const REDUCED_MOTION_QUERY = '(prefers-reduced-motion: reduce)';
|
||||
|
||||
// How far the pointer must travel before a press becomes a drag. Keeps taps on
|
||||
// the header's back/close buttons working.
|
||||
const DRAG_THRESHOLD_PX = 6;
|
||||
|
||||
// Velocity is sampled over this trailing window.
|
||||
const VELOCITY_WINDOW_MS = 100;
|
||||
|
||||
// Must be >= the CSS transform transition duration.
|
||||
const TRANSITION_MS = 300;
|
||||
|
||||
const HANDLE_SELECTOR = '.sheet-handle, .sidebar-header';
|
||||
// Form fields keep the gesture for text selection / native controls. Buttons
|
||||
// and links elsewhere (list rows, header-adjacent controls aside) are drag
|
||||
// surfaces too — the drag threshold keeps taps working.
|
||||
const FORM_SELECTOR = 'input, select, textarea';
|
||||
const HEADER_CONTROL_SELECTOR = 'button, a';
|
||||
|
||||
// Fallback strip kept above a fully expanded sheet when the search field can't
|
||||
// be measured. The mobile header pads the search form down by 0.5rem.
|
||||
const DEFAULT_SHEET_TOP_GAP = 8;
|
||||
|
||||
export default class BottomSheetModifier extends Modifier {
|
||||
@service mapUi;
|
||||
@service router;
|
||||
|
||||
element = null;
|
||||
named = {};
|
||||
mediaQuery = null;
|
||||
reducedMotionQuery = null;
|
||||
active = false;
|
||||
destroyed = false;
|
||||
handle = null;
|
||||
previousDetentArg = null;
|
||||
|
||||
// Gesture state
|
||||
pointerId = null;
|
||||
pending = false;
|
||||
dragging = false;
|
||||
startY = 0;
|
||||
startOffset = 0;
|
||||
currentOffset = 0;
|
||||
samples = [];
|
||||
dismissTimer = null;
|
||||
|
||||
// Overscroll-to-shrink: set when a drag starts in the sheet content while the
|
||||
// sheet is at its largest detent and the content is scrolled to the top. A
|
||||
// downward pull then resizes the sheet instead of scrolling.
|
||||
overscroll = false;
|
||||
gestureStartY = 0;
|
||||
|
||||
// Deferred service writes. The Map reads sheetInsetPx during render, so the
|
||||
// modifier must not write it mid-render; it coalesces writes into a
|
||||
// requestAnimationFrame flush and releases ownership the same way.
|
||||
pendingInset = null;
|
||||
pendingSnap = false;
|
||||
flushRaf = null;
|
||||
releaseRaf = null;
|
||||
|
||||
// Layout, recomputed on viewport changes
|
||||
viewportHeight = 0;
|
||||
sheetHeight = 0;
|
||||
layout = [];
|
||||
|
||||
modify(element, _positional, named) {
|
||||
const firstRun = this.element === null;
|
||||
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);
|
||||
this.onMediaChange = () => this.applyActiveState();
|
||||
this.mediaQuery.addEventListener('change', this.onMediaChange);
|
||||
this.onResize = () => this.handleViewportChange();
|
||||
window.addEventListener('resize', this.onResize);
|
||||
if (window.visualViewport) {
|
||||
this.onVisualViewport = () => this.handleViewportChange();
|
||||
window.visualViewport.addEventListener('resize', this.onVisualViewport);
|
||||
}
|
||||
registerDestructor(this, () => this.teardown());
|
||||
}
|
||||
|
||||
this.applyActiveState();
|
||||
}
|
||||
|
||||
// --- activation -----------------------------------------------------------
|
||||
|
||||
applyActiveState() {
|
||||
const shouldBeActive = this.mediaQuery.matches && !this.named.disabled;
|
||||
|
||||
if (shouldBeActive && !this.active) {
|
||||
this.activate();
|
||||
} else if (!shouldBeActive && this.active) {
|
||||
this.deactivate();
|
||||
} else if (shouldBeActive) {
|
||||
this.handleDetentArgChange();
|
||||
}
|
||||
}
|
||||
|
||||
activate() {
|
||||
this.active = true;
|
||||
// A pending release from an earlier deactivate must not fire after we have
|
||||
// re-claimed the slot (breakpoint flip / disabled arg flip).
|
||||
this.cancelRelease();
|
||||
|
||||
// A background sheet sits behind the interactive one: it must not steal
|
||||
// inset ownership, take gestures, or inject a handle. It is pinned to the
|
||||
// minimum detent (see initialDetentName) so it stays hidden.
|
||||
if (!this.named.background) {
|
||||
this.mapUi.claimSheetInset(this);
|
||||
this.injectHandle();
|
||||
this.element.addEventListener('pointerdown', this.onPointerDown);
|
||||
// Non-passive so an overscroll pull can stop the browser from claiming
|
||||
// the pan and let the pointer drag resize the sheet instead.
|
||||
this.element.addEventListener('touchmove', this.onTouchMove, {
|
||||
passive: false,
|
||||
});
|
||||
}
|
||||
|
||||
this.measure();
|
||||
|
||||
this.previousDetentArg = this.named.detent ?? null;
|
||||
this.enterAt(this.initialDetentName());
|
||||
}
|
||||
|
||||
// The detent this sheet opens at. A background sheet is always minimized so
|
||||
// it can never peek above the interactive top sheet; a top sheet opens at the
|
||||
// detent remembered for its route, falling back to its declared default.
|
||||
initialDetentName() {
|
||||
if (this.named.background) return this.minimumDetent().name;
|
||||
return (
|
||||
this.mapUi.getSheetDetent(this.sheetKey()) ??
|
||||
this.named.detent ??
|
||||
this.minimumDetent().name
|
||||
);
|
||||
}
|
||||
|
||||
// The least-visible reachable detent (largest offset). The top sheet can
|
||||
// never be shorter than this, so a background sheet parked here is always
|
||||
// fully covered.
|
||||
minimumDetent() {
|
||||
return this.layout[this.layout.length - 1];
|
||||
}
|
||||
|
||||
// The most-visible reachable detent (smallest offset, 0 for the expanded
|
||||
// stop). The content only scrolls while the sheet rests here.
|
||||
isAtMax() {
|
||||
const max = this.layout[0]?.offset ?? 0;
|
||||
return this.currentOffset <= max + 0.5;
|
||||
}
|
||||
|
||||
// Mirrors the at-max state onto the element so CSS can switch the content
|
||||
// between "drag the sheet" and "scroll" (touch-action).
|
||||
syncAtMaxClass() {
|
||||
this.element.classList.toggle('sheet-at-max', this.isAtMax());
|
||||
}
|
||||
|
||||
// Sheet identity for the remembered-detent map. Background sheets never use
|
||||
// it (they are pinned to the minimum), so deriving it from the active route
|
||||
// is safe even though a background is rendered under a different route.
|
||||
sheetKey() {
|
||||
return this.router.currentRouteName ?? null;
|
||||
}
|
||||
|
||||
deactivate() {
|
||||
this.active = false;
|
||||
this.cancelDrag();
|
||||
this.element.removeEventListener('pointerdown', this.onPointerDown);
|
||||
this.element.removeEventListener('touchmove', this.onTouchMove);
|
||||
this.removeHandle();
|
||||
this.element.classList.remove('sheet-dragging');
|
||||
this.element.classList.remove('sheet-at-max');
|
||||
this.element.style.removeProperty('--sheet-height');
|
||||
this.element.style.removeProperty('--sheet-offset');
|
||||
this.cancelFlush();
|
||||
if (!this.named.background) {
|
||||
this.scheduleRelease();
|
||||
}
|
||||
}
|
||||
|
||||
teardown() {
|
||||
this.destroyed = true;
|
||||
if (this.dismissTimer) {
|
||||
clearTimeout(this.dismissTimer);
|
||||
this.dismissTimer = null;
|
||||
}
|
||||
this.cancelDrag();
|
||||
|
||||
if (this.mediaQuery && this.onMediaChange) {
|
||||
this.mediaQuery.removeEventListener('change', this.onMediaChange);
|
||||
}
|
||||
window.removeEventListener('resize', this.onResize);
|
||||
if (window.visualViewport && this.onVisualViewport) {
|
||||
window.visualViewport.removeEventListener(
|
||||
'resize',
|
||||
this.onVisualViewport
|
||||
);
|
||||
}
|
||||
|
||||
if (this.element) {
|
||||
this.element.removeEventListener('pointerdown', this.onPointerDown);
|
||||
this.element.removeEventListener('touchmove', this.onTouchMove);
|
||||
this.removeHandle();
|
||||
}
|
||||
// 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();
|
||||
if (!this.named.background) {
|
||||
this.scheduleRelease();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- deferred service writes ---------------------------------------------
|
||||
|
||||
queueInset(px) {
|
||||
this.pendingInset = Math.max(0, Math.round(px));
|
||||
this.scheduleFlush();
|
||||
}
|
||||
|
||||
queueSnap() {
|
||||
this.pendingSnap = true;
|
||||
this.scheduleFlush();
|
||||
}
|
||||
|
||||
// The modifier must not write tracked service state during render (the Map
|
||||
// reads sheetInsetPx while rendering), so writes are coalesced into a
|
||||
// requestAnimationFrame callback, which runs outside the render transaction.
|
||||
scheduleFlush() {
|
||||
if (this.flushRaf !== null) return;
|
||||
this.flushRaf = requestAnimationFrame(() => {
|
||||
this.flushRaf = null;
|
||||
this.flush();
|
||||
});
|
||||
}
|
||||
|
||||
cancelFlush() {
|
||||
if (this.flushRaf !== null) {
|
||||
cancelAnimationFrame(this.flushRaf);
|
||||
this.flushRaf = null;
|
||||
}
|
||||
}
|
||||
|
||||
flush() {
|
||||
if (this.pendingInset !== null) {
|
||||
this.mapUi.setSheetInsetFor(this, this.pendingInset);
|
||||
this.pendingInset = null;
|
||||
}
|
||||
if (this.pendingSnap) {
|
||||
this.pendingSnap = false;
|
||||
this.mapUi.snapSheetFor(this);
|
||||
}
|
||||
}
|
||||
|
||||
// The release is scheduled on its own frame (not tied to the modifier's
|
||||
// lifetime) so it still runs while the modifier is being torn down.
|
||||
// Ownership makes a stale release a no-op once a newer sheet has claimed.
|
||||
scheduleRelease() {
|
||||
this.cancelRelease();
|
||||
this.releaseRaf = requestAnimationFrame(() => {
|
||||
this.releaseRaf = null;
|
||||
this.mapUi.releaseSheetInset(this);
|
||||
});
|
||||
}
|
||||
|
||||
cancelRelease() {
|
||||
if (this.releaseRaf !== null) {
|
||||
cancelAnimationFrame(this.releaseRaf);
|
||||
this.releaseRaf = null;
|
||||
}
|
||||
}
|
||||
|
||||
// --- layout ---------------------------------------------------------------
|
||||
|
||||
measure() {
|
||||
// innerHeight is the numeric source of truth for height; a visualViewport
|
||||
// listener also fires when the iOS keyboard opens, and reading innerHeight
|
||||
// there keeps the measurement identical so the sheet does not collapse.
|
||||
this.viewportHeight = window.innerHeight;
|
||||
this.sheetHeight = computeSheetHeight(this.viewportHeight, this.topGap());
|
||||
this.layout = computeDetentLayout({
|
||||
viewportHeight: this.viewportHeight,
|
||||
sheetHeight: this.sheetHeight,
|
||||
});
|
||||
this.element.style.setProperty('--sheet-height', `${this.sheetHeight}px`);
|
||||
}
|
||||
|
||||
// The strip of viewport kept visible above a fully expanded sheet: the top of
|
||||
// the search field, so the sheet reaches up to (and covers) the search field
|
||||
// and avatar while leaving that little space above. Measured relative to the
|
||||
// sheet's container, since the viewport top is not the app's top (e.g. in
|
||||
// tests the app sits below the QUnit results).
|
||||
topGap() {
|
||||
const searchForm = document.querySelector('.search-form');
|
||||
const container = this.element?.parentElement;
|
||||
if (searchForm && container) {
|
||||
const gap =
|
||||
searchForm.getBoundingClientRect().top -
|
||||
container.getBoundingClientRect().top;
|
||||
if (gap > 0 && gap < 200) return Math.round(gap);
|
||||
}
|
||||
return DEFAULT_SHEET_TOP_GAP;
|
||||
}
|
||||
|
||||
handleViewportChange() {
|
||||
if (!this.active || this.destroyed) return;
|
||||
|
||||
this.measure();
|
||||
|
||||
// Mid-drag: keep the finger-following offset, only refresh the snap
|
||||
// targets so the release settles correctly.
|
||||
if (this.dragging || this.pending) return;
|
||||
|
||||
const name = this.named.background
|
||||
? this.minimumDetent().name
|
||||
: (this.mapUi.getSheetDetent(this.sheetKey()) ??
|
||||
this.named.detent ??
|
||||
this.minimumDetent().name);
|
||||
const detent = findDetent(this.layout, name) ?? this.minimumDetent();
|
||||
|
||||
// Skip the settle (and its map-pan signal) when nothing actually moved,
|
||||
// e.g. an iOS keyboard opening resizes the visual viewport but not
|
||||
// innerHeight.
|
||||
if (detent.offset === this.currentOffset) return;
|
||||
this.settleAt(detent);
|
||||
}
|
||||
|
||||
handleDetentArgChange() {
|
||||
// Background sheets are pinned to the minimum; a changing arg must not
|
||||
// un-minimize them.
|
||||
if (this.named.background) return;
|
||||
|
||||
const requested = this.named.detent ?? null;
|
||||
if (requested === this.previousDetentArg) return;
|
||||
this.previousDetentArg = requested;
|
||||
if (requested === null) return;
|
||||
if (this.dragging || this.pending) return;
|
||||
|
||||
const detent = findDetent(this.layout, requested);
|
||||
if (detent) this.settleAt(detent);
|
||||
}
|
||||
|
||||
// --- positioning ----------------------------------------------------------
|
||||
|
||||
applyOffset(offset) {
|
||||
const clamped = clamp(offset, 0, this.sheetHeight);
|
||||
this.currentOffset = clamped;
|
||||
this.element.style.setProperty('--sheet-offset', `${clamped}px`);
|
||||
this.queueInset(this.sheetHeight - clamped);
|
||||
this.syncAtMaxClass();
|
||||
}
|
||||
|
||||
settleAt(detent) {
|
||||
this.element.classList.remove('sheet-dragging');
|
||||
this.currentOffset = detent.offset;
|
||||
this.element.style.setProperty('--sheet-offset', `${detent.offset}px`);
|
||||
this.queueInset(this.sheetHeight - detent.offset);
|
||||
this.syncAtMaxClass();
|
||||
// Background sheets restore from the detent memory but must never write it:
|
||||
// the top sheet's position is the one worth remembering.
|
||||
if (!this.named.background) {
|
||||
this.mapUi.setSheetDetent(this.sheetKey(), detent.name);
|
||||
}
|
||||
this.queueSnap();
|
||||
}
|
||||
|
||||
enterAt(name) {
|
||||
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.syncAtMaxClass();
|
||||
this.queueInset(0);
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
if (!this.active || this.destroyed) return;
|
||||
this.settleAt(detent);
|
||||
});
|
||||
}
|
||||
|
||||
// --- handle ---------------------------------------------------------------
|
||||
|
||||
injectHandle() {
|
||||
if (this.handle) return;
|
||||
const handle = document.createElement('div');
|
||||
handle.className = 'sheet-handle';
|
||||
handle.setAttribute('aria-hidden', 'true');
|
||||
handle.setAttribute('data-test-sheet-handle', '');
|
||||
this.element.prepend(handle);
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
removeHandle() {
|
||||
if (this.handle?.parentNode) {
|
||||
this.handle.parentNode.removeChild(this.handle);
|
||||
}
|
||||
this.handle = null;
|
||||
}
|
||||
|
||||
// --- gestures -------------------------------------------------------------
|
||||
|
||||
onPointerDown = (event) => {
|
||||
if (this.destroyed || this.pointerId !== null) return;
|
||||
if (event.pointerType === 'mouse' && event.button !== 0) return;
|
||||
// Only the primary pointer may start a drag, so a second finger landing on
|
||||
// the header during a map pinch does not hijack the gesture.
|
||||
if (!event.isPrimary) return;
|
||||
|
||||
const target = event.target;
|
||||
if (!(target instanceof Element)) return;
|
||||
if (target.closest(FORM_SELECTOR)) return;
|
||||
|
||||
const onHandle = target.closest(HANDLE_SELECTOR);
|
||||
// Header controls stay tappable instead of starting a drag.
|
||||
if (onHandle && target.closest(HEADER_CONTROL_SELECTOR)) return;
|
||||
|
||||
const content = target.closest('.sidebar-content');
|
||||
|
||||
let overscroll = false;
|
||||
if (!onHandle) {
|
||||
// Below the largest detent the whole content is a drag surface. At the
|
||||
// largest detent it scrolls instead — unless it is scrolled to the top,
|
||||
// where a downward pull shrinks the sheet (overscroll).
|
||||
if (!content) return;
|
||||
if (this.isAtMax()) {
|
||||
if (content.scrollTop > 0) return;
|
||||
overscroll = true;
|
||||
}
|
||||
}
|
||||
|
||||
this.pointerId = event.pointerId;
|
||||
this.pending = true;
|
||||
this.dragging = false;
|
||||
this.overscroll = overscroll;
|
||||
this.gestureStartY = event.clientY;
|
||||
this.startY = event.clientY;
|
||||
this.startOffset = this.currentOffset;
|
||||
this.samples = [{ y: event.clientY, t: performance.now() }];
|
||||
|
||||
window.addEventListener('pointermove', this.onPointerMove, {
|
||||
passive: false,
|
||||
});
|
||||
window.addEventListener('pointerup', this.onPointerUp);
|
||||
window.addEventListener('pointercancel', this.onPointerCancel);
|
||||
};
|
||||
|
||||
// A non-passive touchmove listener (see activate) that keeps the browser from
|
||||
// claiming the pan while an overscroll pull is in progress, so the pointer
|
||||
// drag can shrink the sheet instead.
|
||||
onTouchMove = (event) => {
|
||||
if (!this.overscroll || !(this.pending || this.dragging)) return;
|
||||
const touch = event.touches?.[0];
|
||||
if (!touch) return;
|
||||
if (touch.clientY > this.gestureStartY && event.cancelable) {
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
onPointerMove = (event) => {
|
||||
if (event.pointerId !== this.pointerId) return;
|
||||
|
||||
if (this.pending) {
|
||||
const thresholdDy = event.clientY - this.startY;
|
||||
if (Math.abs(thresholdDy) < DRAG_THRESHOLD_PX) return;
|
||||
|
||||
// An upward pull at the top of the content should scroll it, not resize
|
||||
// the sheet, so hand the gesture back to the browser.
|
||||
if (this.overscroll && thresholdDy < 0) {
|
||||
this.endGesture();
|
||||
return;
|
||||
}
|
||||
|
||||
this.pending = false;
|
||||
this.dragging = true;
|
||||
this.element.classList.add('sheet-dragging');
|
||||
|
||||
// Rebase on the live visual position. While a snap or the entrance
|
||||
// transition is still interpolating, currentOffset already points at the
|
||||
// target, so using it here would make the sheet jump. Reading the actual
|
||||
// transform keeps the gesture continuous.
|
||||
this.startY = event.clientY;
|
||||
this.startOffset = this.readLiveOffset();
|
||||
this.samples = [{ y: event.clientY, t: performance.now() }];
|
||||
}
|
||||
|
||||
if (event.cancelable) event.preventDefault();
|
||||
this.recordSample(event.clientY);
|
||||
this.applyOffset(this.startOffset + (event.clientY - this.startY));
|
||||
};
|
||||
|
||||
onPointerUp = (event) => {
|
||||
if (event.pointerId !== this.pointerId) return;
|
||||
|
||||
// A press that never crossed the threshold is a tap: leave it to the
|
||||
// browser so header buttons keep working.
|
||||
if (this.pending) {
|
||||
this.endGesture();
|
||||
return;
|
||||
}
|
||||
|
||||
const velocity = this.computeVelocity();
|
||||
const target = resolveSnap({
|
||||
offset: this.currentOffset,
|
||||
velocity,
|
||||
layout: this.layout,
|
||||
sheetHeight: this.sheetHeight,
|
||||
});
|
||||
|
||||
this.endGesture();
|
||||
|
||||
if (target === 'dismissed') {
|
||||
this.dismiss();
|
||||
} else {
|
||||
const detent = findDetent(this.layout, target);
|
||||
if (detent) this.settleAt(detent);
|
||||
}
|
||||
};
|
||||
|
||||
onPointerCancel = (event) => {
|
||||
if (event.pointerId !== this.pointerId) return;
|
||||
const wasDragging = this.dragging;
|
||||
this.endGesture();
|
||||
if (!wasDragging) return;
|
||||
|
||||
const detent =
|
||||
this.layout[nearestDetentIndex(this.layout, this.currentOffset)];
|
||||
if (detent) this.settleAt(detent);
|
||||
};
|
||||
|
||||
dismiss() {
|
||||
this.element.classList.remove('sheet-dragging');
|
||||
this.currentOffset = this.sheetHeight;
|
||||
this.element.style.setProperty('--sheet-offset', `${this.sheetHeight}px`);
|
||||
this.syncAtMaxClass();
|
||||
this.queueInset(0);
|
||||
// A drag-dismiss forgets this sheet: the next time it opens it should use
|
||||
// its declared default, not the position the user dragged it to.
|
||||
this.mapUi.setSheetDetent(this.sheetKey(), null);
|
||||
|
||||
const onDismiss = this.named.onDismiss;
|
||||
const delay = this.reducedMotionQuery.matches ? 0 : TRANSITION_MS;
|
||||
this.dismissTimer = setTimeout(() => {
|
||||
this.dismissTimer = null;
|
||||
if (typeof onDismiss === 'function') onDismiss();
|
||||
}, delay);
|
||||
}
|
||||
|
||||
endGesture() {
|
||||
window.removeEventListener('pointermove', this.onPointerMove);
|
||||
window.removeEventListener('pointerup', this.onPointerUp);
|
||||
window.removeEventListener('pointercancel', this.onPointerCancel);
|
||||
this.pointerId = null;
|
||||
this.pending = false;
|
||||
this.dragging = false;
|
||||
this.overscroll = false;
|
||||
}
|
||||
|
||||
cancelDrag() {
|
||||
if (this.dismissTimer) {
|
||||
clearTimeout(this.dismissTimer);
|
||||
this.dismissTimer = null;
|
||||
}
|
||||
this.endGesture();
|
||||
this.element?.classList.remove('sheet-dragging');
|
||||
}
|
||||
|
||||
// The sheet's current visual offset in px, read from the rendered transform.
|
||||
// Differs from currentOffset while a CSS transition is still interpolating.
|
||||
readLiveOffset() {
|
||||
const transform = getComputedStyle(this.element).transform;
|
||||
if (!transform || transform === 'none') {
|
||||
return this.currentOffset;
|
||||
}
|
||||
try {
|
||||
const matrix = new DOMMatrixReadOnly(transform);
|
||||
return clamp(matrix.m42, 0, this.sheetHeight);
|
||||
} catch {
|
||||
return this.currentOffset;
|
||||
}
|
||||
}
|
||||
|
||||
recordSample(y) {
|
||||
const now = performance.now();
|
||||
this.samples.push({ y, t: now });
|
||||
while (
|
||||
this.samples.length > 2 &&
|
||||
now - this.samples[0].t > VELOCITY_WINDOW_MS * 1.5
|
||||
) {
|
||||
this.samples.shift();
|
||||
}
|
||||
}
|
||||
|
||||
computeVelocity() {
|
||||
const now = performance.now();
|
||||
const recent = this.samples.filter(
|
||||
(sample) => now - sample.t <= VELOCITY_WINDOW_MS
|
||||
);
|
||||
if (recent.length < 2) return 0;
|
||||
|
||||
const first = recent[0];
|
||||
const last = recent[recent.length - 1];
|
||||
const dt = last.t - first.t;
|
||||
if (dt <= 0) return 0;
|
||||
|
||||
// Positive velocity means the pointer moved downward.
|
||||
return (last.y - first.y) / dt;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,25 @@ export default class MapUiService extends Service {
|
||||
@tracked loadingState = null;
|
||||
@tracked isSidebarVisible = false;
|
||||
@tracked isSidebarOpening = false;
|
||||
// Mobile bottom-sheet state. `sheetInsetPx` is how many pixels the sheet
|
||||
// currently covers from the bottom of the viewport, and `sheetSnapSeq` bumps
|
||||
// whenever a drag settles so the map can react once (not per frame).
|
||||
//
|
||||
// `sheetDetents` remembers the detent per sheet, keyed by sheet identity
|
||||
// (route name), so a sheet reopens at the size the user last dragged it to.
|
||||
// `sheetDetent` mirrors the interactive (top) sheet's current detent. Both
|
||||
// are intentionally NOT tracked: the modifier reads them while setting up to
|
||||
// restore the previous position, and reading a tracked value there would
|
||||
// re-run setup on every drag frame.
|
||||
@tracked sheetInsetPx = 0;
|
||||
@tracked sheetSnapSeq = 0;
|
||||
sheetDetents = {};
|
||||
sheetDetent = null;
|
||||
// The modifier that currently owns the covered-height signal. A plain field
|
||||
// so it is safe to write during render. Writes to sheetInsetPx/sheetSnapSeq
|
||||
// are gated on this owner so a stale modifier can never corrupt the value
|
||||
// (see the ownership-token note on the setters below).
|
||||
sheetInsetOwner = null;
|
||||
|
||||
scrollPositions = {};
|
||||
|
||||
@@ -48,6 +67,65 @@ export default class MapUiService extends Service {
|
||||
hideSidebar() {
|
||||
this.isSidebarVisible = false;
|
||||
this.isSidebarOpening = false;
|
||||
this.resetSheet();
|
||||
}
|
||||
|
||||
// --- Bottom-sheet covered-height signal ----------------------------------
|
||||
//
|
||||
// The Map reads sheetInsetPx during render, so the modifier must never write
|
||||
// it (or sheetSnapSeq) while a render is in progress. Instead the modifier
|
||||
// owns the slot and writes through an afterRender flush. Ownership makes the
|
||||
// result independent of the order in which a stale modifier's release and a
|
||||
// live modifier's flush land in the afterRender queue.
|
||||
|
||||
claimSheetInset(owner) {
|
||||
this.sheetInsetOwner = owner;
|
||||
}
|
||||
|
||||
setSheetInsetFor(owner, px) {
|
||||
if (owner !== this.sheetInsetOwner) return;
|
||||
const next = Math.max(0, Math.round(px));
|
||||
// Guard against no-op writes: this build's tracked setter invalidates even
|
||||
// when the value is unchanged, and the drag calls this per frame.
|
||||
if (next !== this.sheetInsetPx) {
|
||||
this.sheetInsetPx = next;
|
||||
}
|
||||
}
|
||||
|
||||
snapSheetFor(owner) {
|
||||
if (owner !== this.sheetInsetOwner) return;
|
||||
this.sheetSnapSeq++;
|
||||
}
|
||||
|
||||
releaseSheetInset(owner) {
|
||||
if (owner !== this.sheetInsetOwner) return;
|
||||
this.sheetInsetOwner = null;
|
||||
if (this.sheetInsetPx !== 0) {
|
||||
this.sheetInsetPx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
getSheetDetent(key) {
|
||||
return this.sheetDetents[key] ?? null;
|
||||
}
|
||||
|
||||
// A null name forgets the sheet (used when a drag dismisses it), so the next
|
||||
// open falls back to the sheet's declared default.
|
||||
setSheetDetent(key, name) {
|
||||
if (key == null) return;
|
||||
if (name == null) {
|
||||
delete this.sheetDetents[key];
|
||||
} else {
|
||||
this.sheetDetents[key] = name;
|
||||
}
|
||||
this.sheetDetent = name ?? null;
|
||||
}
|
||||
|
||||
resetSheet() {
|
||||
this.sheetInsetOwner = null;
|
||||
this.sheetInsetPx = 0;
|
||||
this.sheetDetents = {};
|
||||
this.sheetDetent = null;
|
||||
}
|
||||
|
||||
selectPlace(place, options = {}) {
|
||||
|
||||
@@ -123,6 +123,11 @@ export default class NostrDataService extends Service {
|
||||
@tracked showUntrustedContent = false;
|
||||
// Count of currently-hidden (untrusted) place photos for the selected place.
|
||||
@tracked untrustedContentCount = 0;
|
||||
// Untrusted authors whose content is revealed for the currently selected
|
||||
// place because the user followed a deep link to one of their photos. Kept
|
||||
// place-scoped (cleared in `loadPhotosForPlace`) so a reveal never leaks into
|
||||
// other places. Reassigned — never mutated — to stay reactive.
|
||||
@tracked revealedUntrustedAuthors = new Set();
|
||||
_allPlacePhotos = [];
|
||||
|
||||
_profileSub = null;
|
||||
@@ -589,6 +594,7 @@ export default class NostrDataService extends Service {
|
||||
this._clearZapRefreshTimer();
|
||||
|
||||
this.placePhotos = [];
|
||||
this.revealedUntrustedAuthors = new Set();
|
||||
this.zapReceipts = {};
|
||||
this._lastPhotoIds = new Set();
|
||||
this._clearProfileSubs();
|
||||
@@ -646,14 +652,24 @@ export default class NostrDataService extends Service {
|
||||
);
|
||||
}
|
||||
|
||||
// Recompute `placePhotos` from `_allPlacePhotos` applying the trust filter
|
||||
// and the session-only reveal toggle. Called whenever the timeline emits or
|
||||
// the user flips `showUntrustedContent`.
|
||||
// Recompute `placePhotos` from `_allPlacePhotos` applying the trust filter,
|
||||
// the session-only reveal toggle and the per-place author reveals. Called
|
||||
// whenever the timeline emits, the user flips `showUntrustedContent` or a
|
||||
// deep link reveals an author.
|
||||
_updatePlacePhotos() {
|
||||
const events = this._allPlacePhotos;
|
||||
const { trusted, untrusted } = this.partitionByTrust(events);
|
||||
this.untrustedContentCount = untrusted.length;
|
||||
this.placePhotos = this.showUntrustedContent ? events : trusted;
|
||||
const trustedIds = new Set(trusted.map((e) => e.id));
|
||||
const hidden = untrusted.filter(
|
||||
(e) => !this.revealedUntrustedAuthors.has(e.pubkey)
|
||||
);
|
||||
this.untrustedContentCount = hidden.length;
|
||||
this.placePhotos = this.showUntrustedContent
|
||||
? events
|
||||
: events.filter(
|
||||
(e) =>
|
||||
trustedIds.has(e.id) || this.revealedUntrustedAuthors.has(e.pubkey)
|
||||
);
|
||||
}
|
||||
|
||||
@action
|
||||
@@ -662,6 +678,34 @@ export default class NostrDataService extends Service {
|
||||
this._updatePlacePhotos();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reveals all untrusted photos by the author of `eventId` for the current
|
||||
* place, so following a deep link to one untrusted photo also shows the rest
|
||||
* of that author's contribution. Other authors' hidden content stays hidden.
|
||||
*
|
||||
* Returns `true` when the event is present in the place timeline (hidden or
|
||||
* not) and `false` while it has not loaded yet, so callers can retry.
|
||||
*
|
||||
* @param {string} eventId
|
||||
* @returns {boolean}
|
||||
*/
|
||||
revealPlacePhotoAuthor(eventId) {
|
||||
if (!eventId) return false;
|
||||
|
||||
const event = this._allPlacePhotos.find((e) => e.id === eventId);
|
||||
if (!event) return false;
|
||||
|
||||
if (!this.revealedUntrustedAuthors.has(event.pubkey)) {
|
||||
this.revealedUntrustedAuthors = new Set([
|
||||
...this.revealedUntrustedAuthors,
|
||||
event.pubkey,
|
||||
]);
|
||||
this._updatePlacePhotos();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async loadMyContributions(pubkey) {
|
||||
if (!pubkey) return;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
+111
-20
@@ -23,6 +23,12 @@ html,
|
||||
body {
|
||||
height: 100%;
|
||||
overscroll-behavior: none; /* Prevent pull-to-refresh on mobile */
|
||||
|
||||
/* The mobile bottom sheet is translated below the viewport edge while
|
||||
collapsed/dragging; without this the page becomes scrollable. `hidden`
|
||||
(not `clip`) keeps the viewport a scroll container so focused inputs can
|
||||
still be scrolled into view when the mobile keyboard opens. */
|
||||
overflow: hidden;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
@@ -471,7 +477,6 @@ body {
|
||||
width: 100%;
|
||||
right: 0;
|
||||
border-radius: 16px 16px 0 0;
|
||||
height: 66vh;
|
||||
top: auto;
|
||||
bottom: 0;
|
||||
}
|
||||
@@ -1115,15 +1120,23 @@ abbr[title] {
|
||||
@media (width <= 768px) {
|
||||
.photo-carousel.inline .photo-carousel-track {
|
||||
scroll-snap-type: none;
|
||||
gap: 2px;
|
||||
gap: 6px;
|
||||
background-color: var(--primary-background-color);
|
||||
}
|
||||
|
||||
/* On mobile the inline carousel sits below the place type, not at the top of
|
||||
the content, so it must not bleed upward — or sideways, so the photos line
|
||||
up with the rest of the content. */
|
||||
.photo-carousel.inline {
|
||||
margin: 0 0 1rem;
|
||||
}
|
||||
|
||||
.photo-carousel.inline .carousel-slide {
|
||||
flex: 0 0 auto;
|
||||
height: 100px;
|
||||
width: auto;
|
||||
scroll-snap-align: none;
|
||||
border-radius: 4px; /* Match the action buttons below */
|
||||
}
|
||||
|
||||
.photo-carousel.inline .carousel-slide.landscape {
|
||||
@@ -1555,12 +1568,12 @@ span.icon {
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
/* Sidebar/Bottom Sheet is open (Mobile: Bottom 50%) */
|
||||
|
||||
/* Center Y = (height/2) / 2 = height/4 = 25% + half header height */
|
||||
/* Sidebar/Bottom Sheet is open (Mobile). Center the crosshair in the area
|
||||
above the sheet, whose covered height is exposed as --sheet-inset by the
|
||||
map container's syncSheetInset modifier. */
|
||||
.map-container.sidebar-open .map-crosshair {
|
||||
left: 50%; /* Reset desktop shift */
|
||||
top: calc(25% + 30px); /* 30px approx half header height */
|
||||
top: calc((100% - var(--sheet-inset, 50vh)) / 2 + 30px);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1585,24 +1598,82 @@ button.create-place {
|
||||
@media (width <= 768px) {
|
||||
.sidebar {
|
||||
width: 100%;
|
||||
height: 50vh;
|
||||
height: var(--sheet-height, 50vh);
|
||||
box-shadow: 0 -2px 10px rgb(0 0 0 / 10%);
|
||||
border-top-left-radius: 16px;
|
||||
border-top-right-radius: 16px;
|
||||
inset: auto 0 0;
|
||||
transform: translateY(var(--sheet-offset, 0));
|
||||
transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
touch-action: pan-y;
|
||||
}
|
||||
|
||||
/* The bottom-sheet modifier owns the mobile entrance, so the desktop
|
||||
slide-up keyframe must not run here. This selector matches the desktop
|
||||
rule's specificity (0,2,0) and comes later in the file, so it wins. */
|
||||
.sidebar-opening .sidebar {
|
||||
animation: sidebar-slide-up-bottom 0.18s cubic-bezier(0.16, 1, 0.3, 1)
|
||||
forwards;
|
||||
animation: none;
|
||||
}
|
||||
|
||||
/* While a drag is in progress the sheet must track the pointer exactly. */
|
||||
.sidebar.sheet-dragging {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
/* Injected by app/modifiers/bottom-sheet.js as the first child of the sheet.
|
||||
Keep the gap above the bar, but tighten the gap toward the content. */
|
||||
.sheet-handle {
|
||||
display: flex;
|
||||
flex: 0 0 auto;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
height: 16px;
|
||||
padding-top: 9px;
|
||||
background: transparent;
|
||||
cursor: grab;
|
||||
touch-action: none;
|
||||
}
|
||||
|
||||
.sheet-handle::before {
|
||||
content: '';
|
||||
width: 40px;
|
||||
height: 4px;
|
||||
border-radius: 999px;
|
||||
background: #ccc;
|
||||
}
|
||||
|
||||
/* The header doubles as a drag surface; disable native scrolling there so
|
||||
the gesture is not cancelled. The content is only scrollable while the
|
||||
sheet is at its largest detent — below that, dragging anywhere on it
|
||||
resizes the sheet (see the bottom-sheet modifier). */
|
||||
.sidebar-header {
|
||||
touch-action: none;
|
||||
}
|
||||
|
||||
.sidebar-content {
|
||||
touch-action: none;
|
||||
overflow-y: auto;
|
||||
|
||||
/* Ensure content doesn't get hidden behind bottom safe areas on mobile */
|
||||
padding-bottom: env(safe-area-inset-bottom, 20px);
|
||||
}
|
||||
|
||||
.sidebar.sheet-at-max .sidebar-content {
|
||||
touch-action: pan-y;
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
@@ -2451,17 +2522,6 @@ button.create-place {
|
||||
}
|
||||
}
|
||||
|
||||
/* Snappy slide-up from bottom (Mobile) */
|
||||
@keyframes sidebar-slide-up-bottom {
|
||||
from {
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
to {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Lists Index Sidebar Menu */
|
||||
.lists-index-item {
|
||||
width: 100%;
|
||||
@@ -2546,6 +2606,37 @@ button.create-place {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* Left-aligned title used by the mobile header. The text is clipped with an
|
||||
ellipsis so a long place name can't push the trailing button off-screen. */
|
||||
.sidebar-header-title {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.sidebar-header-title-text {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Place details uses the mobile header as a content title, not a nav bar:
|
||||
it is compact, borderless (via no-border) and sized like the body title. */
|
||||
@media (width <= 768px) {
|
||||
.sidebar-header-place {
|
||||
height: auto;
|
||||
padding: 0.5rem 1rem 0.25rem;
|
||||
}
|
||||
|
||||
.sidebar-header-place .sidebar-header-title {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
/* The type sits directly under the name, so the content needs no top gap. */
|
||||
.sidebar-content-place {
|
||||
padding-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Sidebar Loading State */
|
||||
.sidebar-loading {
|
||||
display: flex;
|
||||
|
||||
@@ -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,128 +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 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">
|
||||
<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>
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
import { on } from '@ember/modifier';
|
||||
import PlaceEditForm from '#components/place-edit-form';
|
||||
import Icon from '#components/icon';
|
||||
import DrawerHeader from '#components/drawer-header';
|
||||
import bottomSheet from '../../modifiers/bottom-sheet';
|
||||
|
||||
export default class PlaceNewTemplate extends Component {
|
||||
@service router;
|
||||
@@ -57,16 +57,13 @@ export default class PlaceNewTemplate extends Component {
|
||||
|
||||
<template>
|
||||
{{#if this.mapUi.isSidebarVisible}}
|
||||
<div class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<h2><Icon @name="plus-circle" @size={{20}} @color="#ea4335" />
|
||||
New Place</h2>
|
||||
<button
|
||||
type="button"
|
||||
class="close-btn"
|
||||
{{on "click" this.close}}
|
||||
><Icon @name="x" @size={{20}} @color="#333" /></button>
|
||||
</div>
|
||||
<div class="sidebar" {{bottomSheet detent="medium" onDismiss=this.close}}>
|
||||
<DrawerHeader
|
||||
@title="New Place"
|
||||
@icon="plus-circle"
|
||||
@iconColor="#ea4335"
|
||||
@onClose={{this.close}}
|
||||
/>
|
||||
|
||||
<div class="sidebar-content">
|
||||
<p class="helper-text">
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,14 @@ export function getLocalizedName(tags, defaultName = 'Untitled Place') {
|
||||
return defaultName;
|
||||
}
|
||||
|
||||
// The display name for a place: an explicit title (saved places) wins, then the
|
||||
// localized OSM name. Shared by the place details body and the drawer header so
|
||||
// both agree on the title.
|
||||
export function getPlaceName(place) {
|
||||
if (!place) return 'Untitled Place';
|
||||
return place.title || getLocalizedName(place.osmTags);
|
||||
}
|
||||
|
||||
const PLACE_TYPE_KEYS = [
|
||||
'craft',
|
||||
'amenity',
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
// Pure geometry and snap math for the mobile bottom sheet.
|
||||
//
|
||||
// Kept free of DOM and service dependencies so the drag/snap behaviour can be
|
||||
// unit tested directly. The modifier in app/modifiers/bottom-sheet.js owns the
|
||||
// DOM and gesture wiring and delegates every decision here.
|
||||
//
|
||||
// The sheet is positioned with `transform: translateY(--sheet-offset)`, where
|
||||
// the offset is the number of pixels pushed below the bottom of the viewport.
|
||||
// An offset of 0 is fully expanded; an offset equal to the sheet height is
|
||||
// fully hidden.
|
||||
|
||||
// Visible height of the sheet at each detent, as a fraction of the viewport.
|
||||
// The expanded stop is the whole sheet, whose height is the viewport minus the
|
||||
// small gap kept above it (see computeSheetHeight).
|
||||
export const DETENT_FRACTIONS = {
|
||||
expanded: 1,
|
||||
medium: 0.55,
|
||||
collapsed: 0.3,
|
||||
};
|
||||
|
||||
// Fling speed (px/ms) at or above which a release moves one detent in the
|
||||
// direction of the gesture instead of snapping to the nearest detent.
|
||||
export const FLING_THRESHOLD = 0.5;
|
||||
|
||||
// How far (as a fraction of the sheet height) the user must drag past the
|
||||
// collapsed detent to dismiss the sheet on release.
|
||||
export const DISMISS_EXTRA_FRACTION = 0.15;
|
||||
|
||||
export function clamp(value, min, max) {
|
||||
return Math.min(Math.max(value, min), max);
|
||||
}
|
||||
|
||||
// The sheet fills the viewport down from `topGap` pixels, so a fully expanded
|
||||
// sheet reaches up to the top of the search field while leaving that strip
|
||||
// visible above it.
|
||||
export function computeSheetHeight(viewportHeight, topGap = 0) {
|
||||
return Math.max(0, Math.round(viewportHeight - topGap));
|
||||
}
|
||||
|
||||
// Build the list of reachable detents for a given viewport and sheet height.
|
||||
// Returns entries sorted by ascending offset (expanded first) with any
|
||||
// duplicate offsets removed, so a very short sheet cannot produce two identical
|
||||
// stops.
|
||||
export function computeDetentLayout({
|
||||
viewportHeight,
|
||||
sheetHeight,
|
||||
detents = DETENT_FRACTIONS,
|
||||
}) {
|
||||
const entries = Object.entries(detents).map(([name, fraction]) => {
|
||||
const visibleHeight = Math.min(
|
||||
Math.round(fraction * viewportHeight),
|
||||
sheetHeight
|
||||
);
|
||||
const offset = clamp(sheetHeight - visibleHeight, 0, sheetHeight);
|
||||
return { name, fraction, visibleHeight, offset };
|
||||
});
|
||||
|
||||
entries.sort((a, b) => a.offset - b.offset);
|
||||
|
||||
const seen = new Set();
|
||||
const layout = entries.filter((entry) => {
|
||||
if (seen.has(entry.offset)) return false;
|
||||
seen.add(entry.offset);
|
||||
return true;
|
||||
});
|
||||
|
||||
// Floor rule: a sheet always has at least one reachable open position.
|
||||
if (layout.length === 0) {
|
||||
layout.push({
|
||||
name: 'collapsed',
|
||||
fraction: detents.collapsed,
|
||||
visibleHeight: sheetHeight,
|
||||
offset: 0,
|
||||
});
|
||||
}
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
export function findDetent(layout, name) {
|
||||
return layout.find((detent) => detent.name === name) ?? null;
|
||||
}
|
||||
|
||||
export function nearestDetentIndex(layout, offset) {
|
||||
let nearest = 0;
|
||||
let best = Infinity;
|
||||
layout.forEach((detent, index) => {
|
||||
const distance = Math.abs(detent.offset - offset);
|
||||
if (distance < best) {
|
||||
best = distance;
|
||||
nearest = index;
|
||||
}
|
||||
});
|
||||
return nearest;
|
||||
}
|
||||
|
||||
// Resolve where a released drag should settle.
|
||||
//
|
||||
// `velocity` is in px/ms and positive means downward. Returns a detent name, or
|
||||
// the string 'dismissed' when the sheet should close instead of snapping.
|
||||
export function resolveSnap({
|
||||
offset,
|
||||
velocity,
|
||||
layout,
|
||||
sheetHeight,
|
||||
flingThreshold = FLING_THRESHOLD,
|
||||
dismissExtraFraction = DISMISS_EXTRA_FRACTION,
|
||||
}) {
|
||||
const collapsed = layout[layout.length - 1];
|
||||
const dismissOffset = collapsed.offset + dismissExtraFraction * sheetHeight;
|
||||
|
||||
if (offset >= dismissOffset) return 'dismissed';
|
||||
if (velocity >= flingThreshold && offset > collapsed.offset) {
|
||||
return 'dismissed';
|
||||
}
|
||||
|
||||
const nearest = nearestDetentIndex(layout, offset);
|
||||
if (velocity <= -flingThreshold) {
|
||||
return layout[Math.max(0, nearest - 1)].name;
|
||||
}
|
||||
if (velocity >= flingThreshold) {
|
||||
return layout[Math.min(layout.length - 1, nearest + 1)].name;
|
||||
}
|
||||
return layout[nearest].name;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "marco",
|
||||
"version": "1.39.0",
|
||||
"version": "1.40.0",
|
||||
"private": true,
|
||||
"description": "Unhosted maps app",
|
||||
"repository": {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
:root{--body-text-color:#333;--primary-background-color:#fff;--hover-bg:#f8f9fa;--divider-color:#eee;--sidebar-width:350px;--link-color:#2a7fff;--link-color-visited:#6a4fbf;--marker-color-primary:#ea4335;--marker-color-dark:#b31412;--danger-color:var(--marker-color-primary);--danger-color-dark:var(--marker-color-dark);--default-list-color:#fc3;--secondary-text-color:#898989;--border-color:#d8d8d8;--success-color:#2e7d32;--secondary-background-color:#f0f0f0}html,body{overscroll-behavior:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent;height:100%}button{-webkit-tap-highlight-color:transparent}body{color:var(--body-text-color);margin:0;font-family:Noto Sans,sans-serif;font-size:16px;font-weight:400}#root,#ember-testing{height:100%}.map-container{-webkit-tap-highlight-color:transparent;background:#f8f9fa;outline:none;position:absolute;inset:0}#rs-widget-container{z-index:4000;display:none;position:absolute;top:60px;right:10px}#rs-widget-container.visible{display:block}.rs-backdrop{z-index:3999;position:fixed;inset:0}.app-header{z-index:3000;pointer-events:none;grid-template-columns:1fr auto 1fr;grid-template-areas:"search chips user";align-items:center;gap:1rem;height:60px;padding:.5rem 1rem;display:grid;position:absolute;top:0;left:0;right:0}@media (width<=768px){.app-header{grid-template-columns:1fr auto;grid-template-areas:"search user""chips chips";row-gap:8px;height:auto;padding:.5rem .5rem 0}}.header-left,.header-right,.header-center{pointer-events:auto}.header-left{grid-area:search;justify-self:start;align-items:center;width:100%;display:flex}@media (width>768px){.header-left{min-width:300px;max-width:350px}}.header-right{grid-area:user;justify-self:end}.header-center{grid-area:chips;justify-content:center;min-width:0;display:flex}@media (width>768px){.header-center .category-chips-scroll{width:auto;max-width:100%}}@media (width<=768px){.header-center{justify-content:start;width:100%;overflow:hidden}.header-center.searching{display:none}}.btn-press{transition:transform .1s}.btn-press:active{transform:scale(.95)}.user-btn{cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:flex}.user-avatar-placeholder{background:#2a3743;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:40px;height:40px;display:flex}.user-avatar{object-fit:cover;border-radius:50%;flex-shrink:0;width:40px;height:40px;display:block}.photo-preview-img{max-width:100%;height:auto}.dropzone{text-align:center;cursor:pointer;aspect-ratio:4/3;background-color:#ffffff05;border:2px dashed #ccc;border-radius:8px;margin:1.5rem 0 1rem;transition:all .2s}.dropzone.is-dragging{background-color:#61afef0d;border-color:#61afef}.dropzone-label{cursor:pointer;color:#898989;flex-direction:column;justify-content:center;align-items:center;gap:1rem;width:100%;height:100%;display:flex}.dropzone-label p{margin:0}.file-input-hidden{display:none}.photo-upload-item{aspect-ratio:4/3;background:#1e262e;border-radius:6px;width:100%;margin-bottom:1.25rem;position:relative;overflow:hidden}.photo-upload-item img{object-fit:contain;z-index:1;width:100%;height:100%;display:block;position:absolute;top:0;left:0}.photo-upload-item .overlay,.photo-upload-item .btn-remove-photo{z-index:2}.photo-upload-item .overlay{background:#0009;flex-direction:column;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.upload-status-text{color:#fff;text-shadow:0 1px 3px #000c;text-align:center;margin-top:1rem;padding:0 1rem;font-size:.9rem}.photo-upload-item .error-overlay{cursor:pointer;background:#e06c75cc;border:none;width:100%;margin:0;padding:0}.photo-upload-item .btn-remove-photo{cursor:pointer;color:#fff;background:#000000b3;border:none;border-radius:50%;justify-content:center;align-items:center;width:24px;height:24px;padding:0;display:flex;position:absolute;top:4px;right:4px}.photo-upload-item .btn-remove-photo:hover{background:var(--danger-color)}.spin-animation{animation:1s linear infinite spin}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.btn-publish{width:100%}.user-menu-container{position:relative}.user-menu-popover{z-index:3001;background:#fff;border-radius:8px;width:280px;margin-top:10px;padding:1rem;position:absolute;top:100%;right:0;box-shadow:0 4px 12px #00000026}.menu-backdrop{z-index:3000;position:fixed;inset:0}.account-list{margin:0;padding:0;list-style:none}.account-item{border-bottom:1px solid var(--divider-color);flex-direction:column;padding:1rem 0;display:flex}.account-item:last-child{border-bottom:none;padding-bottom:0}.account-item:first-child{padding-top:0}.account-header{justify-content:space-between;align-items:center;display:flex}.account-status{color:#898989;white-space:nowrap;text-overflow:ellipsis;margin-top:.35rem;margin-left:calc(18px + .75rem);font-size:.85rem;overflow:hidden}.account-status strong{font-weight:600}.account-item.disaLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),a=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:"Module"}),r},l=(e,i,o,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(var l,c=r(i),u=0,h=c.length;u<h;u++)l=c[u],s.call(e,l)||l===o||t(e,l,{get:(e=>i[e]).bind(null,l),enumerable:!(a=n(i,l))||a.enumerable});return e},c=(n,r,o)=>(o=null!=n?e(i(n)):{},l(!r&&n&&n.__esModule&&s.call(n,"default")?o:t(o,"default",{value:n,enumerable:!0}),n)),u=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)(function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))t(e);new MutationObserver(e=>{for(const n of e)if("childList"===n.type)for(const e of n.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&t(e)}).observe(document,{childList:!0,subtree:!0})}function t(e){if(e.ep)return;e.ep=!0;const t=function(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?t.credentials="include":"anonymous"===e.crossOrigin?t.credentials="omit":t.credentials="same-origin",t}(e);fetch(e.href,t)}}();var h,d=Object.prototype,p=Symbol("undefined"),f=function(e){return e[e.ADD=0]="ADD",e[e.ONCE=1]="ONCE",e[e.REMOVE=2]="REMOVE",e}(f||{}),g=1,m=class{_descriptors;_mixins;_isInit;_lazyChains;_values;_revisions;source;proto;_parent;_listeners;_listenersVersion=1;_inheritedEnd=-1;_flattenedVersion=0;constructor(e){this._parent=void 0,this._descriptors=void 0,this._mixins=void 0,this._lazyChains=void 0,this._values=void 0,this._revisions=void 0,this._isInit=!1,this.source=e,this.proto=void 0===e.constructor?void 0:e.constructor.prototype,this._listeners=void 0}get parent(){let e=this._parent;if(void 0===e){let t=y(this.source);this._parent=e=null===t||t===d?null:_(t)}return e}setInitializing(){this._isInit=!0}unsetInitializing(){this._isInit=!1}isInitializing(){return this._isInit}isPrototypeMeta(e){return this.proto===this.source&&this.source===e}_getOrCreateOwnMap(e){return this[e]||(this[e]=Object.create(null))}_getOrCreateOwnSet(e){return this[e]||(this[e]=new Set)}_findInheritedMap(e,t){let n=this;for(;null!==n;){let r=n[e];if(void 0!==r){let e=r.get(t);if(void 0!==e)return e}n=n.parent}}_hasInInheritedSet(e,t){let n=this;for(;null!==n;){let r=n[e];if(void 0!==r&&r.has(t))return!0;n=n.parent}return!1}valueFor(e){let t=this._values;return void 0!==t?t[e]:void 0}setValueFor(e,t){this._getOrCreateOwnMap("_values")[e]=t}revisionFor(e){let t=this._revisions;return void 0!==t?t[e]:void 0}setRevisionFor(e,t){this._getOrCreateOwnMap("_revisions")[e]=t}writableLazyChainsFor(e){let t=this._getOrCreateOwnMap("_lazyChains"),n=t[e];return void 0===n&&(n=t[e]=[]),n}readableLazyChainsFor(e){let t=this._lazyChains;if(void 0!==t)return t[e]}addMixin(e){this._getOrCreateOwnSet("_mixins").add(e)}hasMixin(e){return this._hasInInheritedSet("_mixins",e)}forEachMixins(e){let t,n=this;for(;null!==n;){let r=n._mixins;void 0!==r&&(t=void 0===t?new Set:t,r.forEach(n=>{t.has(n)||(t.add(n),e(n))})),n=n.parent}}writeDescriptors(e,t){(this._descriptors||(this._descriptors=new Map)).set(e,t)}peekDescriptors(e){let t=this._findInheritedMap("_descriptors",e);return t===p?void 0:t}removeDescriptors(e){this.writeDescriptors(e,p)}forEachDescriptors(e){let t,n=this;for(;null!==n;){let r=n._descriptors;void 0!==r&&(t=void 0===t?new Set:t,r.forEach((n,r)=>{t.has(r)||(t.add(r),n!==p&&e(r,n))})),n=n.parent}}addToListeners(e,t,n,r,i){this.pushListener(e,t,n,r?f.ONCE:f.ADD,i)}removeFromListeners(e,t,n){this.pushListener(e,t,n,f.REMOVE)}pushListener(e,t,n,r,i=!1){let s=this.writableListeners(),o=x(s,e,t,n);if(-1!==o&&o<this._inheritedEnd&&(s.splice(o,1),this._inheritedEnd--,o=-1),-1===o)s.push({event:e,target:t,method:n,kind:r,sync:i});else{let e=s[o];r===f.REMOVE&&e.kind!==f.REMOVE?s.splice(o,1):(e.kind=r,e.sync=i)}}writableListeners(){return this._flattenedVersion!==g||this.source!==this.proto&&-1!==this._inheritedEnd||g++,-1===this._inheritedEnd&&(this._inheritedEnd=0,this._listeners=[]),this._listeners}flattenedListeners(){if(this._flattenedVersion<g){let e=this.parent;if(null!==e){let t=e.flattenedListeners();if(void 0!==t)if(void 0===this._listeners)this._listeners=t;else{let e=this._listeners;this._inheritedEnd>0&&(e.splice(0,this._inheritedEnd),this._inheritedEnd=0);for(Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
:root{--body-text-color:#333;--primary-background-color:#fff;--hover-bg:#f8f9fa;--divider-color:#eee;--sidebar-width:350px;--link-color:#2a7fff;--link-color-visited:#6a4fbf;--marker-color-primary:#ea4335;--marker-color-dark:#b31412;--danger-color:var(--marker-color-primary);--danger-color-dark:var(--marker-color-dark);--default-list-color:#fc3;--secondary-text-color:#898989;--border-color:#d8d8d8;--success-color:#2e7d32;--secondary-background-color:#f0f0f0}html,body{overscroll-behavior:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent;height:100%;overflow:hidden}button{-webkit-tap-highlight-color:transparent}body{color:var(--body-text-color);margin:0;font-family:Noto Sans,sans-serif;font-size:16px;font-weight:400}#root,#ember-testing{height:100%}.map-container{-webkit-tap-highlight-color:transparent;background:#f8f9fa;outline:none;position:absolute;inset:0}#rs-widget-container{z-index:4000;display:none;position:absolute;top:60px;right:10px}#rs-widget-container.visible{display:block}.rs-backdrop{z-index:3999;position:fixed;inset:0}.app-header{z-index:3000;pointer-events:none;grid-template-columns:1fr auto 1fr;grid-template-areas:"search chips user";align-items:center;gap:1rem;height:60px;padding:.5rem 1rem;display:grid;position:absolute;top:0;left:0;right:0}@media (width<=768px){.app-header{grid-template-columns:1fr auto;grid-template-areas:"search user""chips chips";row-gap:8px;height:auto;padding:.5rem .5rem 0}}.header-left,.header-right,.header-center{pointer-events:auto}.header-left{grid-area:search;justify-self:start;align-items:center;width:100%;display:flex}@media (width>768px){.header-left{min-width:300px;max-width:350px}}.header-right{grid-area:user;justify-self:end}.header-center{grid-area:chips;justify-content:center;min-width:0;display:flex}@media (width>768px){.header-center .category-chips-scroll{width:auto;max-width:100%}}@media (width<=768px){.header-center{justify-content:start;width:100%;overflow:hidden}.header-center.searching{display:none}}.btn-press{transition:transform .1s}.btn-press:active{transform:scale(.95)}.user-btn{cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:flex}.user-avatar-placeholder{background:#2a3743;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:40px;height:40px;display:flex}.user-avatar{object-fit:cover;border-radius:50%;flex-shrink:0;width:40px;height:40px;display:block}.photo-preview-img{max-width:100%;height:auto}.dropzone{text-align:center;cursor:pointer;aspect-ratio:4/3;background-color:#ffffff05;border:2px dashed #ccc;border-radius:8px;margin:1.5rem 0 1rem;transition:all .2s}.dropzone.is-dragging{background-color:#61afef0d;border-color:#61afef}.dropzone-label{cursor:pointer;color:#898989;flex-direction:column;justify-content:center;align-items:center;gap:1rem;width:100%;height:100%;display:flex}.dropzone-label p{margin:0}.file-input-hidden{display:none}.photo-upload-item{aspect-ratio:4/3;background:#1e262e;border-radius:6px;width:100%;margin-bottom:1.25rem;position:relative;overflow:hidden}.photo-upload-item img{object-fit:contain;z-index:1;width:100%;height:100%;display:block;position:absolute;top:0;left:0}.photo-upload-item .overlay,.photo-upload-item .btn-remove-photo{z-index:2}.photo-upload-item .overlay{background:#0009;flex-direction:column;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.upload-status-text{color:#fff;text-shadow:0 1px 3px #000c;text-align:center;margin-top:1rem;padding:0 1rem;font-size:.9rem}.photo-upload-item .error-overlay{cursor:pointer;background:#e06c75cc;border:none;width:100%;margin:0;padding:0}.photo-upload-item .btn-remove-photo{cursor:pointer;color:#fff;background:#000000b3;border:none;border-radius:50%;justify-content:center;align-items:center;width:24px;height:24px;padding:0;display:flex;position:absolute;top:4px;right:4px}.photo-upload-item .btn-remove-photo:hover{background:var(--danger-color)}.spin-animation{animation:1s linear infinite spin}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.btn-publish{width:100%}.user-menu-container{position:relative}.user-menu-popover{z-index:3001;background:#fff;border-radius:8px;width:280px;margin-top:10px;padding:1rem;position:absolute;top:100%;right:0;box-shadow:0 4px 12px #00000026}.menu-backdrop{z-index:3000;position:fixed;inset:0}.account-list{margin:0;padding:0;list-style:none}.account-item{border-bottom:1px solid var(--divider-color);flex-direction:column;padding:1rem 0;display:flex}.account-item:last-child{border-bottom:none;padding-bottom:0}.account-item:first-child{padding-top:0}.account-header{justify-content:space-between;align-items:center;display:flex}.account-status{color:#898989;white-space:nowrap;text-overflow:ellipsis;margin-top:.35rem;margin-left:calc(18px + .75rem);font-size:.85rem;overflow:hidden}.account-status strong{font-weight:600}.aLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
var t=Object.create,e=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,o=(t,e)=>()=>(e||(t((e={exports:{}}).exports,e),t=null),e.exports),a=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:"Module"}),r},l=(t,i,o,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(var l,c=r(i),u=0,h=c.length;u<h;u++)l=c[u],s.call(t,l)||l===o||e(t,l,{get:(t=>i[t]).bind(null,l),enumerable:!(a=n(i,l))||a.enumerable});return t},c=(n,r,o)=>(o=null!=n?t(i(n)):{},l(!r&&n&&n.__esModule&&s.call(n,"default")?o:e(o,"default",{value:n,enumerable:!0}),n)),u=(t=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(t,{get:(t,e)=>("undefined"!=typeof require?require:t)[e]}):t)(function(t){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Calling `require` for "'+t+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});!function(){const t=document.createElement("link").relList;if(!(t&&t.supports&&t.supports("modulepreload"))){for(const t of document.querySelectorAll('link[rel="modulepreload"]'))e(t);new MutationObserver(t=>{for(const n of t)if("childList"===n.type)for(const t of n.addedNodes)"LINK"===t.tagName&&"modulepreload"===t.rel&&e(t)}).observe(document,{childList:!0,subtree:!0})}function e(t){if(t.ep)return;t.ep=!0;const e=function(t){const e={};return t.integrity&&(e.integrity=t.integrity),t.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),"use-credentials"===t.crossOrigin?e.credentials="include":"anonymous"===t.crossOrigin?e.credentials="omit":e.credentials="same-origin",e}(t);fetch(t.href,e)}}();var h,d=Object.prototype,p=Symbol("undefined"),f=function(t){return t[t.ADD=0]="ADD",t[t.ONCE=1]="ONCE",t[t.REMOVE=2]="REMOVE",t}(f||{}),g=1,m=class{_descriptors;_mixins;_isInit;_lazyChains;_values;_revisions;source;proto;_parent;_listeners;_listenersVersion=1;_inheritedEnd=-1;_flattenedVersion=0;constructor(t){this._parent=void 0,this._descriptors=void 0,this._mixins=void 0,this._lazyChains=void 0,this._values=void 0,this._revisions=void 0,this._isInit=!1,this.source=t,this.proto=void 0===t.constructor?void 0:t.constructor.prototype,this._listeners=void 0}get parent(){let t=this._parent;if(void 0===t){let e=y(this.source);this._parent=t=null===e||e===d?null:_(e)}return t}setInitializing(){this._isInit=!0}unsetInitializing(){this._isInit=!1}isInitializing(){return this._isInit}isPrototypeMeta(t){return this.proto===this.source&&this.source===t}_getOrCreateOwnMap(t){return this[t]||(this[t]=Object.create(null))}_getOrCreateOwnSet(t){return this[t]||(this[t]=new Set)}_findInheritedMap(t,e){let n=this;for(;null!==n;){let r=n[t];if(void 0!==r){let t=r.get(e);if(void 0!==t)return t}n=n.parent}}_hasInInheritedSet(t,e){let n=this;for(;null!==n;){let r=n[t];if(void 0!==r&&r.has(e))return!0;n=n.parent}return!1}valueFor(t){let e=this._values;return void 0!==e?e[t]:void 0}setValueFor(t,e){this._getOrCreateOwnMap("_values")[t]=e}revisionFor(t){let e=this._revisions;return void 0!==e?e[t]:void 0}setRevisionFor(t,e){this._getOrCreateOwnMap("_revisions")[t]=e}writableLazyChainsFor(t){let e=this._getOrCreateOwnMap("_lazyChains"),n=e[t];return void 0===n&&(n=e[t]=[]),n}readableLazyChainsFor(t){let e=this._lazyChains;if(void 0!==e)return e[t]}addMixin(t){this._getOrCreateOwnSet("_mixins").add(t)}hasMixin(t){return this._hasInInheritedSet("_mixins",t)}forEachMixins(t){let e,n=this;for(;null!==n;){let r=n._mixins;void 0!==r&&(e=void 0===e?new Set:e,r.forEach(n=>{e.has(n)||(e.add(n),t(n))})),n=n.parent}}writeDescriptors(t,e){(this._descriptors||(this._descriptors=new Map)).set(t,e)}peekDescriptors(t){let e=this._findInheritedMap("_descriptors",t);return e===p?void 0:e}removeDescriptors(t){this.writeDescriptors(t,p)}forEachDescriptors(t){let e,n=this;for(;null!==n;){let r=n._descriptors;void 0!==r&&(e=void 0===e?new Set:e,r.forEach((n,r)=>{e.has(r)||(e.add(r),n!==p&&t(r,n))})),n=n.parent}}addToListeners(t,e,n,r,i){this.pushListener(t,e,n,r?f.ONCE:f.ADD,i)}removeFromListeners(t,e,n){this.pushListener(t,e,n,f.REMOVE)}pushListener(t,e,n,r,i=!1){let s=this.writableListeners(),o=x(s,t,e,n);if(-1!==o&&o<this._inheritedEnd&&(s.splice(o,1),this._inheritedEnd--,o=-1),-1===o)s.push({event:t,target:e,method:n,kind:r,sync:i});else{let t=s[o];r===f.REMOVE&&t.kind!==f.REMOVE?s.splice(o,1):(t.kind=r,t.sync=i)}}writableListeners(){return this._flattenedVersion!==g||this.source!==this.proto&&-1!==this._inheritedEnd||g++,-1===this._inheritedEnd&&(this._inheritedEnd=0,this._listeners=[]),this._listeners}flattenedListeners(){if(this._flattenedVersion<g){let t=this.parent;if(null!==t){let e=t.flattenedListeners();if(void 0!==e)if(void 0===this._listeners)this._listeners=e;else{let t=this._listeners;this._inheritedEnd>0&&(t.splice(0,this._inheritedEnd),this._inheritedEnd=0);for(Line truncated
|
||||
@@ -1 +1 @@
|
||||
import{$ as e,$n as t,$t as a,A as n,An as s,Ar as r,At as i,B as o,Bn as l,Br as g,Bt as d,C as h,Cn as c,Cr as u,Ct as p,D as _,Dn as m,Dr as y,Dt as C,E as b,En as f,Er as A,Et as M,F as I,Fn as D,Fr as T,Ft as v,G as O,Gn as E,Gr as S,Gt as R,H as j,Hn as x,Hr as w,Ht as P,I as N,In as V,Ir as F,It as G,J as L,Jn as k,Jr as U,Jt as Y,K as B,Kn as H,Kr as $,Kt as z,L as W,Ln as q,Lr as Z,Lt as J,M as K,Mn as X,Mr as Q,Mt as ee,N as te,Nn as ae,Nr as ne,Nt as se,O as re,On as ie,Or as oe,Ot as le,P as ge,Pn as de,Pr as he,Pt as ce,Q as ue,Qn as pe,Qt as _e,R as me,Rn as ye,Rr as Ce,Rt as be,S as fe,Sn as Ae,Sr as Me,St as Ie,T as De,Tn as Te,Tr as ve,Tt as Oe,U as Ee,Un as Se,Ur as Re,Ut as je,V as xe,Vn as we,Vr as Pe,Vt as Ne,W as Ve,Wn as Fe,Wr as Ge,Wt as Le,X as ke,Xn as Ue,Xr as Ye,Xt as Be,Y as He,Yn as $e,Yr as ze,Yt as We,Z as qe,Zn as Ze,Zr as Je,Zt as Ke,_ as Xe,_n as Qe,_r as et,_t as tt,a as at,an as nt,ar as st,at as rt,b as it,bn as ot,br as lt,bt as gt,c as dt,cn as ht,cr as ct,ct as ut,d as pt,dn as _t,dr as mt,dt as yt,en as Ct,er as bt,et as ft,f as At,fn as Mt,fr as It,ft as Dt,g as Tt,gn as vt,gr as Ot,gt as Et,h as St,hn as Rt,hr as jt,ht as xt,i as wt,in as Pt,ir as Nt,it as Vt,j as Ft,jn as Gt,jr as Lt,jt as kt,k as Ut,kn as Yt,kr as Bt,kt as Ht,l as $t,ln as zt,lr as Wt,lt as qt,m as Zt,mn as Jt,mr as Kt,mt as Xt,n as Qt,nn as ea,nr as ta,nt as aa,o as na,on as sa,or as ra,ot as ia,p as oa,pn as la,pr as ga,pt as da,q as ha,qn as ca,qr as ua,qt as pa,r as _a,rn as ma,rr as ya,rt as Ca,s as ba,sn as fa,sr as Aa,st as Ma,t as Ia,tn as Da,tr as Ta,tt as va,u as Oa,un as Ea,ur as Sa,ut as Ra,v as ja,vn as xa,vr as wa,vt as Pa,w as Na,wn as Va,wr as Fa,wt as Ga,x as La,xn as ka,xr as Ua,xt as Ya,y as Ba,yn as Ha,yr as $a,yt as za,z as Wa,zn as qa,zr as Za,zt as Ja}from"./main-bPhej5rb.js";var Ka=Je({default:()=>Jt}),Xa=Je({default:()=>tn}),Qa={willChange:"_arrangedContentArrayWillChange",didChange:"_arrangedContentArrayDidChange"};function en(e,t){return"[]"===t?(e._revalidate(),e._arrTag):"length"===t?(e._revalidate(),e._lengthTag):F(e,t)}var tn=class extends V{_objectsDirtyIndex=0;_objects=null;_lengthDirty=!0;_length=0;_arrangedContent=null;_arrangedContentIsUpdating=!1;_arrangedContentTag=null;_arrangedContentRevision=null;_lengthTag=null;_arrTag=null;init(e){super.init(e),y(this,en)}[Ot](){this._revalidate()}willDestroy(){this._removeArrangedContentArrayObserver()}objectAtContent(e){let t=It(this,"arrangedContent");return Fa(t,e)}replace(e,t,a){this.replaceContent(e,t,a)}replaceContent(e,t,a){let n=It(this,"content");Wt(n,e,t,a)}objectAt(e){if(this._revalidate(),null===this._objects&&(this._objects=[]),-1!==this._objectsDirtyIndex&&e>=this._objectsDirtyIndex){let e=It(this,"arrangedContent");if(e){let t=this._objects.length=It(e,"length");for(let e=this._objectsDirtyIndex;e<t;e++)this._objects[e]=this.objectAtContent(e)}else this._objects.length=0;this._objectsDirtyIndex=-1}return this._objects[e]}get length(){if(this._revalidate(),this._lengthDirty){let e=It(this,"arrangedContent");this._length=e?It(e,"length"):0,this._lengthDirty=!1}return Ce(this._lengthTag),this._length}set length(e){let t,a=this.length-e;if(0===a)return;a<0&&(t=new Array(-a),a=0);let n=It(this,"content");n&&(Wt(n,e,a,t),this._invalidate())}_updateArrangedContentArray(e){let t=null===this._objects?0:this._objects.length,a=e?It(e,"length"):0;this._removeArrangedContentArrayObserver(),Aa(this,0,t,a),this._invalidate(),ra(this,0,t,a,!1),this._addArrangedContentArrayObserver(e)}_addArrangedContentArrayObserver(e){e&&!e.isDestroyed&&(st(e,this,Qa),this._arrangedContent=e)}_removeArrangedContentArrayObserver(){this._arrangedContent&&ct(this._arrangedContent,this,Qa)}_arrangedContentArrayWillChange(){}_arrangedContentArrayDidChange(e,t,a,n){Aa(this,t,a,n);let s=t;s<0&&(s+=It(this._arrangedContent,"length")+a-n),(-1===this._objectsDirtyIndex||this._objectsDirtyIndex>s)&&(this._objectsDirtyIndex=s),this._lengthDirty=!0,ra(this,t,a,n,!1)}_invalidate(){this._objectsDirtyIndex=0,this._lengthDirty=!0}_revalidate(){if(!0!==this._arrangedContentIsUpdating&&(null===this._arrangedContentTag||!Za(this._arrangedContentTag,this._arrangedContentRevision))){let e=this.get("arrangedContent");null===this._arrangedContentTag?this._addArrangedContentArrayObserver(e):(this._arrangedContentIsUpdating=!0,this._updateArrangedContentArray(e),this._arrangedContentIsUpdating=!1);let t=this._arrangedContentTag=F(this,"arrangedContent");this._arrangedContentRevision=g(this._arrangedContentTag),T(e)?(this._lengthTag=Z([t,ve(e,"length")]),this._arrTag=Z([t,ve(e,"[]")])):this._lengthTag=this._arrTag=t}}};tn.reopen(Jt,{arrangedContent:Sa("content")});var an=Je({Meta:()=>S,UNDEFINED:()=>$,counters:()=>ua,meta:()=>U,peekMeta:()=>ze,setMeta:()=>Ye}),nn=Je({ActionHandler:()=>l,Comparable:()=>vt,ContainerProxyMixin:()=>_t,MutableEnumerable:()=>Qe,RSVP:()=>k,RegistryProxyMixin:()=>Ea,TargetActionSupport:()=>ja,_ProxyMixin:()=>O,_contentFor:()=>B,onerrorLine truncated
|
||||
import{$ as e,$n as t,$t as a,A as n,An as s,Ar as r,At as i,B as o,Bn as l,Br as g,Bt as d,C as h,Cn as c,Cr as u,Ct as p,D as _,Dn as m,Dr as y,Dt as C,E as b,En as f,Er as A,Et as M,F as I,Fn as D,Fr as T,Ft as v,G as O,Gn as E,Gr as S,Gt as R,H as j,Hn as x,Hr as w,Ht as P,I as N,In as V,Ir as F,It as G,J as L,Jn as k,Jr as U,Jt as Y,K as B,Kn as H,Kr as $,Kt as z,L as W,Ln as q,Lr as Z,Lt as J,M as K,Mn as X,Mr as Q,Mt as ee,N as te,Nn as ae,Nr as ne,Nt as se,O as re,On as ie,Or as oe,Ot as le,P as ge,Pn as de,Pr as he,Pt as ce,Q as ue,Qn as pe,Qt as _e,R as me,Rn as ye,Rr as Ce,Rt as be,S as fe,Sn as Ae,Sr as Me,St as Ie,T as De,Tn as Te,Tr as ve,Tt as Oe,U as Ee,Un as Se,Ur as Re,Ut as je,V as xe,Vn as we,Vr as Pe,Vt as Ne,W as Ve,Wn as Fe,Wr as Ge,Wt as Le,X as ke,Xn as Ue,Xr as Ye,Xt as Be,Y as He,Yn as $e,Yr as ze,Yt as We,Z as qe,Zn as Ze,Zr as Je,Zt as Ke,_ as Xe,_n as Qe,_r as et,_t as tt,a as at,an as nt,ar as st,at as rt,b as it,bn as ot,br as lt,bt as gt,c as dt,cn as ht,cr as ct,ct as ut,d as pt,dn as _t,dr as mt,dt as yt,en as Ct,er as bt,et as ft,f as At,fn as Mt,fr as It,ft as Dt,g as Tt,gn as vt,gr as Ot,gt as Et,h as St,hn as Rt,hr as jt,ht as xt,i as wt,in as Pt,ir as Nt,it as Vt,j as Ft,jn as Gt,jr as Lt,jt as kt,k as Ut,kn as Yt,kr as Bt,kt as Ht,l as $t,ln as zt,lr as Wt,lt as qt,m as Zt,mn as Jt,mr as Kt,mt as Xt,n as Qt,nn as ea,nr as ta,nt as aa,o as na,on as sa,or as ra,ot as ia,p as oa,pn as la,pr as ga,pt as da,q as ha,qn as ca,qr as ua,qt as pa,r as _a,rn as ma,rr as ya,rt as Ca,s as ba,sn as fa,sr as Aa,st as Ma,t as Ia,tn as Da,tr as Ta,tt as va,u as Oa,un as Ea,ur as Sa,ut as Ra,v as ja,vn as xa,vr as wa,vt as Pa,w as Na,wn as Va,wr as Fa,wt as Ga,x as La,xn as ka,xr as Ua,xt as Ya,y as Ba,yn as Ha,yr as $a,yt as za,z as Wa,zn as qa,zr as Za,zt as Ja}from"./main-DHeKkWql.js";var Ka=Je({default:()=>Jt}),Xa=Je({default:()=>tn}),Qa={willChange:"_arrangedContentArrayWillChange",didChange:"_arrangedContentArrayDidChange"};function en(e,t){return"[]"===t?(e._revalidate(),e._arrTag):"length"===t?(e._revalidate(),e._lengthTag):F(e,t)}var tn=class extends V{_objectsDirtyIndex=0;_objects=null;_lengthDirty=!0;_length=0;_arrangedContent=null;_arrangedContentIsUpdating=!1;_arrangedContentTag=null;_arrangedContentRevision=null;_lengthTag=null;_arrTag=null;init(e){super.init(e),y(this,en)}[Ot](){this._revalidate()}willDestroy(){this._removeArrangedContentArrayObserver()}objectAtContent(e){let t=It(this,"arrangedContent");return Fa(t,e)}replace(e,t,a){this.replaceContent(e,t,a)}replaceContent(e,t,a){let n=It(this,"content");Wt(n,e,t,a)}objectAt(e){if(this._revalidate(),null===this._objects&&(this._objects=[]),-1!==this._objectsDirtyIndex&&e>=this._objectsDirtyIndex){let e=It(this,"arrangedContent");if(e){let t=this._objects.length=It(e,"length");for(let e=this._objectsDirtyIndex;e<t;e++)this._objects[e]=this.objectAtContent(e)}else this._objects.length=0;this._objectsDirtyIndex=-1}return this._objects[e]}get length(){if(this._revalidate(),this._lengthDirty){let e=It(this,"arrangedContent");this._length=e?It(e,"length"):0,this._lengthDirty=!1}return Ce(this._lengthTag),this._length}set length(e){let t,a=this.length-e;if(0===a)return;a<0&&(t=new Array(-a),a=0);let n=It(this,"content");n&&(Wt(n,e,a,t),this._invalidate())}_updateArrangedContentArray(e){let t=null===this._objects?0:this._objects.length,a=e?It(e,"length"):0;this._removeArrangedContentArrayObserver(),Aa(this,0,t,a),this._invalidate(),ra(this,0,t,a,!1),this._addArrangedContentArrayObserver(e)}_addArrangedContentArrayObserver(e){e&&!e.isDestroyed&&(st(e,this,Qa),this._arrangedContent=e)}_removeArrangedContentArrayObserver(){this._arrangedContent&&ct(this._arrangedContent,this,Qa)}_arrangedContentArrayWillChange(){}_arrangedContentArrayDidChange(e,t,a,n){Aa(this,t,a,n);let s=t;s<0&&(s+=It(this._arrangedContent,"length")+a-n),(-1===this._objectsDirtyIndex||this._objectsDirtyIndex>s)&&(this._objectsDirtyIndex=s),this._lengthDirty=!0,ra(this,t,a,n,!1)}_invalidate(){this._objectsDirtyIndex=0,this._lengthDirty=!0}_revalidate(){if(!0!==this._arrangedContentIsUpdating&&(null===this._arrangedContentTag||!Za(this._arrangedContentTag,this._arrangedContentRevision))){let e=this.get("arrangedContent");null===this._arrangedContentTag?this._addArrangedContentArrayObserver(e):(this._arrangedContentIsUpdating=!0,this._updateArrangedContentArray(e),this._arrangedContentIsUpdating=!1);let t=this._arrangedContentTag=F(this,"arrangedContent");this._arrangedContentRevision=g(this._arrangedContentTag),T(e)?(this._lengthTag=Z([t,ve(e,"length")]),this._arrTag=Z([t,ve(e,"[]")])):this._lengthTag=this._arrTag=t}}};tn.reopen(Jt,{arrangedContent:Sa("content")});var an=Je({Meta:()=>S,UNDEFINED:()=>$,counters:()=>ua,meta:()=>U,peekMeta:()=>ze,setMeta:()=>Ye}),nn=Je({ActionHandler:()=>l,Comparable:()=>vt,ContainerProxyMixin:()=>_t,MutableEnumerable:()=>Qe,RSVP:()=>k,RegistryProxyMixin:()=>Ea,TargetActionSupport:()=>ja,_ProxyMixin:()=>O,_contentFor:()=>B,onerrorLine truncated
|
||||
+2
-2
@@ -42,8 +42,8 @@
|
||||
<meta name="msapplication-TileColor" content="#F6E9A6">
|
||||
<meta name="msapplication-TileImage" content="/icons/icon-144.png">
|
||||
|
||||
<script type="module" crossorigin src="/assets/main-bPhej5rb.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/main-D1hwoGyg.css">
|
||||
<script type="module" crossorigin src="/assets/main-DHeKkWql.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/main-DdJzN7M8.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="modal-portal"></div>
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,602 @@
|
||||
import { module, test } from 'qunit';
|
||||
import {
|
||||
visit,
|
||||
click,
|
||||
currentURL,
|
||||
triggerEvent,
|
||||
waitFor,
|
||||
waitUntil,
|
||||
} from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'marco/tests/helpers';
|
||||
import { computeDetentLayout } from 'marco/utils/sheet-detents';
|
||||
import Service from '@ember/service';
|
||||
import sinon from 'sinon';
|
||||
|
||||
class MockOsmService extends Service {
|
||||
async getNearbyPois() {
|
||||
return [
|
||||
{
|
||||
osmId: '123',
|
||||
lat: 1,
|
||||
lon: 1,
|
||||
osmTags: { name: 'Test Place', amenity: 'cafe' },
|
||||
osmType: 'node',
|
||||
},
|
||||
];
|
||||
}
|
||||
async getPoiById() {
|
||||
return null;
|
||||
}
|
||||
async fetchOsmObject(id, type) {
|
||||
return {
|
||||
osmId: id,
|
||||
osmType: type,
|
||||
lat: 1,
|
||||
lon: 1,
|
||||
osmTags: { name: 'Test Place' },
|
||||
title: 'Test Place',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class MockStorageService extends Service {
|
||||
initialSyncDone = true;
|
||||
savedPlaces = [];
|
||||
findPlaceById() {
|
||||
return null;
|
||||
}
|
||||
isPlaceSaved() {
|
||||
return false;
|
||||
}
|
||||
loadPlacesInBounds() {
|
||||
return [];
|
||||
}
|
||||
get placesInView() {
|
||||
return [];
|
||||
}
|
||||
rs = {
|
||||
on: () => {},
|
||||
};
|
||||
}
|
||||
|
||||
const MOBILE_QUERY = '(max-width: 768px)';
|
||||
|
||||
// @ember/test-helpers 5.4 has no setViewport helper, so simulate the mobile
|
||||
// media query directly. The bottom-sheet modifier reads window.matchMedia at
|
||||
// setup, so this must be installed before the route is visited.
|
||||
function installMobileMatchMedia() {
|
||||
return sinon.stub(window, 'matchMedia').callsFake((query) => ({
|
||||
matches: typeof query === 'string' && query.includes(MOBILE_QUERY),
|
||||
media: query,
|
||||
onchange: null,
|
||||
addEventListener() {},
|
||||
removeEventListener() {},
|
||||
addListener() {},
|
||||
removeListener() {},
|
||||
dispatchEvent() {
|
||||
return false;
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
module('Acceptance | bottom sheet', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.owner.register('service:osm', MockOsmService);
|
||||
this.owner.register('service:storage', MockStorageService);
|
||||
});
|
||||
|
||||
test('does not inject the drag handle at desktop width', async function (assert) {
|
||||
await visit('/menu');
|
||||
|
||||
assert.dom('.sidebar').exists('sheet is rendered');
|
||||
assert
|
||||
.dom('[data-test-sheet-handle]')
|
||||
.doesNotExist('no drag handle on desktop');
|
||||
});
|
||||
|
||||
test('injects a handle and a pixel offset on mobile', async function (assert) {
|
||||
const matchMediaStub = installMobileMatchMedia();
|
||||
try {
|
||||
const mapUi = this.owner.lookup('service:map-ui');
|
||||
await visit('/menu');
|
||||
await waitUntil(() => mapUi.sheetDetent !== null);
|
||||
|
||||
assert.dom('[data-test-sheet-handle]').exists('drag handle is injected');
|
||||
|
||||
const sheet = document.querySelector('.sidebar');
|
||||
const offset = sheet.style.getPropertyValue('--sheet-offset');
|
||||
assert.true(
|
||||
/px$/.test(offset),
|
||||
`--sheet-offset is a pixel value (${offset})`
|
||||
);
|
||||
assert.strictEqual(
|
||||
mapUi.sheetDetent,
|
||||
'medium',
|
||||
'the app menu opens at the medium detent'
|
||||
);
|
||||
} finally {
|
||||
matchMediaStub.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('dragging the handle moves the sheet to another detent', async function (assert) {
|
||||
const matchMediaStub = installMobileMatchMedia();
|
||||
try {
|
||||
const mapUi = this.owner.lookup('service:map-ui');
|
||||
await visit('/menu');
|
||||
await waitUntil(() => mapUi.sheetDetent !== null);
|
||||
|
||||
const sheet = document.querySelector('.sidebar');
|
||||
const handle = sheet.querySelector('[data-test-sheet-handle]');
|
||||
const before = parseFloat(sheet.style.getPropertyValue('--sheet-offset'));
|
||||
|
||||
// Drag downward well past the threshold. Pointer events bubble to the
|
||||
// window-level listeners the modifier installs on pointerdown. The first
|
||||
// small move crosses the drag threshold (which rebases the gesture on the
|
||||
// live offset); the second move performs the actual drag.
|
||||
await triggerEvent(handle, 'pointerdown', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 100,
|
||||
button: 0,
|
||||
});
|
||||
await triggerEvent(handle, 'pointermove', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 110,
|
||||
});
|
||||
await triggerEvent(handle, 'pointermove', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 370,
|
||||
});
|
||||
await triggerEvent(handle, 'pointerup', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 370,
|
||||
});
|
||||
|
||||
const after = parseFloat(sheet.style.getPropertyValue('--sheet-offset'));
|
||||
assert.true(after > before, `sheet moved down (${before} -> ${after})`);
|
||||
assert.notStrictEqual(
|
||||
mapUi.sheetDetent,
|
||||
'medium',
|
||||
'sheet left its opening detent'
|
||||
);
|
||||
// The inset is published on a deferred animation-frame flush.
|
||||
await waitUntil(() => mapUi.sheetInsetPx > 0);
|
||||
assert.true(mapUi.sheetInsetPx > 0, 'map inset is reported');
|
||||
} finally {
|
||||
matchMediaStub.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('dragging the content resizes the sheet below the largest detent', async function (assert) {
|
||||
const matchMediaStub = installMobileMatchMedia();
|
||||
try {
|
||||
const mapUi = this.owner.lookup('service:map-ui');
|
||||
await visit('/menu');
|
||||
await waitUntil(() => mapUi.sheetDetent === 'medium');
|
||||
|
||||
const sheet = document.querySelector('.sheet-top');
|
||||
assert
|
||||
.dom('.sheet-top')
|
||||
.doesNotHaveClass('sheet-at-max', 'not at the largest detent');
|
||||
const content = sheet.querySelector('.sidebar-content');
|
||||
const before = parseFloat(sheet.style.getPropertyValue('--sheet-offset'));
|
||||
|
||||
// Drag the content itself (not the handle) downward.
|
||||
await triggerEvent(content, 'pointerdown', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 100,
|
||||
button: 0,
|
||||
});
|
||||
await triggerEvent(content, 'pointermove', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 110,
|
||||
});
|
||||
await triggerEvent(content, 'pointermove', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 300,
|
||||
});
|
||||
await triggerEvent(content, 'pointerup', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 300,
|
||||
});
|
||||
|
||||
const after = parseFloat(sheet.style.getPropertyValue('--sheet-offset'));
|
||||
assert.true(after > before, `sheet moved down (${before} -> ${after})`);
|
||||
assert.notStrictEqual(
|
||||
mapUi.sheetDetent,
|
||||
'medium',
|
||||
'sheet left its opening detent'
|
||||
);
|
||||
} finally {
|
||||
matchMediaStub.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('dragging a list row resizes the sheet (mobile)', async function (assert) {
|
||||
const matchMediaStub = installMobileMatchMedia();
|
||||
try {
|
||||
const mapUi = this.owner.lookup('service:map-ui');
|
||||
await visit('/search?lat=1&lon=1');
|
||||
await waitUntil(() => mapUi.sheetDetent === 'medium');
|
||||
|
||||
const sheet = document.querySelector('.sheet-top');
|
||||
const row = sheet.querySelector('.place-item');
|
||||
const before = parseFloat(sheet.style.getPropertyValue('--sheet-offset'));
|
||||
|
||||
// A list row is a <button>; it must still start a sheet drag.
|
||||
await triggerEvent(row, 'pointerdown', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 100,
|
||||
button: 0,
|
||||
});
|
||||
await triggerEvent(row, 'pointermove', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 110,
|
||||
});
|
||||
await triggerEvent(row, 'pointermove', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 300,
|
||||
});
|
||||
await triggerEvent(row, 'pointerup', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 300,
|
||||
});
|
||||
|
||||
const after = parseFloat(sheet.style.getPropertyValue('--sheet-offset'));
|
||||
assert.true(after > before, `sheet moved down (${before} -> ${after})`);
|
||||
assert.notStrictEqual(
|
||||
mapUi.sheetDetent,
|
||||
'medium',
|
||||
'sheet left its opening detent'
|
||||
);
|
||||
} finally {
|
||||
matchMediaStub.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('pulling the content down at the largest detent shrinks the sheet', async function (assert) {
|
||||
const matchMediaStub = installMobileMatchMedia();
|
||||
try {
|
||||
const mapUi = this.owner.lookup('service:map-ui');
|
||||
// Open the menu at its largest detent.
|
||||
mapUi.setSheetDetent('menu', 'expanded');
|
||||
await visit('/menu');
|
||||
await waitUntil(() => mapUi.sheetDetent === 'expanded');
|
||||
|
||||
const sheet = document.querySelector('.sheet-top');
|
||||
assert
|
||||
.dom('.sheet-top')
|
||||
.hasClass('sheet-at-max', 'marked as at the largest detent');
|
||||
|
||||
const content = sheet.querySelector('.sidebar-content');
|
||||
assert.strictEqual(
|
||||
content.scrollTop,
|
||||
0,
|
||||
'content is scrolled to the top'
|
||||
);
|
||||
const before = parseFloat(sheet.style.getPropertyValue('--sheet-offset'));
|
||||
|
||||
// Pull the content down: overscroll shrinks the sheet instead of scrolling.
|
||||
await triggerEvent(content, 'pointerdown', {
|
||||
pointerId: 2,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 100,
|
||||
button: 0,
|
||||
});
|
||||
await triggerEvent(content, 'pointermove', {
|
||||
pointerId: 2,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 110,
|
||||
});
|
||||
await triggerEvent(content, 'pointermove', {
|
||||
pointerId: 2,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 400,
|
||||
});
|
||||
await triggerEvent(content, 'pointerup', {
|
||||
pointerId: 2,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 400,
|
||||
});
|
||||
|
||||
const after = parseFloat(sheet.style.getPropertyValue('--sheet-offset'));
|
||||
assert.true(after > before, `sheet shrank (${before} -> ${after})`);
|
||||
assert.notStrictEqual(
|
||||
mapUi.sheetDetent,
|
||||
'expanded',
|
||||
'sheet left the largest detent'
|
||||
);
|
||||
} finally {
|
||||
matchMediaStub.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('opening a place from search results does not crash (mobile)', async function (assert) {
|
||||
const matchMediaStub = installMobileMatchMedia();
|
||||
try {
|
||||
const mapUi = this.owner.lookup('service:map-ui');
|
||||
|
||||
await visit('/search?lat=1&lon=1');
|
||||
assert.dom('.place-item').exists('search results are rendered');
|
||||
|
||||
// This is the search→place transition that used to throw the
|
||||
// backtracking assertion (Map re-renders in the same pass that installs
|
||||
// the new sheet's modifier). click() already settles.
|
||||
await click('.place-item');
|
||||
|
||||
assert.dom('.sheet-top').exists('the place sheet is rendered');
|
||||
assert.ok(currentURL().includes('/place/'), 'navigated to the place');
|
||||
|
||||
await waitUntil(() => mapUi.sheetInsetPx > 0);
|
||||
assert.true(
|
||||
mapUi.sheetInsetPx > 0,
|
||||
'the map inset reflects the open sheet'
|
||||
);
|
||||
} finally {
|
||||
matchMediaStub.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('opening a place keeps the search sheet stacked behind it (mobile)', async function (assert) {
|
||||
const matchMediaStub = installMobileMatchMedia();
|
||||
try {
|
||||
const mapUi = this.owner.lookup('service:map-ui');
|
||||
await visit('/search?lat=1&lon=1');
|
||||
assert.dom('.place-item').exists('search results are rendered');
|
||||
|
||||
await click('.place-item');
|
||||
await waitUntil(() => mapUi.sheetDetent === 'medium');
|
||||
|
||||
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');
|
||||
|
||||
// Place details opens at medium, and the background is pinned to the
|
||||
// minimum so it can never peek above the top sheet. Read the sheet height
|
||||
// the modifier wrote rather than recomputing the geometry.
|
||||
const top = document.querySelector('.sheet-top');
|
||||
const background = document.querySelector('.sheet-background');
|
||||
const sheetHeight = parseFloat(
|
||||
top.style.getPropertyValue('--sheet-height')
|
||||
);
|
||||
const layout = computeDetentLayout({
|
||||
viewportHeight: window.innerHeight,
|
||||
sheetHeight,
|
||||
});
|
||||
const mediumOffset = layout.find((d) => d.name === 'medium')?.offset;
|
||||
const minimumOffset = layout[layout.length - 1].offset;
|
||||
await waitUntil(
|
||||
() =>
|
||||
parseFloat(top.style.getPropertyValue('--sheet-offset')) ===
|
||||
mediumOffset
|
||||
);
|
||||
assert.strictEqual(
|
||||
parseFloat(top.style.getPropertyValue('--sheet-offset')),
|
||||
mediumOffset,
|
||||
'place details opens at the medium detent'
|
||||
);
|
||||
assert.strictEqual(
|
||||
parseFloat(background.style.getPropertyValue('--sheet-offset')),
|
||||
minimumOffset,
|
||||
'the background sheet is minimized'
|
||||
);
|
||||
} finally {
|
||||
matchMediaStub.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('background sheets stay minimized when the top sheet is taller (mobile)', async function (assert) {
|
||||
const matchMediaStub = installMobileMatchMedia();
|
||||
try {
|
||||
const mapUi = this.owner.lookup('service:map-ui');
|
||||
await visit('/search?lat=1&lon=1');
|
||||
await click('.place-item');
|
||||
await waitUntil(() => mapUi.sheetDetent === 'medium');
|
||||
|
||||
const top = document.querySelector('.sheet-top');
|
||||
const handle = top.querySelector('[data-test-sheet-handle]');
|
||||
const background = document.querySelector('.sheet-background');
|
||||
const backgroundBefore = parseFloat(
|
||||
background.style.getPropertyValue('--sheet-offset')
|
||||
);
|
||||
const topBefore = parseFloat(
|
||||
top.style.getPropertyValue('--sheet-offset')
|
||||
);
|
||||
|
||||
// Drag the top sheet all the way up.
|
||||
await triggerEvent(handle, 'pointerdown', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 1000,
|
||||
button: 0,
|
||||
});
|
||||
await triggerEvent(handle, 'pointermove', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 990,
|
||||
});
|
||||
await triggerEvent(handle, 'pointermove', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 0,
|
||||
});
|
||||
await triggerEvent(handle, 'pointerup', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 0,
|
||||
});
|
||||
|
||||
await waitUntil(() => mapUi.sheetDetent !== 'medium');
|
||||
const topAfter = parseFloat(top.style.getPropertyValue('--sheet-offset'));
|
||||
const backgroundAfter = parseFloat(
|
||||
background.style.getPropertyValue('--sheet-offset')
|
||||
);
|
||||
assert.true(topAfter < topBefore, 'the top sheet expanded');
|
||||
assert.true(
|
||||
topAfter < backgroundAfter,
|
||||
'the top sheet is more visible than the background'
|
||||
);
|
||||
assert.strictEqual(
|
||||
backgroundAfter,
|
||||
backgroundBefore,
|
||||
'the background stayed minimized'
|
||||
);
|
||||
} 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');
|
||||
await waitUntil(() => mapUi.sheetDetent === 'medium');
|
||||
assert.strictEqual(
|
||||
mapUi.sheetDetent,
|
||||
'medium',
|
||||
'place details 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'
|
||||
);
|
||||
await waitUntil(() => mapUi.sheetDetent === 'medium');
|
||||
assert.strictEqual(
|
||||
mapUi.sheetDetent,
|
||||
'medium',
|
||||
'the search sheet returns to its remembered medium detent'
|
||||
);
|
||||
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 {
|
||||
const mapUi = this.owner.lookup('service:map-ui');
|
||||
await visit('/menu');
|
||||
await waitUntil(() => mapUi.sheetDetent !== null);
|
||||
|
||||
const sheet = document.querySelector('.sidebar');
|
||||
const handle = sheet.querySelector('[data-test-sheet-handle]');
|
||||
|
||||
await triggerEvent(handle, 'pointerdown', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 100,
|
||||
button: 0,
|
||||
});
|
||||
await triggerEvent(handle, 'pointermove', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 110,
|
||||
});
|
||||
await triggerEvent(handle, 'pointermove', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 1400,
|
||||
});
|
||||
await triggerEvent(handle, 'pointerup', {
|
||||
pointerId: 1,
|
||||
pointerType: 'touch',
|
||||
isPrimary: true,
|
||||
clientY: 1400,
|
||||
});
|
||||
|
||||
assert.strictEqual(
|
||||
mapUi.sheetDetent,
|
||||
null,
|
||||
'the remembered detent is cleared on dismiss'
|
||||
);
|
||||
|
||||
// dismiss() waits for the slide-out transition before calling onDismiss,
|
||||
// so settled() is not enough.
|
||||
await waitUntil(() => !document.querySelector('.sidebar'), {
|
||||
timeout: 3000,
|
||||
});
|
||||
assert.dom('.sidebar').doesNotExist('the sheet closed after dismissing');
|
||||
} finally {
|
||||
matchMediaStub.restore();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, click, currentURL, waitUntil } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'marco/tests/helpers';
|
||||
import Service from '@ember/service';
|
||||
import sinon from 'sinon';
|
||||
|
||||
class MockOsmService extends Service {
|
||||
async getNearbyPois() {
|
||||
return [
|
||||
{
|
||||
osmId: '123',
|
||||
lat: 1,
|
||||
lon: 1,
|
||||
osmTags: { name: 'Test Place', amenity: 'cafe' },
|
||||
osmType: 'node',
|
||||
},
|
||||
];
|
||||
}
|
||||
async getPoiById() {
|
||||
return null;
|
||||
}
|
||||
async fetchOsmObject(id, type) {
|
||||
return {
|
||||
osmId: id,
|
||||
osmType: type,
|
||||
lat: 1,
|
||||
lon: 1,
|
||||
osmTags: { name: 'Test Place' },
|
||||
title: 'Test Place',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class MockStorageService extends Service {
|
||||
initialSyncDone = true;
|
||||
savedPlaces = [];
|
||||
findPlaceById() {
|
||||
return null;
|
||||
}
|
||||
isPlaceSaved() {
|
||||
return false;
|
||||
}
|
||||
loadPlacesInBounds() {
|
||||
return [];
|
||||
}
|
||||
get placesInView() {
|
||||
return [];
|
||||
}
|
||||
rs = { on: () => {} };
|
||||
}
|
||||
|
||||
const MOBILE_QUERY = '(max-width: 768px)';
|
||||
|
||||
// @ember/test-helpers 5.4 has no setViewport helper, so simulate the mobile
|
||||
// media query directly. The viewport service reads window.matchMedia when it is
|
||||
// first instantiated (during the application render), so this must be installed
|
||||
// before the route is visited.
|
||||
function installMobileMatchMedia() {
|
||||
return sinon.stub(window, 'matchMedia').callsFake((query) => ({
|
||||
matches: typeof query === 'string' && query.includes(MOBILE_QUERY),
|
||||
media: query,
|
||||
onchange: null,
|
||||
addEventListener() {},
|
||||
removeEventListener() {},
|
||||
addListener() {},
|
||||
removeListener() {},
|
||||
dispatchEvent() {
|
||||
return false;
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
function makePhoto(id) {
|
||||
return {
|
||||
id,
|
||||
pubkey: 'a'.repeat(64),
|
||||
kind: 360,
|
||||
created_at: 1,
|
||||
tags: [
|
||||
['i', 'osm:node:123'],
|
||||
[
|
||||
'imeta',
|
||||
'url data:image/gif;base64,R0lGODlhAQABAAAAACw=',
|
||||
'dim 800x600',
|
||||
],
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
function clickSavedPlaces() {
|
||||
const button = Array.from(document.querySelectorAll('.app-menu button')).find(
|
||||
(b) => b.textContent.includes('Saved Places')
|
||||
);
|
||||
return click(button);
|
||||
}
|
||||
|
||||
module('Acceptance | drawer header', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.owner.register('service:osm', MockOsmService);
|
||||
this.owner.register('service:storage', MockStorageService);
|
||||
});
|
||||
|
||||
test('mobile top-level drawer drops the back button and the X closes it', async function (assert) {
|
||||
const matchMediaStub = installMobileMatchMedia();
|
||||
try {
|
||||
await visit('/menu');
|
||||
|
||||
assert.dom('.sheet-top .sidebar-header').exists('menu header is shown');
|
||||
assert
|
||||
.dom('.sheet-top .sidebar-header .back-btn')
|
||||
.doesNotExist('no back button on mobile');
|
||||
assert
|
||||
.dom('.sheet-top .sidebar-header-title')
|
||||
.includesText('Marco', 'title is shown');
|
||||
|
||||
await click('.sheet-top .sidebar-header .close-btn');
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
'/',
|
||||
'the X closed the top-level drawer'
|
||||
);
|
||||
} finally {
|
||||
matchMediaStub.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('mobile X on a child drawer goes back to its parent', async function (assert) {
|
||||
const matchMediaStub = installMobileMatchMedia();
|
||||
try {
|
||||
await visit('/menu');
|
||||
await clickSavedPlaces();
|
||||
assert.strictEqual(currentURL(), '/lists', 'on the lists index');
|
||||
|
||||
assert
|
||||
.dom('.sheet-top .sidebar-header .back-btn')
|
||||
.doesNotExist('no back button on mobile');
|
||||
assert
|
||||
.dom('.sheet-top .sidebar-header-title')
|
||||
.includesText('Saved Places', 'title is shown');
|
||||
|
||||
await click('.sheet-top .sidebar-header .close-btn');
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
'/menu',
|
||||
'the X went back to the parent (menu), not index'
|
||||
);
|
||||
} finally {
|
||||
matchMediaStub.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('mobile place details uses the place name as the header title', async function (assert) {
|
||||
const matchMediaStub = installMobileMatchMedia();
|
||||
try {
|
||||
this.owner.lookup('service:nostr-data').placePhotos = [makePhoto('p1')];
|
||||
|
||||
await visit('/search?lat=1&lon=1');
|
||||
await click('.place-item');
|
||||
await waitUntil(() =>
|
||||
document.querySelector('.sheet-top .sidebar-header-title')
|
||||
);
|
||||
|
||||
assert
|
||||
.dom('.sheet-top .sidebar-header-title')
|
||||
.includesText('Test Place', 'the place name is the header title');
|
||||
assert
|
||||
.dom('.sheet-top .sidebar-header-place')
|
||||
.exists('the header uses the compact place variant');
|
||||
assert
|
||||
.dom('.sheet-top .sidebar-content-place')
|
||||
.exists('the content uses the place spacing');
|
||||
assert
|
||||
.dom('.sheet-top .sidebar-header .back-btn')
|
||||
.doesNotExist('no back button on mobile');
|
||||
assert
|
||||
.dom('.sheet-top .sidebar-header.no-border')
|
||||
.exists('the place details header is borderless');
|
||||
assert
|
||||
.dom('.sheet-top .place-details h3')
|
||||
.doesNotExist('the name is not repeated in the body');
|
||||
|
||||
const type = document.querySelector(
|
||||
'.sheet-top .place-details .place-type'
|
||||
);
|
||||
const carousel = document.querySelector(
|
||||
'.sheet-top .place-details .photo-carousel'
|
||||
);
|
||||
assert.ok(type && carousel, 'the type and photo carousel are rendered');
|
||||
assert.true(
|
||||
Boolean(
|
||||
type.compareDocumentPosition(carousel) &
|
||||
Node.DOCUMENT_POSITION_FOLLOWING
|
||||
),
|
||||
'the photo carousel sits below the place type'
|
||||
);
|
||||
|
||||
await click('.sheet-top .sidebar-header .close-btn');
|
||||
await waitUntil(() => currentURL().includes('/search'));
|
||||
assert.ok(
|
||||
currentURL().includes('/search'),
|
||||
'the X popped back to the search sheet'
|
||||
);
|
||||
} finally {
|
||||
matchMediaStub.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('desktop keeps the back button and centered title', async function (assert) {
|
||||
await visit('/menu');
|
||||
await clickSavedPlaces();
|
||||
assert.strictEqual(currentURL(), '/lists', 'on the lists index');
|
||||
|
||||
assert
|
||||
.dom('.sheet-top .sidebar-header .back-btn')
|
||||
.exists('back button is present on desktop');
|
||||
assert
|
||||
.dom('.sheet-top .sidebar-header-text-centered')
|
||||
.includesText('Saved Places', 'title stays centered on desktop');
|
||||
});
|
||||
});
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'marco/tests/helpers';
|
||||
import { render, click } from '@ember/test-helpers';
|
||||
import { render, click, settled, waitUntil } from '@ember/test-helpers';
|
||||
import PhotoCarousel from 'marco/components/photo-carousel';
|
||||
|
||||
module('Integration | Component | photo-carousel', function (hooks) {
|
||||
@@ -154,4 +154,81 @@ module('Integration | Component | photo-carousel', function (hooks) {
|
||||
.dom('[data-event-id="event-3"]')
|
||||
.doesNotHaveClass('active', 'other photos stay inactive');
|
||||
});
|
||||
|
||||
test('it re-aligns to the focused photo when the list changes under it', async function (assert) {
|
||||
const originalOffsetLeft = Object.getOwnPropertyDescriptor(
|
||||
HTMLElement.prototype,
|
||||
'offsetLeft'
|
||||
);
|
||||
|
||||
// Simulate the carousel layout: each slide is one track-width wide (100px),
|
||||
// so its offset is its index among the current slides.
|
||||
Object.defineProperty(HTMLElement.prototype, 'offsetLeft', {
|
||||
configurable: true,
|
||||
get() {
|
||||
if (!this.dataset?.eventId) return 0;
|
||||
const slides = [
|
||||
...(this.parentElement?.querySelectorAll('.carousel-slide') ?? []),
|
||||
];
|
||||
return slides.indexOf(this) * 100;
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
this.photos = [
|
||||
{ eventId: 'event-a', url: 'a.jpg', isLandscape: true },
|
||||
{ eventId: 'event-b', url: 'b.jpg', isLandscape: true },
|
||||
];
|
||||
this.focusEventId = 'event-b';
|
||||
|
||||
await render(
|
||||
<template>
|
||||
<div class="test-container">
|
||||
<PhotoCarousel
|
||||
@photos={{this.photos}}
|
||||
@scrollToEventId={{this.focusEventId}}
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
);
|
||||
|
||||
// Track scrollLeft directly; the real one would clamp without layout.
|
||||
const track = document.querySelector('.photo-carousel-track');
|
||||
let scrollLeft = 0;
|
||||
Object.defineProperty(track, 'scrollLeft', {
|
||||
configurable: true,
|
||||
get: () => scrollLeft,
|
||||
set: (value) => {
|
||||
scrollLeft = value;
|
||||
},
|
||||
});
|
||||
|
||||
// A new photo is prepended, shifting the focused photo (event-b) from
|
||||
// index 1 to index 2, without the focused event changing.
|
||||
this.set('photos', [
|
||||
{ eventId: 'event-c', url: 'c.jpg', isLandscape: true },
|
||||
{ eventId: 'event-a', url: 'a.jpg', isLandscape: true },
|
||||
{ eventId: 'event-b', url: 'b.jpg', isLandscape: true },
|
||||
]);
|
||||
await settled();
|
||||
|
||||
await waitUntil(() => scrollLeft === 200, { timeout: 1000 });
|
||||
|
||||
assert.strictEqual(
|
||||
scrollLeft,
|
||||
200,
|
||||
'the track re-aligns to the shifted focused photo'
|
||||
);
|
||||
} finally {
|
||||
if (originalOffsetLeft) {
|
||||
Object.defineProperty(
|
||||
HTMLElement.prototype,
|
||||
'offsetLeft',
|
||||
originalOffsetLeft
|
||||
);
|
||||
} else {
|
||||
delete HTMLElement.prototype.offsetLeft;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'marco/tests/helpers';
|
||||
import { render, click, triggerKeyEvent } from '@ember/test-helpers';
|
||||
import { render, click, triggerKeyEvent, settled } from '@ember/test-helpers';
|
||||
import Service from '@ember/service';
|
||||
import { decodePointer } from 'applesauce-core/helpers/pointers';
|
||||
import PhotoGallery from 'marco/components/photo-gallery';
|
||||
@@ -379,6 +379,83 @@ module('Integration | Component | photo-gallery', function (hooks) {
|
||||
assert.ok(closed, 'gallery was closed when last photo was deleted');
|
||||
});
|
||||
|
||||
test('it completes the Blossom cleanup when the real close unmounts the gallery', async function (assert) {
|
||||
this.nostrAuth.pubkey = USER_A;
|
||||
this.settings.update('experimentalEnablePhotoDeletion', true);
|
||||
Object.defineProperty(this.nostrAuth, 'signer', {
|
||||
configurable: true,
|
||||
get: () => ({
|
||||
signEvent: async (e) => ({
|
||||
...e,
|
||||
id: 'a3b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1',
|
||||
sig: 'b3b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1',
|
||||
pubkey: USER_A,
|
||||
}),
|
||||
getPublicKey: async () => USER_A,
|
||||
}),
|
||||
});
|
||||
|
||||
const mainHash =
|
||||
'd3b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1';
|
||||
const thumbHash =
|
||||
'e3b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1';
|
||||
|
||||
this.set('photos', [
|
||||
{
|
||||
...this.photos[0],
|
||||
url: 'https://example.com/photo.jpg',
|
||||
thumbUrl: 'https://example.com/thumb.jpg',
|
||||
hash: mainHash,
|
||||
hashes: [mainHash, thumbHash],
|
||||
},
|
||||
]);
|
||||
this.selectedPhoto = this.photos[0];
|
||||
|
||||
// Real close: unmounts the gallery, so a task that closed the component
|
||||
// before finishing its Blossom cleanup would be cancelled.
|
||||
this.open = true;
|
||||
this.close = () => this.set('open', false);
|
||||
|
||||
sinon.stub(window, 'confirm').returns(true);
|
||||
const blossomStub = sinon.stub(this.blossom, 'delete').resolves();
|
||||
sinon
|
||||
.stub(this.nostrRelay, 'publish')
|
||||
.resolves([{ ok: true, from: 'wss://relay.test' }]);
|
||||
sinon.stub(this.nostrData.store, 'add');
|
||||
const toastSpy = sinon.spy(this.toast, 'show');
|
||||
|
||||
await render(
|
||||
<template>
|
||||
<div id="test-container">
|
||||
<div id="modal-portal"></div>
|
||||
{{#if this.open}}
|
||||
<PhotoGallery
|
||||
@photos={{this.photos}}
|
||||
@selectedPhoto={{this.selectedPhoto}}
|
||||
@onClose={{this.close}}
|
||||
/>
|
||||
{{/if}}
|
||||
</div>
|
||||
</template>
|
||||
);
|
||||
|
||||
await click('.dropdown-trigger-btn');
|
||||
await click('.dropdown-item.text-danger');
|
||||
|
||||
assert.strictEqual(
|
||||
blossomStub.callCount,
|
||||
2,
|
||||
'both blobs were deleted before the gallery unmounted'
|
||||
);
|
||||
assert.ok(
|
||||
toastSpy.calledWith('Photo deleted successfully'),
|
||||
'the success toast fired'
|
||||
);
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.doesNotExist('the gallery closed after the deletion');
|
||||
});
|
||||
|
||||
test('it copies event id to clipboard', async function (assert) {
|
||||
const eventId = '1'.repeat(64);
|
||||
this.nostrAuth.pubkey = USER_A;
|
||||
@@ -626,6 +703,47 @@ module('Integration | Component | photo-gallery', function (hooks) {
|
||||
.hasAttribute('data-current-event-id', 'event2');
|
||||
});
|
||||
|
||||
test('keeps the focused photo when new photos are added', async function (assert) {
|
||||
this.photos = [
|
||||
{ eventId: 'event1', url: 'photo1.jpg' },
|
||||
{ eventId: 'event2', url: 'photo2.jpg' },
|
||||
];
|
||||
this.selectedPhoto = this.photos[1];
|
||||
|
||||
await render(
|
||||
<template>
|
||||
<div id="test-container">
|
||||
<div id="modal-portal"></div>
|
||||
<PhotoGallery
|
||||
@photos={{this.photos}}
|
||||
@selectedPhoto={{this.selectedPhoto}}
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
);
|
||||
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.hasAttribute('data-current-event-id', 'event2');
|
||||
|
||||
// Another photo streams in first, as fresh objects (parsePlacePhotos
|
||||
// rebuilds every photo on each update).
|
||||
this.set('photos', [
|
||||
{ eventId: 'event0', url: 'photo0.jpg' },
|
||||
{ eventId: 'event1', url: 'photo1.jpg' },
|
||||
{ eventId: 'event2', url: 'photo2.jpg' },
|
||||
]);
|
||||
await settled();
|
||||
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.hasAttribute(
|
||||
'data-current-event-id',
|
||||
'event2',
|
||||
'focus does not jump to the newly added photo'
|
||||
);
|
||||
});
|
||||
|
||||
test('escape key closes gallery', async function (assert) {
|
||||
this.selectedPhoto = this.photos[0];
|
||||
let closed = false;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'marco/tests/helpers';
|
||||
import { render, click } from '@ember/test-helpers';
|
||||
import { render, click, settled } from '@ember/test-helpers';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import Service from '@ember/service';
|
||||
import PlaceDetails from 'marco/components/place-details';
|
||||
|
||||
@@ -807,42 +808,289 @@ module('Integration | Component | place-details', function (hooks) {
|
||||
assert.dom('.place-lists-manager .edit-item').doesNotExist();
|
||||
});
|
||||
|
||||
test('it focuses a deep-linked photo from the photo query param', async function (assert) {
|
||||
class NostrDataStub extends Service {
|
||||
placePhotos = [
|
||||
{
|
||||
id: 'event-2',
|
||||
pubkey: 'a'.repeat(64),
|
||||
kind: 360,
|
||||
created_at: 1,
|
||||
tags: [
|
||||
['i', 'osm:node:1'],
|
||||
['imeta', 'url https://example.com/a.jpg', 'dim 800x600'],
|
||||
],
|
||||
},
|
||||
];
|
||||
untrustedContentCount = 0;
|
||||
showUntrustedContent = false;
|
||||
toggleShowUntrustedContent() {}
|
||||
}
|
||||
function makePhoto(id, { pubkey = 'a'.repeat(64), created_at = 1 } = {}) {
|
||||
return {
|
||||
id,
|
||||
pubkey,
|
||||
kind: 360,
|
||||
created_at,
|
||||
tags: [
|
||||
['i', 'osm:node:1'],
|
||||
['imeta', `url https://example.com/${id}.jpg`, 'dim 800x600'],
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
class MockRouter extends Service {
|
||||
currentRoute = { queryParams: { photo: 'event-2' } };
|
||||
// Deep links render the gallery through `in-element`, so the test needs the
|
||||
// same `#modal-portal` the app provides.
|
||||
async function renderDetails(place) {
|
||||
await render(
|
||||
<template>
|
||||
<div id="modal-portal"></div>
|
||||
<PlaceDetails @place={{place}} />
|
||||
</template>
|
||||
);
|
||||
}
|
||||
|
||||
function registerDeepLink(owner, { photo = 'event-2', NostrDataStub }) {
|
||||
class DebLinkRouter extends Service {
|
||||
currentRoute = { queryParams: { photo } };
|
||||
transitionTo() {}
|
||||
urlFor() {
|
||||
return '/place/osm:node:1';
|
||||
}
|
||||
}
|
||||
|
||||
this.owner.register('service:nostr-data', NostrDataStub);
|
||||
this.owner.register('service:router', MockRouter);
|
||||
owner.register('service:nostr-data', NostrDataStub);
|
||||
owner.register('service:router', DebLinkRouter);
|
||||
}
|
||||
|
||||
test('it focuses and opens a deep-linked photo from the photo query param', async function (assert) {
|
||||
class NostrDataStub extends Service {
|
||||
@tracked placePhotos = [makePhoto('event-2')];
|
||||
untrustedContentCount = 0;
|
||||
showUntrustedContent = false;
|
||||
toggleShowUntrustedContent() {}
|
||||
}
|
||||
|
||||
registerDeepLink(this.owner, { NostrDataStub });
|
||||
|
||||
const place = { title: 'Test Place', osmId: '1', osmType: 'node' };
|
||||
|
||||
await render(<template><PlaceDetails @place={{place}} /></template>);
|
||||
await renderDetails(place);
|
||||
|
||||
assert
|
||||
.dom('.carousel-slide[data-event-id="event-2"]')
|
||||
.hasClass('active', 'the deep-linked photo is focused');
|
||||
.hasClass('active', 'the deep-linked photo is focused inline');
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.hasAttribute(
|
||||
'data-current-event-id',
|
||||
'event-2',
|
||||
'the gallery opens on the deep-linked photo'
|
||||
);
|
||||
});
|
||||
|
||||
test('it opens the gallery once the deep-linked photo arrives', async function (assert) {
|
||||
class NostrDataStub extends Service {
|
||||
@tracked placePhotos = [];
|
||||
untrustedContentCount = 0;
|
||||
showUntrustedContent = false;
|
||||
toggleShowUntrustedContent() {}
|
||||
revealPlacePhotoAuthor() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
registerDeepLink(this.owner, { NostrDataStub });
|
||||
|
||||
const nostrData = this.owner.lookup('service:nostr-data');
|
||||
const place = { title: 'Test Place', osmId: '1', osmType: 'node' };
|
||||
await renderDetails(place);
|
||||
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.doesNotExist('the gallery waits for the photo to load');
|
||||
|
||||
nostrData.placePhotos = [makePhoto('event-2')];
|
||||
await settled();
|
||||
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.hasAttribute(
|
||||
'data-current-event-id',
|
||||
'event-2',
|
||||
'the gallery opens once the photo arrives'
|
||||
);
|
||||
});
|
||||
|
||||
test('it reveals the linked author before opening the gallery', async function (assert) {
|
||||
const linked = makePhoto('event-2');
|
||||
|
||||
class NostrDataStub extends Service {
|
||||
@tracked placePhotos = [];
|
||||
untrustedContentCount = 1;
|
||||
showUntrustedContent = false;
|
||||
revealCalls = [];
|
||||
toggleShowUntrustedContent() {}
|
||||
revealPlacePhotoAuthor(eventId) {
|
||||
this.revealCalls.push(eventId);
|
||||
this.placePhotos = [linked];
|
||||
this.untrustedContentCount = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
registerDeepLink(this.owner, { NostrDataStub });
|
||||
|
||||
const nostrData = this.owner.lookup('service:nostr-data');
|
||||
const place = { title: 'Test Place', osmId: '1', osmType: 'node' };
|
||||
await renderDetails(place);
|
||||
|
||||
assert.deepEqual(
|
||||
nostrData.revealCalls,
|
||||
['event-2'],
|
||||
'the linked event was handed to the reveal'
|
||||
);
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.hasAttribute(
|
||||
'data-current-event-id',
|
||||
'event-2',
|
||||
'the gallery opens after revealing the author'
|
||||
);
|
||||
});
|
||||
|
||||
test('it keeps the deep-linked photo focused when photos are added later', async function (assert) {
|
||||
class NostrDataStub extends Service {
|
||||
@tracked placePhotos = [makePhoto('event-2', { created_at: 2 })];
|
||||
untrustedContentCount = 0;
|
||||
showUntrustedContent = false;
|
||||
toggleShowUntrustedContent() {}
|
||||
}
|
||||
|
||||
registerDeepLink(this.owner, { NostrDataStub });
|
||||
|
||||
const nostrData = this.owner.lookup('service:nostr-data');
|
||||
const place = { title: 'Test Place', osmId: '1', osmType: 'node' };
|
||||
await renderDetails(place);
|
||||
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.hasAttribute('data-current-event-id', 'event-2');
|
||||
|
||||
// Another author's photo streams in afterwards, with fresh objects.
|
||||
nostrData.placePhotos = [
|
||||
makePhoto('event-1', { pubkey: 'b'.repeat(64), created_at: 1 }),
|
||||
...nostrData.placePhotos,
|
||||
];
|
||||
await settled();
|
||||
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.hasAttribute(
|
||||
'data-current-event-id',
|
||||
'event-2',
|
||||
'the gallery stays focused on the deep-linked photo'
|
||||
);
|
||||
});
|
||||
|
||||
test('it does not reopen the gallery after the user closes it', async function (assert) {
|
||||
class NostrDataStub extends Service {
|
||||
@tracked placePhotos = [makePhoto('event-2')];
|
||||
untrustedContentCount = 0;
|
||||
showUntrustedContent = false;
|
||||
toggleShowUntrustedContent() {}
|
||||
}
|
||||
|
||||
registerDeepLink(this.owner, { NostrDataStub });
|
||||
|
||||
const nostrData = this.owner.lookup('service:nostr-data');
|
||||
const place = { title: 'Test Place', osmId: '1', osmType: 'node' };
|
||||
await renderDetails(place);
|
||||
|
||||
await click('.photo-gallery-content .close-btn');
|
||||
|
||||
assert.dom('.photo-gallery-content').doesNotExist('gallery closed');
|
||||
|
||||
nostrData.placePhotos = [
|
||||
...nostrData.placePhotos,
|
||||
makePhoto('event-1', { pubkey: 'b'.repeat(64), created_at: 3 }),
|
||||
];
|
||||
await settled();
|
||||
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.doesNotExist('the gallery does not reopen after being closed');
|
||||
});
|
||||
|
||||
test('it does not open the gallery without a deep link', async function (assert) {
|
||||
class NostrDataStub extends Service {
|
||||
@tracked placePhotos = [makePhoto('event-2')];
|
||||
untrustedContentCount = 0;
|
||||
showUntrustedContent = false;
|
||||
toggleShowUntrustedContent() {}
|
||||
}
|
||||
|
||||
registerDeepLink(this.owner, { photo: null, NostrDataStub });
|
||||
|
||||
const place = { title: 'Test Place', osmId: '1', osmType: 'node' };
|
||||
await renderDetails(place);
|
||||
|
||||
assert.dom('.carousel-slide').exists('the inline carousel renders');
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.doesNotExist('the gallery stays closed without a deep link');
|
||||
});
|
||||
|
||||
test('it does not reopen the gallery if the linked photo arrives after a manual close', async function (assert) {
|
||||
class NostrDataStub extends Service {
|
||||
@tracked placePhotos = [makePhoto('event-1')];
|
||||
untrustedContentCount = 0;
|
||||
showUntrustedContent = false;
|
||||
toggleShowUntrustedContent() {}
|
||||
revealPlacePhotoAuthor() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
registerDeepLink(this.owner, { NostrDataStub });
|
||||
|
||||
const nostrData = this.owner.lookup('service:nostr-data');
|
||||
const place = { title: 'Test Place', osmId: '1', osmType: 'node' };
|
||||
await renderDetails(place);
|
||||
|
||||
// The linked photo is not loaded yet. The user opens the gallery on
|
||||
// another photo, then closes it.
|
||||
await click('.carousel-slide[data-event-id="event-1"]');
|
||||
assert.dom('.photo-gallery-content').exists('the user opened the gallery');
|
||||
await click('.photo-gallery-content .close-btn');
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.doesNotExist('the user closed the gallery');
|
||||
|
||||
// The linked photo finally arrives; it must not reopen the gallery.
|
||||
nostrData.placePhotos = [...nostrData.placePhotos, makePhoto('event-2')];
|
||||
await settled();
|
||||
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.doesNotExist('the late linked photo does not reopen the gallery');
|
||||
});
|
||||
|
||||
test('it does not hijack a gallery the user opened on another photo', async function (assert) {
|
||||
class NostrDataStub extends Service {
|
||||
@tracked placePhotos = [makePhoto('event-1', { created_at: 2 })];
|
||||
untrustedContentCount = 0;
|
||||
showUntrustedContent = false;
|
||||
toggleShowUntrustedContent() {}
|
||||
revealPlacePhotoAuthor() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
registerDeepLink(this.owner, { NostrDataStub });
|
||||
|
||||
const nostrData = this.owner.lookup('service:nostr-data');
|
||||
const place = { title: 'Test Place', osmId: '1', osmType: 'node' };
|
||||
await renderDetails(place);
|
||||
|
||||
await click('.carousel-slide[data-event-id="event-1"]');
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.hasAttribute('data-current-event-id', 'event-1');
|
||||
|
||||
nostrData.placePhotos = [
|
||||
...nostrData.placePhotos,
|
||||
makePhoto('event-2', { created_at: 3 }),
|
||||
];
|
||||
await settled();
|
||||
|
||||
assert
|
||||
.dom('.photo-gallery-content')
|
||||
.hasAttribute(
|
||||
'data-current-event-id',
|
||||
'event-1',
|
||||
'the late linked photo does not steal focus'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1116,6 +1116,85 @@ module('Unit | Service | nostr-data | place photos', function (hooks) {
|
||||
assert.strictEqual(service.placePhotos.length, 1, 'back to trusted only');
|
||||
});
|
||||
|
||||
test('revealPlacePhotoAuthor reveals only that author and recounts', async function (assert) {
|
||||
const service = this.owner.lookup('service:nostr-data');
|
||||
const pkA = makePubkey(88);
|
||||
const pkB = makePubkey(89);
|
||||
const trustedId = makeEventId(910);
|
||||
const authorAId = makeEventId(911);
|
||||
const authorBId = makeEventId(912);
|
||||
|
||||
await service.loadPhotosForPlace({ osmId: '910', osmType: 'node' });
|
||||
|
||||
service._recordProvenance(trustedId, 'wss://nostr.kosmos.org');
|
||||
service.store.add(makePhotoEvent(pkA, 'osm:node:910', { id: trustedId }));
|
||||
service.store.add(makePhotoEvent(pkA, 'osm:node:910', { id: authorAId }));
|
||||
service.store.add(makePhotoEvent(pkB, 'osm:node:910', { id: authorBId }));
|
||||
|
||||
await wait(50);
|
||||
|
||||
assert.deepEqual(
|
||||
service.placePhotos.map((e) => e.id),
|
||||
[trustedId],
|
||||
'only trusted shown initially'
|
||||
);
|
||||
assert.strictEqual(
|
||||
service.untrustedContentCount,
|
||||
2,
|
||||
'two untrusted hidden'
|
||||
);
|
||||
|
||||
assert.true(
|
||||
service.revealPlacePhotoAuthor(authorAId),
|
||||
'returns true for a known event'
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
service.placePhotos.map((e) => e.id).sort(),
|
||||
[trustedId, authorAId].sort(),
|
||||
"author A's untrusted photo is revealed"
|
||||
);
|
||||
assert.false(
|
||||
service.placePhotos.some((e) => e.id === authorBId),
|
||||
"author B's untrusted photo stays hidden"
|
||||
);
|
||||
assert.strictEqual(service.untrustedContentCount, 1, 'count decremented');
|
||||
});
|
||||
|
||||
test('revealPlacePhotoAuthor returns false for an event that is not loaded', async function (assert) {
|
||||
const service = this.owner.lookup('service:nostr-data');
|
||||
|
||||
await service.loadPhotosForPlace({ osmId: '911', osmType: 'node' });
|
||||
|
||||
assert.false(
|
||||
service.revealPlacePhotoAuthor(makeEventId(999)),
|
||||
'returns false for an unknown event'
|
||||
);
|
||||
assert.strictEqual(service.untrustedContentCount, 0, 'nothing to reveal');
|
||||
});
|
||||
|
||||
test('revealPlacePhotoAuthor is cleared when the place changes', async function (assert) {
|
||||
const service = this.owner.lookup('service:nostr-data');
|
||||
const pk = makePubkey(90);
|
||||
const untrustedId = makeEventId(920);
|
||||
|
||||
await service.loadPhotosForPlace({ osmId: '920', osmType: 'node' });
|
||||
service.store.add(makePhotoEvent(pk, 'osm:node:920', { id: untrustedId }));
|
||||
|
||||
await wait(50);
|
||||
|
||||
service.revealPlacePhotoAuthor(untrustedId);
|
||||
assert.strictEqual(service.placePhotos.length, 1, 'author revealed');
|
||||
|
||||
await service.loadPhotosForPlace({ osmId: '921', osmType: 'node' });
|
||||
|
||||
assert.deepEqual(
|
||||
[...service.revealedUntrustedAuthors],
|
||||
[],
|
||||
'revealed authors cleared for the next place'
|
||||
);
|
||||
});
|
||||
|
||||
test('own photos are shown without provenance', async function (assert) {
|
||||
const service = this.owner.lookup('service:nostr-data');
|
||||
const myPubkey = makePubkey(95);
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
import { module, test } from 'qunit';
|
||||
import {
|
||||
computeDetentLayout,
|
||||
computeSheetHeight,
|
||||
findDetent,
|
||||
nearestDetentIndex,
|
||||
resolveSnap,
|
||||
} from 'marco/utils/sheet-detents';
|
||||
|
||||
const VIEWPORT = 800;
|
||||
// No top gap, so the sheet fills the viewport.
|
||||
const SHEET = computeSheetHeight(VIEWPORT); // 800
|
||||
// expanded: 800 - 800 = 0, medium: 800 - 440 = 360, collapsed: 800 - 240 = 560
|
||||
const LAYOUT = computeDetentLayout({
|
||||
viewportHeight: VIEWPORT,
|
||||
sheetHeight: SHEET,
|
||||
});
|
||||
|
||||
module('Unit | Utility | sheet-detents', function () {
|
||||
test('computeSheetHeight fills the viewport minus the top gap', function (assert) {
|
||||
assert.strictEqual(computeSheetHeight(800), 800);
|
||||
assert.strictEqual(computeSheetHeight(800, 8), 792);
|
||||
assert.strictEqual(computeSheetHeight(100, 200), 0, 'never negative');
|
||||
});
|
||||
|
||||
test('computeDetentLayout produces ascending offsets with expanded first', function (assert) {
|
||||
assert.deepEqual(
|
||||
LAYOUT.map((detent) => detent.name),
|
||||
['expanded', 'medium', 'collapsed'],
|
||||
'detents are ordered by ascending offset'
|
||||
);
|
||||
assert.strictEqual(findDetent(LAYOUT, 'expanded').offset, 0);
|
||||
assert.strictEqual(findDetent(LAYOUT, 'medium').offset, 360);
|
||||
assert.strictEqual(findDetent(LAYOUT, 'collapsed').offset, 560);
|
||||
});
|
||||
|
||||
test('computeDetentLayout keeps a single clamped detent for short sheets', function (assert) {
|
||||
const layout = computeDetentLayout({
|
||||
viewportHeight: VIEWPORT,
|
||||
sheetHeight: 100,
|
||||
});
|
||||
|
||||
assert.strictEqual(layout.length, 1, 'only one reachable position remains');
|
||||
assert.strictEqual(
|
||||
layout[0].offset,
|
||||
0,
|
||||
'the remaining detent is fully open'
|
||||
);
|
||||
assert.strictEqual(layout[0].visibleHeight, 100);
|
||||
});
|
||||
|
||||
test('nearestDetentIndex picks the closest offset', function (assert) {
|
||||
assert.strictEqual(nearestDetentIndex(LAYOUT, 10), 0, 'near expanded');
|
||||
assert.strictEqual(nearestDetentIndex(LAYOUT, 300), 1, 'near medium');
|
||||
assert.strictEqual(nearestDetentIndex(LAYOUT, 480), 2, 'near collapsed');
|
||||
});
|
||||
|
||||
test('resolveSnap snaps to the nearest detent without velocity', function (assert) {
|
||||
assert.strictEqual(
|
||||
resolveSnap({
|
||||
offset: 100,
|
||||
velocity: 0,
|
||||
layout: LAYOUT,
|
||||
sheetHeight: SHEET,
|
||||
}),
|
||||
'expanded'
|
||||
);
|
||||
assert.strictEqual(
|
||||
resolveSnap({
|
||||
offset: 290,
|
||||
velocity: 0,
|
||||
layout: LAYOUT,
|
||||
sheetHeight: SHEET,
|
||||
}),
|
||||
'medium'
|
||||
);
|
||||
assert.strictEqual(
|
||||
resolveSnap({
|
||||
offset: 490,
|
||||
velocity: 0,
|
||||
layout: LAYOUT,
|
||||
sheetHeight: SHEET,
|
||||
}),
|
||||
'collapsed'
|
||||
);
|
||||
});
|
||||
|
||||
test('resolveSnap flings one detent in the gesture direction', function (assert) {
|
||||
assert.strictEqual(
|
||||
resolveSnap({
|
||||
offset: 300,
|
||||
velocity: -0.8,
|
||||
layout: LAYOUT,
|
||||
sheetHeight: SHEET,
|
||||
}),
|
||||
'expanded',
|
||||
'a fast upward flick moves to the next detent up'
|
||||
);
|
||||
assert.strictEqual(
|
||||
resolveSnap({
|
||||
offset: 290,
|
||||
velocity: 0.8,
|
||||
layout: LAYOUT,
|
||||
sheetHeight: SHEET,
|
||||
}),
|
||||
'collapsed',
|
||||
'a fast downward flick moves to the next detent down'
|
||||
);
|
||||
});
|
||||
|
||||
test('resolveSnap dismisses past the collapsed threshold', function (assert) {
|
||||
assert.strictEqual(
|
||||
resolveSnap({
|
||||
offset: 700,
|
||||
velocity: 0,
|
||||
layout: LAYOUT,
|
||||
sheetHeight: SHEET,
|
||||
}),
|
||||
'dismissed',
|
||||
'dragging well past collapsed dismisses'
|
||||
);
|
||||
assert.strictEqual(
|
||||
resolveSnap({
|
||||
offset: 570,
|
||||
velocity: 0.6,
|
||||
layout: LAYOUT,
|
||||
sheetHeight: SHEET,
|
||||
}),
|
||||
'dismissed',
|
||||
'a fast downward flick past collapsed dismisses'
|
||||
);
|
||||
assert.strictEqual(
|
||||
resolveSnap({
|
||||
offset: 500,
|
||||
velocity: 0,
|
||||
layout: LAYOUT,
|
||||
sheetHeight: SHEET,
|
||||
}),
|
||||
'collapsed',
|
||||
'the same offset without velocity just collapses'
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user