Progressive UI Refinements for Mobile and Desktop Layouts

This commit is contained in:
aditya.chandel
2025-07-19 15:43:49 -06:00
committed by Aditya Chandel
parent fe2d307d2a
commit 06e58233b1
22 changed files with 275 additions and 238 deletions
@@ -1,7 +1,7 @@
<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 justify-between w-full gap-4 py-2 px-2 md:px-4 rounded-t-xl md:mb-4 mb-2 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-xl whitespace-nowrap overflow-hidden text-ellipsis w-full">
@@ -252,40 +252,38 @@
</div>
}
@if (bookState?.books; as books) {
<div class="book-card-container">
@if (currentViewMode === 'table' && books.length > 0) {
<app-book-table
[books]="books"
(selectedBooksChange)="onSelectedBooksChange($event)"
[sortOption]="this.bookSorter.selectedSort!"
[visibleColumns]="visibleColumns"
></app-book-table>
}
@if (currentViewMode === 'grid') {
<virtual-scroller class="virtual-scroller" #scroll [items]="books">
<div
class="grid"
#container
[ngStyle]="{'grid-template-columns': 'repeat(auto-fill, minmax(' + gridColumnMinWidth + ', 1fr))'}">
@for (book of scroll.viewPortItems; let i = $index; track book) {
<div
class="virtual-scroller-item relative"
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
<app-book-card
[index]="i"
[book]="book"
[isCheckboxEnabled]="true"
[onBookSelect]="handleBookSelect.bind(this)"
[isSeriesCollapsed]="seriesCollapseFilter.isSeriesCollapsed"
(checkboxClick)="onCheckboxClicked($event)"
[isSelected]="selectedBooks.has(book.id)">
</app-book-card>
</div>
}
</div>
</virtual-scroller>
}
</div>
@if (currentViewMode === 'table' && books.length > 0) {
<app-book-table
[books]="books"
(selectedBooksChange)="onSelectedBooksChange($event)"
[sortOption]="this.bookSorter.selectedSort!"
[visibleColumns]="visibleColumns"
></app-book-table>
}
@if (currentViewMode === 'grid') {
<virtual-scroller class="virtual-scroller" #scroll [items]="books">
<div
class="grid"
#container
[ngStyle]="{'grid-template-columns': 'repeat(auto-fill, minmax(' + gridColumnMinWidth + ', 1fr))'}">
@for (book of scroll.viewPortItems; let i = $index; track book) {
<div
class="virtual-scroller-item relative"
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
<app-book-card
[index]="i"
[book]="book"
[isCheckboxEnabled]="true"
[onBookSelect]="handleBookSelect.bind(this)"
[isSeriesCollapsed]="seriesCollapseFilter.isSeriesCollapsed"
(checkboxClick)="onCheckboxClicked($event)"
[isSelected]="selectedBooks.has(book.id)">
</app-book-card>
</div>
}
</div>
</virtual-scroller>
}
}
@if (selectedBooks.size > 0) {
@if (userService.userState$ | async; as userData) {
@@ -18,6 +18,12 @@
overflow-y: auto;
}
@media (max-width: 768px) {
.virtual-scroller {
height: calc(100dvh - 9rem);
}
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(1px, 1fr));
@@ -10,7 +10,7 @@
showGridlines
stripedRows
[scrollable]="true"
[scrollHeight]="'calc(100dvh - 160px)'"
[scrollHeight]="scrollHeight"
[virtualScroll]="true"
[virtualScrollItemSize]="46"
[(selection)]="selectedBooks"
@@ -70,6 +70,8 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
{field: 'hardcoverReviewCount', header: 'HC #'}
];
scrollHeight = 'calc(100dvh - 160px)';
ngOnInit(): void {
this.userService.userState$
.pipe(
@@ -79,6 +81,16 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
.subscribe(user => {
this.metadataCenterViewMode = user?.userSettings.metadataCenterViewMode ?? 'route';
});
this.setScrollHeight();
window.addEventListener('resize', this.setScrollHeight.bind(this));
}
setScrollHeight() {
const isMobile = window.innerWidth <= 768;
this.scrollHeight = isMobile
? 'calc(100dvh - 125px)'
: 'calc(100dvh - 150px)';
}
ngOnChanges() {
@@ -255,5 +267,6 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
window.removeEventListener('resize', this.setScrollHeight.bind(this));
}
}