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