feat(cbx-viewer): add (back) infinite and long-strip modes, fixed. (#390)

* feat(cbx-viewer): add (back) infinite and long-strip modes, fixed.

* feat(reader): improve strip width controls and improve continuation affordance

* fix(cbx-reader): clear debounce timer on layout generation changes
This commit is contained in:
brios
2026-04-22 17:27:07 -04:00
committed by Zach Yale
parent 78099cc92c
commit 1db1b8404a
20 changed files with 964 additions and 123 deletions
@@ -94,6 +94,30 @@
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row strip-width-row">
<label class="setting-label" for="cbx-strip-max-width">{{ t('stripMaxWidth') }}</label>
<div class="strip-width-control">
<input
id="cbx-strip-max-width"
type="range"
min="50"
max="100"
step="5"
[value]="selectedCbxStripMaxWidthPercent"
(input)="onStripMaxWidthInput($event)"
[attr.aria-valuetext]="selectedCbxStripMaxWidthPercent + '%'"
/>
<span class="strip-width-value">{{ selectedCbxStripMaxWidthPercent }}%</span>
</div>
</div>
<p class="setting-description">
{{ t('stripMaxWidthDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
@@ -49,6 +49,26 @@
}
}
.strip-width-control {
display: flex;
align-items: center;
gap: 0.75rem;
flex: 1;
min-width: 0;
input[type='range'] {
flex: 1;
min-width: 120px;
max-width: 280px;
}
}
.strip-width-value {
font-size: 0.9rem;
color: var(--p-text-muted-color);
min-width: 2.75rem;
}
.setting-description {
color: var(--p-text-muted-color);
font-size: settings.$settings-section-description-size;
@@ -57,6 +57,7 @@ describe('CbxReaderPreferencesComponent', () => {
expect(component.selectedCbxFitMode).toBe(CbxFitMode.AUTO);
expect(component.selectedCbxScrollMode).toBe(CbxScrollMode.PAGINATED);
expect(component.selectedCbxBackgroundColor).toBe(CbxBackgroundColor.GRAY);
expect(component.selectedCbxStripMaxWidthPercent).toBe(100);
});
it('persists each CBX reader preference through the shared preferences service', () => {
@@ -74,4 +75,16 @@ describe('CbxReaderPreferencesComponent', () => {
expect(updatePreference).toHaveBeenNthCalledWith(4, ['cbxReaderSetting', 'scrollMode'], CbxScrollMode.INFINITE);
expect(updatePreference).toHaveBeenNthCalledWith(5, ['cbxReaderSetting', 'backgroundColor'], CbxBackgroundColor.BLACK);
});
it('persists strip max width with silent preference updates', () => {
const component = fixture.componentInstance;
component.selectedCbxStripMaxWidthPercent = 75;
expect(updatePreference).toHaveBeenCalledWith(
['cbxReaderSetting', 'stripMaxWidthPercent'],
75,
{ silent: true }
);
});
});
@@ -1,6 +1,7 @@
import {Component, inject, Input} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {TranslocoDirective} from '@jsverse/transloco';
import {clampStripMaxWidthPercent} from '../../../readers/cbx-reader/core/cbx-reader-storage';
import {CbxBackgroundColor, CbxFitMode, CbxPageSpread, CbxPageViewMode, CbxScrollMode, UserSettings} from '../../user-management/user.service';
import {ReaderPreferencesService} from '../reader-preferences.service';
import {TooltipModule} from 'primeng/tooltip';
@@ -27,6 +28,7 @@ export class CbxReaderPreferencesComponent {
private static readonly PROP_FIT_MODE = 'fitMode';
private static readonly PROP_SCROLL_MODE = 'scrollMode';
private static readonly PROP_BACKGROUND_COLOR = 'backgroundColor';
private static readonly PROP_STRIP_MAX_WIDTH_PERCENT = 'stripMaxWidthPercent';
readonly cbxSpreads = [
{name: 'Even', key: CbxPageSpread.EVEN, icon: 'pi pi-align-left', translationKey: 'even'},
@@ -102,4 +104,23 @@ export class CbxReaderPreferencesComponent {
this.userSettings.cbxReaderSetting.backgroundColor = value;
this.readerPreferencesService.updatePreference([CbxReaderPreferencesComponent.SETTING_ROOT, CbxReaderPreferencesComponent.PROP_BACKGROUND_COLOR], value);
}
get selectedCbxStripMaxWidthPercent(): number {
return clampStripMaxWidthPercent(this.userSettings.cbxReaderSetting.stripMaxWidthPercent);
}
set selectedCbxStripMaxWidthPercent(value: number) {
const v = clampStripMaxWidthPercent(value);
this.userSettings.cbxReaderSetting.stripMaxWidthPercent = v;
this.readerPreferencesService.updatePreference(
[CbxReaderPreferencesComponent.SETTING_ROOT, CbxReaderPreferencesComponent.PROP_STRIP_MAX_WIDTH_PERCENT],
v,
{ silent: true }
);
}
onStripMaxWidthInput(event: Event): void {
const input = event.target as HTMLInputElement;
this.selectedCbxStripMaxWidthPercent = Number(input.value);
}
}
@@ -21,7 +21,7 @@ export class ReaderPreferencesService {
});
}
updatePreference(path: string[], value: unknown): void {
updatePreference(path: string[], value: unknown, options?: { silent?: boolean }): void {
if (!this.currentUser) return;
let target = this.currentUser.userSettings as unknown as MutableSettingsBranch;
@@ -38,11 +38,13 @@ export class ReaderPreferencesService {
const updatedValue = this.currentUser.userSettings[rootKey as keyof UserSettings];
this.userService.updateUserSetting(this.currentUser.id, rootKey, updatedValue);
this.messageService.add({
severity: 'success',
summary: this.t.translate('settingsReader.toast.preferencesUpdated'),
detail: this.t.translate('settingsReader.toast.preferencesUpdatedDetail'),
life: 2000
});
if (!options?.silent) {
this.messageService.add({
severity: 'success',
summary: this.t.translate('settingsReader.toast.preferencesUpdated'),
detail: this.t.translate('settingsReader.toast.preferencesUpdatedDetail'),
life: 2000
});
}
}
}
@@ -210,6 +210,8 @@ export interface CbxReaderSetting {
emulateBook?: boolean;
clickToPaginate?: boolean;
autoCloseMenu?: boolean;
/** 50–100: max width % of reader for infinite / long-strip (global setting). */
stripMaxWidthPercent?: number;
}
export interface TableColumnPreference {