fix(ui): mobile UI enhancements (#1184)
This commit is contained in:
+18
-11
@@ -1,9 +1,16 @@
|
||||
@use "../../../../../assets/layout/styles/layout/variables";
|
||||
|
||||
.main-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
background: var(--page-background);
|
||||
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
padding: var(--space-4);
|
||||
}
|
||||
}
|
||||
|
||||
.header {
|
||||
@@ -15,7 +22,7 @@
|
||||
border-bottom: 1px solid var(--p-content-border-color);
|
||||
gap: 1rem;
|
||||
|
||||
@media (width <= 768px) {
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
padding: 1rem;
|
||||
}
|
||||
}
|
||||
@@ -39,7 +46,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
flex-shrink: 1;
|
||||
|
||||
p {
|
||||
@@ -49,7 +56,7 @@
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
@media (width <= 768px) {
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
@@ -158,7 +165,7 @@
|
||||
width: 8rem;
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
width: 100%;
|
||||
|
||||
label {
|
||||
@@ -172,7 +179,7 @@
|
||||
}
|
||||
|
||||
::ng-deep .p-select-overlay {
|
||||
@media (width <= 768px) {
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
max-width: 70vw;
|
||||
|
||||
.p-select-option {
|
||||
@@ -285,7 +292,7 @@ p-inputgroup.disabled {
|
||||
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 10%);
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
@@ -305,7 +312,7 @@ div.cover-image {
|
||||
text-overflow: ellipsis;
|
||||
white-space: wrap;
|
||||
|
||||
@media (width <= 768px) {
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
@@ -330,7 +337,7 @@ div.cover-image {
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
|
||||
@media (width <= 768px) {
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
@@ -339,7 +346,7 @@ div.cover-image {
|
||||
.path-select {
|
||||
width: 8rem;
|
||||
|
||||
@media (width <= 768px) {
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
flex-basis: 50%;
|
||||
}
|
||||
}
|
||||
@@ -357,7 +364,7 @@ div.cover-image {
|
||||
}
|
||||
|
||||
.footer {
|
||||
@media (width <= 768px) {
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
flex-wrap: wrap;
|
||||
|
||||
::ng-deep .p-button-label {
|
||||
@@ -405,7 +412,7 @@ div.cover-image {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
::ng-deep .p-paginator .p-paginator-jtp-dropdown span {
|
||||
font-size: var(--p-select-sm-font-size);
|
||||
padding-block: var(--p-select-sm-padding-y);
|
||||
|
||||
@@ -21,6 +21,14 @@
|
||||
(ngModelChange)="onQueryChange($event)"
|
||||
(keydown)="onKeydown($event)"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="command-palette-close-button"
|
||||
[attr.aria-label]="'close' | transloco"
|
||||
(click)="svc.hide()"
|
||||
>
|
||||
<i class="pi pi-times" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@use "../../../assets/layout/styles/layout/variables";
|
||||
|
||||
:host {
|
||||
display: contents;
|
||||
}
|
||||
@@ -12,11 +14,13 @@
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
max-height: min(70vh, calc(100dvh - 4rem));
|
||||
background: var(--surface-overlay);
|
||||
background: color-mix(in srgb, var(--surface-overlay) 64%, var(--surface-card));
|
||||
color: var(--text-color);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: var(--shadow-overlay);
|
||||
box-shadow:
|
||||
0 20px 64px rgb(0 0 0 / 32%),
|
||||
var(--shadow-overlay);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -61,6 +65,34 @@
|
||||
}
|
||||
}
|
||||
|
||||
.command-palette-close-button {
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
color: var(--text-color);
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--surface-hover);
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--primary-color);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
i {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.command-palette-results {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
@@ -228,17 +260,78 @@
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
@media (width <= 767px) {
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
.command-palette-shell {
|
||||
width: 100vw;
|
||||
}
|
||||
|
||||
.command-palette {
|
||||
max-height: calc(100dvh - 3.5rem);
|
||||
border-top: none;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
max-height: 100dvh;
|
||||
background: var(--app-background);
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.command-palette-form {
|
||||
box-sizing: border-box;
|
||||
flex-shrink: 0;
|
||||
height: 3.5rem;
|
||||
background: var(--app-background);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
|
||||
&:has(+ .command-palette-results) .command-palette-input-row {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.command-palette-input-row {
|
||||
box-sizing: border-box;
|
||||
height: 100%;
|
||||
gap: 0.5rem;
|
||||
padding:
|
||||
0
|
||||
calc(0.75rem + env(safe-area-inset-right))
|
||||
0
|
||||
calc(0.75rem + env(safe-area-inset-left));
|
||||
|
||||
> .pi-search {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 2.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.command-palette-input {
|
||||
padding-right: 0.5rem;
|
||||
}
|
||||
|
||||
.command-palette-close-button {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.command-palette-results,
|
||||
.command-palette-empty {
|
||||
background: var(--page-background);
|
||||
}
|
||||
|
||||
.command-palette-empty {
|
||||
padding:
|
||||
var(--space-6)
|
||||
calc(var(--space-4) + env(safe-area-inset-right))
|
||||
var(--space-6)
|
||||
calc(var(--space-4) + env(safe-area-inset-left));
|
||||
}
|
||||
|
||||
.command-palette-results {
|
||||
padding:
|
||||
var(--space-2)
|
||||
calc(var(--space-3) + env(safe-area-inset-right))
|
||||
var(--space-2)
|
||||
calc(var(--space-3) + env(safe-area-inset-left));
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
box-shadow: 0 12px 24px rgb(0 0 0 / 18%);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { Overlay, OverlayModule, OverlayRef } from '@angular/cdk/overlay';
|
||||
import { TemplatePortal } from '@angular/cdk/portal';
|
||||
import { Component, computed, DestroyRef, effect, ElementRef, inject, signal, TemplateRef, untracked, ViewContainerRef, viewChild } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, computed, DestroyRef, effect, ElementRef, inject, signal, TemplateRef, untracked, ViewContainerRef, viewChild } from '@angular/core';
|
||||
import { NavigationStart, Router } from '@angular/router';
|
||||
import { filter, take } from 'rxjs/operators';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { TranslocoDirective } from '@jsverse/transloco';
|
||||
import { TranslocoDirective, TranslocoPipe } from '@jsverse/transloco';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
import { CoverPlaceholderComponent } from '../../shared/components/cover-generator/cover-generator.component';
|
||||
import { IconDisplayComponent } from '../../shared/components/icon-display/icon-display.component';
|
||||
import { MOBILE_SHELL_ACTIVE_PROPERTY } from '../../shared/layout/layout.service';
|
||||
import { PaletteItem } from './command-palette.model';
|
||||
import { CommandPaletteService } from './command-palette.service';
|
||||
|
||||
const MOBILE_MEDIA_QUERY = '(max-width: 767px)';
|
||||
const MOBILE_TOPBAR_HEIGHT = '3.5rem';
|
||||
|
||||
@Component({
|
||||
selector: 'app-command-palette',
|
||||
standalone: true,
|
||||
imports: [A11yModule, OverlayModule, FormsModule, TranslocoDirective, IconDisplayComponent, CoverPlaceholderComponent],
|
||||
imports: [A11yModule, OverlayModule, FormsModule, TranslocoDirective, TranslocoPipe, IconDisplayComponent, CoverPlaceholderComponent],
|
||||
templateUrl: './command-palette.component.html',
|
||||
styleUrl: './command-palette.component.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class CommandPaletteComponent {
|
||||
protected readonly svc = inject(CommandPaletteService);
|
||||
@@ -45,12 +44,9 @@ export class CommandPaletteComponent {
|
||||
private overlayRef: OverlayRef | undefined;
|
||||
private focusAnimationFrameId: number | undefined;
|
||||
private focusTimeoutId: number | undefined;
|
||||
private mobileMedia: MediaQueryList | undefined;
|
||||
private readonly mobileMediaListener = () => {
|
||||
this.applyPositionStrategy();
|
||||
this.refreshAvailableHeight();
|
||||
};
|
||||
private readonly visualViewportListener = () => this.refreshAvailableHeight();
|
||||
private viewportAnimationFrameId: number | undefined;
|
||||
private readonly mobileStateListener = () => this.scheduleViewportRefresh();
|
||||
private readonly visualViewportListener = () => this.scheduleViewportRefresh();
|
||||
|
||||
constructor() {
|
||||
const unregisterOverlayController = this.svc.registerOverlayController({
|
||||
@@ -162,7 +158,7 @@ export class CommandPaletteComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
this.bindMobileMediaListener();
|
||||
this.bindMobileStateListener();
|
||||
this.bindVisualViewportListener();
|
||||
this.refreshAvailableHeight();
|
||||
this.overlayRef = this.overlay.create({
|
||||
@@ -180,7 +176,8 @@ export class CommandPaletteComponent {
|
||||
|
||||
private closeOverlay(): void {
|
||||
this.clearPendingFocus();
|
||||
this.unbindMobileMediaListener();
|
||||
this.clearPendingViewportRefresh();
|
||||
this.unbindMobileStateListener();
|
||||
this.unbindVisualViewportListener();
|
||||
this.availableHeightPx.set(null);
|
||||
this.overlayRef?.dispose();
|
||||
@@ -190,7 +187,7 @@ export class CommandPaletteComponent {
|
||||
private buildPositionStrategy() {
|
||||
const position = this.overlay.position().global();
|
||||
if (this.isMobileViewport()) {
|
||||
return position.left('0').top(MOBILE_TOPBAR_HEIGHT);
|
||||
return position.left('0').top('0');
|
||||
}
|
||||
return position.centerHorizontally().top('15vh');
|
||||
}
|
||||
@@ -201,18 +198,21 @@ export class CommandPaletteComponent {
|
||||
}
|
||||
|
||||
private isMobileViewport(): boolean {
|
||||
return this.mobileMedia?.matches ?? false;
|
||||
if (typeof window === 'undefined') return false;
|
||||
return window
|
||||
.getComputedStyle(document.documentElement)
|
||||
.getPropertyValue(MOBILE_SHELL_ACTIVE_PROPERTY)
|
||||
.trim() === '1';
|
||||
}
|
||||
|
||||
private bindMobileMediaListener(): void {
|
||||
if (typeof window === 'undefined' || this.mobileMedia) return;
|
||||
this.mobileMedia = window.matchMedia(MOBILE_MEDIA_QUERY);
|
||||
this.mobileMedia.addEventListener('change', this.mobileMediaListener);
|
||||
private bindMobileStateListener(): void {
|
||||
if (typeof window === 'undefined') return;
|
||||
window.addEventListener('resize', this.mobileStateListener);
|
||||
}
|
||||
|
||||
private unbindMobileMediaListener(): void {
|
||||
this.mobileMedia?.removeEventListener('change', this.mobileMediaListener);
|
||||
this.mobileMedia = undefined;
|
||||
private unbindMobileStateListener(): void {
|
||||
if (typeof window === 'undefined') return;
|
||||
window.removeEventListener('resize', this.mobileStateListener);
|
||||
}
|
||||
|
||||
private bindVisualViewportListener(): void {
|
||||
@@ -240,15 +240,24 @@ export class CommandPaletteComponent {
|
||||
this.availableHeightPx.set(null);
|
||||
return;
|
||||
}
|
||||
const topbarPx = this.readTopbarHeightPx();
|
||||
this.availableHeightPx.set(Math.max(0, Math.round(vv.height - topbarPx)));
|
||||
this.availableHeightPx.set(Math.max(0, Math.round(vv.height)));
|
||||
}
|
||||
|
||||
private readTopbarHeightPx(): number {
|
||||
const fontSize = typeof window !== 'undefined'
|
||||
? parseFloat(window.getComputedStyle(document.documentElement).fontSize)
|
||||
: 16;
|
||||
return (isNaN(fontSize) ? 16 : fontSize) * 3.5;
|
||||
private scheduleViewportRefresh(): void {
|
||||
if (typeof window === 'undefined' || this.viewportAnimationFrameId !== undefined) return;
|
||||
|
||||
this.viewportAnimationFrameId = window.requestAnimationFrame(() => {
|
||||
this.viewportAnimationFrameId = undefined;
|
||||
this.applyPositionStrategy();
|
||||
this.refreshAvailableHeight();
|
||||
});
|
||||
}
|
||||
|
||||
private clearPendingViewportRefresh(): void {
|
||||
if (typeof window !== 'undefined' && this.viewportAnimationFrameId !== undefined) {
|
||||
window.cancelAnimationFrame(this.viewportAnimationFrameId);
|
||||
}
|
||||
this.viewportAnimationFrameId = undefined;
|
||||
}
|
||||
|
||||
private scheduleInputFocus(): void {
|
||||
|
||||
+6
@@ -1,3 +1,5 @@
|
||||
@use "../../../../../assets/layout/styles/layout/variables";
|
||||
|
||||
.metadata-manager {
|
||||
padding: 1.5rem;
|
||||
display: flex;
|
||||
@@ -120,6 +122,10 @@
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
padding: var(--space-4);
|
||||
}
|
||||
}
|
||||
|
||||
.enclosing-container {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@use '../../../../shared/styles/settings-shared' as settings;
|
||||
@use '../../../../../assets/layout/styles/layout/variables';
|
||||
|
||||
// Page container — override mixin's overflow so only the content area scrolls
|
||||
.main-container {
|
||||
@@ -22,14 +23,14 @@
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
.main-container > .settings-header,
|
||||
.main-container > .settings-card {
|
||||
margin-inline: 0.5rem;
|
||||
margin-inline: var(--space-4);
|
||||
}
|
||||
|
||||
.main-container > .settings-header {
|
||||
margin-top: 0.5rem;
|
||||
margin-top: var(--space-4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +44,8 @@
|
||||
gap: 1.5rem;
|
||||
padding: 1.5rem 1.1rem 0;
|
||||
|
||||
@media (width <= 768px) {
|
||||
padding: 1.5rem 0.5rem 0;
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
padding: 1.5rem var(--space-4) 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,7 +358,7 @@
|
||||
// ============================================================================
|
||||
// RESPONSIVE
|
||||
// ============================================================================
|
||||
@media (width <= 768px) {
|
||||
@media #{variables.$mobile-shell-media-query} {
|
||||
.filters-bar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
Reference in New Issue
Block a user