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:
+24
@@ -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">
|
||||
|
||||
+20
@@ -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;
|
||||
|
||||
+13
@@ -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 }
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
+21
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user