Improve UI compatibility for mobile devices
This commit is contained in:
committed by
Aditya Chandel
parent
c8b994ed82
commit
d0edf800c7
@@ -1,9 +1,10 @@
|
||||
<div class="flex flex-row">
|
||||
<div class="flex flex-col flex-grow">
|
||||
<div class="flex justify-between items-center p-2 rounded-t-xl mb-4 bg-[var(--card-background)]">
|
||||
<div class="flex items-center pl-2">
|
||||
<div class="relative flex flex-row">
|
||||
<div class="flex flex-col w-full">
|
||||
|
||||
<div class="flex items-center justify-between w-full gap-4 py-2 px-2 md:px-4 rounded-t-xl mb-4 bg-[var(--card-background)]">
|
||||
<div class="flex items-center min-w-0 max-w-full flex-shrink">
|
||||
@if (entityType$ | async; as entityType) {
|
||||
<p class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
|
||||
<p class="text-xl whitespace-nowrap overflow-hidden text-ellipsis w-full">
|
||||
@if (entityType === EntityType.ALL_BOOKS) {
|
||||
@if (currentFilterLabel && rawFilterParamFromUrl) {
|
||||
{{ currentFilterLabel }}
|
||||
@@ -22,17 +23,22 @@
|
||||
@if (userService.userState$ | async; as userData) {
|
||||
@if (entityType !== EntityType.ALL_BOOKS && entityType !== EntityType.UNSHELVED &&
|
||||
(userData.permissions.admin || userData.permissions.canManipulateLibrary)) {
|
||||
<div>
|
||||
<p-button icon="pi pi-ellipsis-v" [rounded]="true" [text]="true" severity="info" (click)="entitymenu.toggle($event)"></p-button>
|
||||
<div class="ml-2 flex-shrink-0">
|
||||
<p-button
|
||||
icon="pi pi-ellipsis-v"
|
||||
[rounded]="true"
|
||||
[text]="true"
|
||||
severity="info"
|
||||
(click)="entitymenu.toggle($event)">
|
||||
</p-button>
|
||||
<p-menu #entitymenu [model]="entityOptions" [popup]="true" appendTo="body"></p-menu>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-8">
|
||||
<div class="flex flex-row items-center gap-6">
|
||||
<div class="flex flex-wrap items-center gap-4 flex-shrink-0">
|
||||
<div class="flex flex-wrap items-center gap-4">
|
||||
@if (isFilterActive) {
|
||||
<a class="topbar-items topbar-item" (click)="clearFilter()">
|
||||
<i
|
||||
@@ -119,29 +125,62 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<p-fluid>
|
||||
<div class="relative">
|
||||
<i class="pi pi-search search-icon"></i>
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
placeholder="Title, Series or Author..."
|
||||
[(ngModel)]="bookTitle"
|
||||
(ngModelChange)="onSearchTermChange($event)"
|
||||
class="search-input"
|
||||
/>
|
||||
@if (bookTitle) {
|
||||
<!-- MOBILE SEARCH (only visible below md) -->
|
||||
<div class="relative md:hidden">
|
||||
<button
|
||||
type="button"
|
||||
class="topbar-items topbar-item"
|
||||
(click)="searchDropdown.toggle($event)"
|
||||
pTooltip="Search"
|
||||
tooltipPosition="top"
|
||||
>
|
||||
<i class="pi pi-search"></i>
|
||||
</button>
|
||||
|
||||
<p-overlayPanel #searchDropdown [dismissable]="true" appendTo="body" [style]="{ width: '18rem' }">
|
||||
<div class="relative w-full">
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
placeholder="Title, Series or Author..."
|
||||
[(ngModel)]="bookTitle"
|
||||
(ngModelChange)="onSearchTermChange($event)"
|
||||
class="w-full"
|
||||
/>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
[text]="true"
|
||||
size="small"
|
||||
[rounded]="true"
|
||||
class="absolute right-2 top-1/2 -translate-y-1/2"
|
||||
(click)="clearSearch()">
|
||||
</p-button>
|
||||
}
|
||||
</div>
|
||||
</p-fluid>
|
||||
(click)="clearSearch(); searchDropdown.hide()"
|
||||
></p-button>
|
||||
</div>
|
||||
</p-overlayPanel>
|
||||
</div>
|
||||
|
||||
<div class="hidden md:block relative">
|
||||
<i class="pi pi-search search-icon"></i>
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
placeholder="Title, Series or Author..."
|
||||
[(ngModel)]="bookTitle"
|
||||
(ngModelChange)="onSearchTermChange($event)"
|
||||
class="search-input"
|
||||
/>
|
||||
@if (bookTitle) {
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
[text]="true"
|
||||
size="small"
|
||||
[rounded]="true"
|
||||
class="absolute right-2 top-1/2 -translate-y-1/2"
|
||||
(click)="clearSearch()"
|
||||
></p-button>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
<p-button
|
||||
class="pr-2"
|
||||
@@ -312,5 +351,19 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<app-book-filter [entity$]="entity$" [entityType$]="entityType$" [resetFilter$]="resetFilterSubject"></app-book-filter>
|
||||
@if (this.showFilter) {
|
||||
<div
|
||||
class="mobile-filter-mask"
|
||||
(click)="this.showFilter = false">
|
||||
</div>
|
||||
}
|
||||
|
||||
<app-book-filter
|
||||
[showFilter]="showFilter"
|
||||
class="filter-overlay-container z-50 flex-shrink-0"
|
||||
[ngClass]="{ 'active': showFilter, 'ml-4': showFilter }"
|
||||
[entity$]="entity$"
|
||||
[entityType$]="entityType$"
|
||||
[resetFilter$]="resetFilterSubject">
|
||||
</app-book-filter>
|
||||
</div>
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
|
||||
grid-template-columns: repeat(auto-fit, minmax(1px, 1fr));
|
||||
gap: 1.3rem;
|
||||
overflow: hidden;
|
||||
align-items: start;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.virtual-scroller-item {
|
||||
@@ -44,19 +44,6 @@
|
||||
border-width: 1px 1px 0px 1px;
|
||||
}
|
||||
|
||||
.topbar-items {
|
||||
display: flex;
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
gap: 0.3rem;
|
||||
align-items: center;
|
||||
|
||||
li {
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
|
||||
.topbar-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -102,3 +89,54 @@
|
||||
line-height: 2.5rem;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.mobile-filter-mask {
|
||||
@media (max-width: 991px) {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 998;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
}
|
||||
|
||||
.filter-overlay-container {
|
||||
|
||||
@media (max-width: 991px) {
|
||||
width: 225px;
|
||||
position: fixed;
|
||||
top: 3.85rem;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
height: calc(100% - 3.85rem);
|
||||
background-color: var(--card-background);
|
||||
box-shadow: -2px 0 10px rgba(0, 0, 0, 0.15);
|
||||
transform: translateX(100%);
|
||||
transition: transform 0.3s ease;
|
||||
z-index: 1001;
|
||||
|
||||
&.active {
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 992px) {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
|
||||
&:not(.active) {
|
||||
width: 0 !important;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&.active {
|
||||
width: 225px;
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import {InputText} from 'primeng/inputtext';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {BookFilterComponent} from './book-filter/book-filter.component';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {Fluid} from 'primeng/fluid';
|
||||
import {EntityViewPreferences, UserService} from '../../../settings/user-management/user.service';
|
||||
import {OverlayPanelModule} from 'primeng/overlaypanel';
|
||||
import {SeriesCollapseFilter} from './filters/SeriesCollapseFilter';
|
||||
@@ -74,7 +73,7 @@ const SORT_DIRECTION = {
|
||||
standalone: true,
|
||||
templateUrl: './book-browser.component.html',
|
||||
styleUrls: ['./book-browser.component.scss'],
|
||||
imports: [Button, VirtualScrollerModule, BookCardComponent, AsyncPipe, ProgressSpinner, Menu, InputText, FormsModule, BookTableComponent, BookFilterComponent, Tooltip, NgClass, Fluid, PrimeTemplate, NgStyle, OverlayPanelModule, DropdownModule, Checkbox, Popover, Slider, Select, Divider],
|
||||
imports: [Button, VirtualScrollerModule, BookCardComponent, AsyncPipe, ProgressSpinner, Menu, InputText, FormsModule, BookTableComponent, BookFilterComponent, Tooltip, NgClass, PrimeTemplate, NgStyle, OverlayPanelModule, DropdownModule, Checkbox, Popover, Slider, Select, Divider],
|
||||
providers: [SeriesCollapseFilter],
|
||||
animations: [
|
||||
trigger('slideInOut', [
|
||||
@@ -148,6 +147,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
protected metadataMenuItems: MenuItem[] | undefined;
|
||||
currentBooks: Book[] = [];
|
||||
lastSelectedIndex: number | null = null;
|
||||
showFilter: boolean = false;
|
||||
|
||||
get currentCardSize() {
|
||||
return this.coverScalePreferenceService.currentCardSize;
|
||||
@@ -310,7 +310,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
: VIEW_MODES.GRID)
|
||||
: (effectivePrefs.view?.toLowerCase() ?? VIEW_MODES.GRID);
|
||||
|
||||
this.bookFilterComponent.showFilters = sidebarParam === 'true' || (sidebarParam === null && this.filterVisibility);
|
||||
//this.showFilter = sidebarParam === 'true' || (sidebarParam === null && this.filterVisibility);
|
||||
|
||||
this.bookSorter.updateSortOptions();
|
||||
|
||||
@@ -323,7 +323,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
[QUERY_PARAMS.VIEW]: this.currentViewMode,
|
||||
[QUERY_PARAMS.SORT]: this.bookSorter.selectedSort.field,
|
||||
[QUERY_PARAMS.DIRECTION]: this.bookSorter.selectedSort.direction === SortDirection.ASCENDING ? SORT_DIRECTION.ASCENDING : SORT_DIRECTION.DESCENDING,
|
||||
[QUERY_PARAMS.SIDEBAR]: this.bookFilterComponent.showFilters.toString(),
|
||||
[QUERY_PARAMS.SIDEBAR]: this.showFilter.toString(),
|
||||
[QUERY_PARAMS.FILTER]: Object.entries(parsedFilters).map(([k, v]) => `${k}:${v.join('|')}`).join(',')
|
||||
};
|
||||
|
||||
@@ -613,10 +613,10 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
toggleFilterSidebar() {
|
||||
this.bookFilterComponent.showFilters = !this.bookFilterComponent.showFilters;
|
||||
this.showFilter = !this.showFilter;
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[QUERY_PARAMS.SIDEBAR]: this.bookFilterComponent.showFilters.toString()
|
||||
[QUERY_PARAMS.SIDEBAR]: this.showFilter.toString()
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
replaceUrl: true
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
<h4 class="book-title m-0 pl-2">{{ book.metadata?.title }}</h4>
|
||||
<p-tieredmenu #menu [model]="items" [popup]="true" appendTo="body"></p-tieredmenu>
|
||||
<p-button
|
||||
class="custom-button-padding"
|
||||
size="small"
|
||||
[text]="true"
|
||||
(click)="menu.toggle($event)"
|
||||
|
||||
@@ -176,3 +176,7 @@
|
||||
::ng-deep p-progressbar {
|
||||
--p-progressbar-border-radius: 0 !important;
|
||||
}
|
||||
|
||||
::ng-deep .custom-button-padding .p-button {
|
||||
padding-block: 0.25rem !important;
|
||||
}
|
||||
|
||||
+22
-29
@@ -1,5 +1,7 @@
|
||||
@if (showFilters) {
|
||||
<div class="w-[225px] ml-4 h-[calc(100vh-6.1rem)] rounded-xl bg-[var(--card-background)] overflow-hidden">
|
||||
@if (showFilter) {
|
||||
<div
|
||||
class="h-[calc(100vh-6.1rem)] rounded-xl bg-[var(--card-background)]">
|
||||
|
||||
<div class="flex items-center justify-between px-4 py-4">
|
||||
<span class="text font-semibold">Filter Mode</span>
|
||||
<p-selectButton
|
||||
@@ -11,42 +13,33 @@
|
||||
allowEmpty="false"
|
||||
styleClass="h-8"></p-selectButton>
|
||||
</div>
|
||||
|
||||
<p-accordion [value]="expandedPanels">
|
||||
@for (filterType of filterTypes; track filterType; let i = $index) {
|
||||
<p-accordion-panel [value]="i">
|
||||
<p-accordion-header>
|
||||
<span class="inline-flex items-center gap-1">
|
||||
{{ filterLabels[filterType] || (filterType | titlecase) }}
|
||||
@if (activeFilters[filterType]?.length) {
|
||||
<span class="text-sm text-[var(--primary-color)]">
|
||||
({{ activeFilters[filterType].length }})
|
||||
</span>
|
||||
}
|
||||
</span>
|
||||
<span class="inline-flex items-center gap-1">
|
||||
{{ filterLabels[filterType] || (filterType | titlecase) }}
|
||||
@if (activeFilters[filterType]?.length) {
|
||||
<span class="text-sm text-[var(--primary-color)]">
|
||||
({{ activeFilters[filterType].length }})
|
||||
</span>
|
||||
}
|
||||
</span>
|
||||
</p-accordion-header>
|
||||
|
||||
<p-accordion-content class="h-[27.5rem] !overflow-y-auto">
|
||||
@if (filterStreams[filterType] | async; as filters) {
|
||||
<div>
|
||||
@for (filter of filters; track filter) {
|
||||
<div>
|
||||
<div
|
||||
class="cursor-pointer transition-colors duration-200 ease-in-out pb-1 flex items-center gap-2"
|
||||
[ngClass]="{
|
||||
'text-[var(--primary-color)]':
|
||||
activeFilters[filterType]?.includes(filter.value?.id || filter.value)
|
||||
}"
|
||||
(click)="handleFilterClick(filterType, filter.value?.id || filter.value)">
|
||||
<p-badge [value]="filter.bookCount"></p-badge>
|
||||
@if (filterType === 'amazonRating') {
|
||||
@if (filterType === 'amazonRating') {
|
||||
<span>{{ filter.value.name }}</span>
|
||||
} @else {
|
||||
{{ filter.value.name || filter.value }}
|
||||
}
|
||||
} @else {
|
||||
{{ filter.value.name || filter.value }}
|
||||
}
|
||||
</div>
|
||||
<div class="cursor-pointer transition-colors duration-200 ease-in-out pb-1 flex items-center gap-2"
|
||||
[ngClass]="{
|
||||
'text-[var(--primary-color)]':
|
||||
activeFilters[filterType]?.includes(filter.value?.id || filter.value)
|
||||
}"
|
||||
(click)="handleFilterClick(filterType, filter.value?.id || filter.value)">
|
||||
<p-badge [value]="filter.bookCount"></p-badge>
|
||||
{{ filter.value.name || filter.value }}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -147,10 +147,10 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
@Output() filterSelected = new EventEmitter<Record<string, any> | null>();
|
||||
@Output() filterModeChanged = new EventEmitter<'and' | 'or'>();
|
||||
|
||||
@Input() showFilters: boolean = true;
|
||||
@Input() entity$!: Observable<Library | Shelf | null> | undefined;
|
||||
@Input() entityType$!: Observable<EntityType> | undefined;
|
||||
@Input() resetFilter$!: Subject<void>;
|
||||
@Input() showFilter: boolean = false;
|
||||
|
||||
activeFilters: Record<string, any> = {};
|
||||
filterStreams: Record<string, Observable<Filter<any>[]>> = {};
|
||||
|
||||
@@ -65,14 +65,13 @@ export class SeriesCollapseFilter implements BookFilter {
|
||||
collapsedBooks.push(book);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (const [seriesName, group] of seriesMap.entries()) {
|
||||
const sortedGroup = group.slice().sort((a, b) => {
|
||||
const aNum = a.metadata?.seriesNumber ?? Number.MAX_VALUE;
|
||||
const bNum = b.metadata?.seriesNumber ?? Number.MAX_VALUE;
|
||||
return aNum - bNum;
|
||||
});
|
||||
|
||||
const firstBook = sortedGroup[0];
|
||||
collapsedBooks.push({
|
||||
...firstBook,
|
||||
@@ -80,7 +79,7 @@ export class SeriesCollapseFilter implements BookFilter {
|
||||
});
|
||||
}
|
||||
|
||||
return { ...bookState, books: collapsedBooks };
|
||||
return {...bookState, books: collapsedBooks};
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user