From 3f3beaf86bc78cda1bf90bb21e768d675b788938 Mon Sep 17 00:00:00 2001
From: Alex <25013571+alexhb1@users.noreply.github.com>
Date: Mon, 4 May 2026 17:56:18 +0100
Subject: [PATCH] refactor(ui): remove mobile-specific grid size controls
(#1105)
---
.../book-browser/book-browser.component.html | 34 +++-----------
.../book-browser/book-browser.component.ts | 47 ++++++++++++++++---
.../grid-density-buttons.component.html | 2 +
.../grid-density-buttons.component.ts | 4 +-
frontend/src/assets/styles/utilities.scss | 7 ++-
5 files changed, 58 insertions(+), 36 deletions(-)
diff --git a/frontend/src/app/features/book/components/book-browser/book-browser.component.html b/frontend/src/app/features/book/components/book-browser/book-browser.component.html
index b78df46d8..d90575145 100644
--- a/frontend/src/app/features/book/components/book-browser/book-browser.component.html
+++ b/frontend/src/app/features/book/components/book-browser/book-browser.component.html
@@ -121,33 +121,13 @@
- @if (isMobile()) {
-
-
{{ t('labels.gridColumns') }}
-
-
-
-
-
-
- } @else {
-
-
{{ t('labels.gridItemSize') }}
-
-
- }
+
+
{{ t('labels.gridItemSize') }}
+
+
this.screenWidth() < this.MOBILE_BREAKPOINT);
+ readonly gridDensitySmallerDisabled = computed(() =>
+ this.isMobile() && this.gridMobileColumnCount() >= MAX_MOBILE_GRID_COLUMNS
+ );
+ readonly gridDensityLargerDisabled = computed(() =>
+ this.isMobile() && this.gridMobileColumnCount() <= MIN_MOBILE_GRID_COLUMNS
+ );
private cardSizeForWidth(width: number): { width: number; height: number } {
const cardWidth = Math.round(width);
@@ -1119,12 +1126,30 @@ export class BookBrowserComponent implements AfterViewInit {
return libraryIds.size === 1;
}
- setMobileColumns(columns: number): void {
+ adjustGridDensity(direction: GridDensityDirection): void {
+ if (this.isMobile()) {
+ this.adjustMobileGridDensity(direction);
+ return;
+ }
+
+ this.adjustDesktopGridDensity(direction);
+ }
+
+ private adjustMobileGridDensity(direction: GridDensityDirection): void {
+ const currentColumns = this.gridMobileColumnCount();
+ const nextColumns = direction === 'smaller'
+ ? currentColumns + 1
+ : currentColumns - 1;
+
+ this.setMobileColumns(this.toMobileGridColumns(nextColumns));
+ }
+
+ private setMobileColumns(columns: number): void {
this.gridMobileColumnCount.set(columns);
this.localStorageService.set(MOBILE_COLUMNS_STORAGE_KEY, columns);
}
- adjustDesktopGridDensity(direction: 'smaller' | 'larger'): void {
+ private adjustDesktopGridDensity(direction: GridDensityDirection): void {
const currentColumns = this.virtualGrid.gridColumns();
const columns = Math.max(1, direction === 'smaller'
? currentColumns + 1
@@ -1143,9 +1168,17 @@ export class BookBrowserComponent implements AfterViewInit {
}
private loadMobileColumnsPreference(): void {
- const saved = this.localStorageService.get(MOBILE_COLUMNS_STORAGE_KEY);
- if (saved !== null && [2, 3, 4].includes(saved)) {
- this.gridMobileColumnCount.set(saved);
+ const saved = this.localStorageService.get(MOBILE_COLUMNS_STORAGE_KEY);
+ if (saved !== null) {
+ this.setMobileColumns(this.toMobileGridColumns(saved));
}
}
+
+ private toMobileGridColumns(value: unknown): number {
+ const columns = Number(value);
+ if (!Number.isFinite(columns)) {
+ return DEFAULT_MOBILE_GRID_COLUMNS;
+ }
+ return Math.min(MAX_MOBILE_GRID_COLUMNS, Math.max(MIN_MOBILE_GRID_COLUMNS, Math.round(columns)));
+ }
}
diff --git a/frontend/src/app/shared/components/grid-density-buttons/grid-density-buttons.component.html b/frontend/src/app/shared/components/grid-density-buttons/grid-density-buttons.component.html
index 0fb046f0b..399e1eda4 100644
--- a/frontend/src/app/shared/components/grid-density-buttons/grid-density-buttons.component.html
+++ b/frontend/src/app/shared/components/grid-density-buttons/grid-density-buttons.component.html
@@ -7,11 +7,13 @@
class="browser-grid-option-btn"
[attr.aria-label]="'common.decreaseCardSize' | transloco"
[title]="'common.decreaseCardSize' | transloco"
+ [disabled]="smallerDisabled()"
(click)="densityChange.emit('smaller')">−
diff --git a/frontend/src/app/shared/components/grid-density-buttons/grid-density-buttons.component.ts b/frontend/src/app/shared/components/grid-density-buttons/grid-density-buttons.component.ts
index 344b5f5ab..93a7845fa 100644
--- a/frontend/src/app/shared/components/grid-density-buttons/grid-density-buttons.component.ts
+++ b/frontend/src/app/shared/components/grid-density-buttons/grid-density-buttons.component.ts
@@ -1,4 +1,4 @@
-import {Component, output} from '@angular/core';
+import {Component, input, output} from '@angular/core';
import {TranslocoPipe} from '@jsverse/transloco';
export type GridDensityDirection = 'smaller' | 'larger';
@@ -10,5 +10,7 @@ export type GridDensityDirection = 'smaller' | 'larger';
templateUrl: './grid-density-buttons.component.html',
})
export class GridDensityButtonsComponent {
+ readonly smallerDisabled = input(false);
+ readonly largerDisabled = input(false);
readonly densityChange = output
();
}
diff --git a/frontend/src/assets/styles/utilities.scss b/frontend/src/assets/styles/utilities.scss
index 96eec62c5..0900972d2 100644
--- a/frontend/src/assets/styles/utilities.scss
+++ b/frontend/src/assets/styles/utilities.scss
@@ -73,10 +73,15 @@
cursor: pointer;
transition: all 0.15s ease;
- &:hover {
+ &:hover:not(:disabled) {
border-color: var(--primary-color);
}
+ &:disabled {
+ cursor: not-allowed;
+ opacity: 0.45;
+ }
+
&.active {
background-color: var(--primary-color);
border-color: var(--primary-color);