refactor(frontend): rename booklore-ui to frontend

- Frontend path:
  - rename the tracked Angular app tree from `booklore-ui/` to `frontend/`
  - preserve file contents during the move so this commit stays focused on the path change itself
- Frontend docs:
  - update the moved frontend README and contribution guide where they refer to the renamed folder
  - keep those edits limited to path references introduced by the directory rename
This commit is contained in:
James Cox
2026-04-22 17:26:39 -04:00
committed by Zach Yale
parent c99aa87877
commit 874b013f75
1493 changed files with 3 additions and 3 deletions
@@ -0,0 +1,125 @@
<ng-container *transloco="let t; prefix: 'settingsReader.cbx'">
<div class="cbx-preferences-container">
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('pageSpread') }}</label>
<div class="button-group">
@for (spread of cbxSpreads; track spread) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxSpread === spread.key"
(click)="selectedCbxSpread = spread.key">
<i [class]="spread.icon"></i>
<span class="option-text">{{ t(spread.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('pageSpreadDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('pageLayout') }}</label>
<div class="button-group">
@for (mode of cbxViewModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxViewMode === mode.key"
(click)="selectedCbxViewMode = mode.key">
<i [class]="mode.icon"></i>
<span class="option-text">{{ t(mode.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('pageLayoutDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('fitMode') }}</label>
<div class="button-group">
@for (mode of cbxFitModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxFitMode === mode.key"
(click)="selectedCbxFitMode = mode.key"
[pTooltip]="t(mode.translationKey)"
tooltipPosition="bottom">
<i [class]="mode.icon"></i>
<span class="option-text">{{ t(mode.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('fitModeDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('scrollMode') }}</label>
<div class="button-group">
@for (mode of cbxScrollModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxScrollMode === mode.key"
(click)="selectedCbxScrollMode = mode.key">
<i [class]="mode.icon"></i>
<span class="option-text">{{ t(mode.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('scrollModeDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('backgroundColor') }}</label>
<div class="theme-selector">
@for (color of cbxBackgroundColors; track color) {
<button
type="button"
class="theme-option"
[class.selected]="selectedCbxBackgroundColor === color.key"
[style.background-color]="color.color"
(click)="selectedCbxBackgroundColor = color.key"
[attr.aria-label]="t(color.translationKey)"
[pTooltip]="t(color.translationKey)"
tooltipPosition="bottom">
@if (selectedCbxBackgroundColor === color.key) {
<i class="pi pi-check"></i>
}
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('backgroundColorDesc') }}
</p>
</div>
</div>
</div>
</ng-container>
@@ -0,0 +1,98 @@
@use '../../../../shared/styles/settings-shared' as settings;
.cbx-preferences-container {
display: flex;
flex-direction: column;
gap: 1rem;
}
.setting-item {
display: flex;
align-items: flex-start;
gap: 2rem;
padding: 0.25rem 0;
&:last-child {
border-bottom: none;
padding-bottom: 0;
}
@media (max-width: 768px) {
flex-direction: column;
gap: 1rem;
}
}
.setting-info {
flex: 1;
min-width: 0;
.setting-label {
display: block;
font-weight: settings.$settings-section-title-weight;
color: var(--p-text-color);
font-size: 1rem;
margin-bottom: 0.5rem;
}
.setting-label-row {
display: flex;
align-items: center;
gap: 1rem;
margin-bottom: 0.5rem;
flex-wrap: wrap;
.setting-label {
margin-bottom: 0;
flex-shrink: 0;
min-width: 100px;
}
}
.setting-description {
color: var(--p-text-muted-color);
font-size: settings.$settings-section-description-size;
line-height: 1.5;
margin: 0;
}
}
.button-group {
@include settings.settings-button-group;
}
.theme-selector {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
.theme-option {
width: 2.5rem;
height: 2.5rem;
border-radius: 0.375rem;
border: 1.5px solid transparent;
cursor: pointer;
transition: all 0.2s ease;
position: relative;
display: flex;
align-items: center;
justify-content: center;
i {
color: white;
font-size: settings.$settings-section-description-size;
font-weight: bold;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
&:hover {
transform: scale(1.1);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
&.selected {
border-color: var(--primary-color);
box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-color) 25%, transparent);
}
}
}
@@ -0,0 +1,104 @@
import {Component, inject, Input} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {TranslocoDirective} from '@jsverse/transloco';
import {CbxBackgroundColor, CbxFitMode, CbxPageSpread, CbxPageViewMode, CbxScrollMode, UserSettings} from '../../user-management/user.service';
import {ReaderPreferencesService} from '../reader-preferences.service';
import {TooltipModule} from 'primeng/tooltip';
@Component({
selector: 'app-cbx-reader-preferences-component',
imports: [
FormsModule,
TranslocoDirective,
TooltipModule
],
templateUrl: './cbx-reader-preferences-component.html',
styleUrl: './cbx-reader-preferences-component.scss'
})
export class CbxReaderPreferencesComponent {
@Input() userSettings!: UserSettings;
private readonly readerPreferencesService = inject(ReaderPreferencesService);
private static readonly SETTING_ROOT = 'cbxReaderSetting';
private static readonly PROP_PAGE_SPREAD = 'pageSpread';
private static readonly PROP_PAGE_VIEW_MODE = 'pageViewMode';
private static readonly PROP_FIT_MODE = 'fitMode';
private static readonly PROP_SCROLL_MODE = 'scrollMode';
private static readonly PROP_BACKGROUND_COLOR = 'backgroundColor';
readonly cbxSpreads = [
{name: 'Even', key: CbxPageSpread.EVEN, icon: 'pi pi-align-left', translationKey: 'even'},
{name: 'Odd', key: CbxPageSpread.ODD, icon: 'pi pi-align-right', translationKey: 'odd'}
];
readonly cbxViewModes = [
{name: 'Single Page', key: CbxPageViewMode.SINGLE_PAGE, icon: 'pi pi-book', translationKey: 'singlePage'},
{name: 'Two Page', key: CbxPageViewMode.TWO_PAGE, icon: 'pi pi-copy', translationKey: 'twoPage'},
];
readonly cbxFitModes = [
{name: 'Fit Page', key: CbxFitMode.FIT_PAGE, icon: 'pi pi-window-maximize', translationKey: 'fitPage'},
{name: 'Fit Width', key: CbxFitMode.FIT_WIDTH, icon: 'pi pi-arrows-h', translationKey: 'fitWidth'},
{name: 'Fit Height', key: CbxFitMode.FIT_HEIGHT, icon: 'pi pi-arrows-v', translationKey: 'fitHeight'},
{name: 'Actual Size', key: CbxFitMode.ACTUAL_SIZE, icon: 'pi pi-expand', translationKey: 'actualSize'},
{name: 'Automatic', key: CbxFitMode.AUTO, icon: 'pi pi-sparkles', translationKey: 'automatic'}
];
readonly cbxScrollModes = [
{name: 'Paginated', key: CbxScrollMode.PAGINATED, icon: 'pi pi-book', translationKey: 'paginated'},
{name: 'Infinite', key: CbxScrollMode.INFINITE, icon: 'pi pi-sort-alt', translationKey: 'infinite'}
];
readonly cbxBackgroundColors = [
{name: 'Gray', key: CbxBackgroundColor.GRAY, color: '#808080', translationKey: 'gray'},
{name: 'Black', key: CbxBackgroundColor.BLACK, color: '#000000', translationKey: 'black'},
{name: 'White', key: CbxBackgroundColor.WHITE, color: '#FFFFFF', translationKey: 'white'}
];
get selectedCbxSpread(): CbxPageSpread {
return this.userSettings.cbxReaderSetting.pageSpread ?? CbxPageSpread.EVEN;
}
set selectedCbxSpread(value: CbxPageSpread) {
this.userSettings.cbxReaderSetting.pageSpread = value;
this.readerPreferencesService.updatePreference([CbxReaderPreferencesComponent.SETTING_ROOT, CbxReaderPreferencesComponent.PROP_PAGE_SPREAD], value);
}
get selectedCbxViewMode(): CbxPageViewMode {
return this.userSettings.cbxReaderSetting.pageViewMode ?? CbxPageViewMode.SINGLE_PAGE;
}
set selectedCbxViewMode(value: CbxPageViewMode) {
this.userSettings.cbxReaderSetting.pageViewMode = value;
this.readerPreferencesService.updatePreference([CbxReaderPreferencesComponent.SETTING_ROOT, CbxReaderPreferencesComponent.PROP_PAGE_VIEW_MODE], value);
}
get selectedCbxFitMode(): CbxFitMode {
return this.userSettings.cbxReaderSetting.fitMode ?? CbxFitMode.FIT_PAGE;
}
set selectedCbxFitMode(value: CbxFitMode) {
this.userSettings.cbxReaderSetting.fitMode = value;
this.readerPreferencesService.updatePreference([CbxReaderPreferencesComponent.SETTING_ROOT, CbxReaderPreferencesComponent.PROP_FIT_MODE], value);
}
get selectedCbxScrollMode(): CbxScrollMode {
return this.userSettings.cbxReaderSetting.scrollMode ?? CbxScrollMode.PAGINATED;
}
set selectedCbxScrollMode(value: CbxScrollMode) {
this.userSettings.cbxReaderSetting.scrollMode = value;
this.readerPreferencesService.updatePreference([CbxReaderPreferencesComponent.SETTING_ROOT, CbxReaderPreferencesComponent.PROP_SCROLL_MODE], value);
}
get selectedCbxBackgroundColor(): CbxBackgroundColor {
return this.userSettings.cbxReaderSetting.backgroundColor ?? CbxBackgroundColor.GRAY;
}
set selectedCbxBackgroundColor(value: CbxBackgroundColor) {
this.userSettings.cbxReaderSetting.backgroundColor = value;
this.readerPreferencesService.updatePreference([CbxReaderPreferencesComponent.SETTING_ROOT, CbxReaderPreferencesComponent.PROP_BACKGROUND_COLOR], value);
}
}
@@ -0,0 +1,291 @@
<ng-container *transloco="let t; prefix: 'settingsReader.ebook'">
<div class="epub-preferences-container">
<div class="settings-group">
<h3 class="group-title">{{ t('appearance') }}</h3>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('theme') }}</label>
<div class="theme-selector">
@for (theme of themes; track theme) {
<button
type="button"
class="theme-option"
[class.selected]="selectedTheme === theme.name"
(click)="selectedTheme = theme.name"
[attr.aria-label]="theme.label"
[pTooltip]="theme.label"
tooltipPosition="bottom">
<span class="theme-colors">
<span class="theme-color" [style.background-color]="theme.light.bg"></span>
<span class="theme-color" [style.background-color]="theme.dark.bg"></span>
</span>
@if (selectedTheme === theme.name) {
<i class="pi pi-check"></i>
}
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('themeDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('darkMode') }}</label>
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="!isDark"
(click)="isDark = false">
<i class="pi pi-sun"></i>
<span class="option-text">{{ t('light') }}</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="isDark"
(click)="isDark = true">
<i class="pi pi-moon"></i>
<span class="option-text">{{ t('dark') }}</span>
</button>
</div>
</div>
<p class="setting-description">
{{ t('darkModeDesc') }}
</p>
</div>
</div>
</div>
<div class="settings-group">
<h3 class="group-title">{{ t('typography') }}</h3>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('fontFamily') }}</label>
<div class="button-group">
@for (font of fonts; track font) {
<button
type="button"
class="option-button font-button"
[class.selected]="selectedFont === font.key"
[class.separator]="font.key === 'separator'"
[attr.data-font]="font.key"
[disabled]="font.key === 'separator'"
(click)="selectedFont = font.key"
[pTooltip]="font.name"
tooltipPosition="bottom">
<span class="option-text" [style.font-family]="font.key && font.key.startsWith('custom:') ? getCustomFontName(font.key) : null">
{{ font.displayName }}
</span>
</button>
}
@if (!customFontsReady) {
<p-skeleton width="3.5rem" height="2.5rem" borderRadius="6px"></p-skeleton>
}
</div>
</div>
<p class="setting-description">
{{ t('fontFamilyDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('fontSize') }}</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseFontSize()"></p-button>
<span class="font-size-value">{{ fontSize }}pt</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseFontSize()"></p-button>
</div>
</div>
<p class="setting-description">
{{ t('fontSizeDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('lineHeight') }}</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseLineHeight()"></p-button>
<span class="font-size-value">{{ lineHeight.toFixed(1) }}</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseLineHeight()"></p-button>
</div>
</div>
<p class="setting-description">
{{ t('lineHeightDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('textJustification') }}</label>
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="!justify"
(click)="justify = false">
<i class="pi pi-align-left"></i>
<span class="option-text">{{ t('left') }}</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="justify"
(click)="justify = true">
<i class="pi pi-align-justify"></i>
<span class="option-text">{{ t('justified') }}</span>
</button>
</div>
</div>
<p class="setting-description">
{{ t('textJustificationDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('hyphenation') }}</label>
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="!hyphenate"
(click)="hyphenate = false">
<i class="pi pi-times"></i>
<span class="option-text">{{ t('off') }}</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="hyphenate"
(click)="hyphenate = true">
<i class="pi pi-check"></i>
<span class="option-text">{{ t('on') }}</span>
</button>
</div>
</div>
<p class="setting-description">
{{ t('hyphenationDesc') }}
</p>
</div>
</div>
</div>
<div class="settings-group">
<h3 class="group-title">{{ t('layout') }}</h3>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('flow') }}</label>
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="flow === 'paginated'"
(click)="flow = 'paginated'">
<i class="pi pi-clone"></i>
<span class="option-text">{{ t('paginated') }}</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="flow === 'scrolled'"
(click)="flow = 'scrolled'">
<i class="pi pi-arrows-v"></i>
<span class="option-text">{{ t('scrolled') }}</span>
</button>
</div>
</div>
<p class="setting-description">
{{ t('flowDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('maxColumns') }}</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="maxColumnCount = maxColumnCount > 1 ? maxColumnCount - 1 : 1"></p-button>
<span class="font-size-value">{{ maxColumnCount }}</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="maxColumnCount = maxColumnCount < 4 ? maxColumnCount + 1 : 4"></p-button>
</div>
</div>
<p class="setting-description">
{{ t('maxColumnsDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('columnGap') }}</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseGap()"></p-button>
<span class="font-size-value">{{ gap * 100 | number : '1.0-0' }}%</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseGap()"></p-button>
</div>
</div>
<p class="setting-description">
{{ t('columnGapDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('maxWidth') }}</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseMaxInlineSize()"></p-button>
<span class="font-size-value">{{ maxInlineSize }}px</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseMaxInlineSize()"></p-button>
</div>
</div>
<p class="setting-description">
{{ t('maxWidthDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('maxHeight') }}</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseMaxBlockSize()"></p-button>
<span class="font-size-value">{{ maxBlockSize }}px</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseMaxBlockSize()"></p-button>
</div>
</div>
<p class="setting-description">
{{ t('maxHeightDesc') }}
</p>
</div>
</div>
</div>
</div>
</ng-container>
@@ -0,0 +1,237 @@
@use '../../../../shared/styles/settings-shared' as settings;
.epub-preferences-container {
display: flex;
flex-direction: column;
gap: 2rem;
}
.settings-group {
display: flex;
flex-direction: column;
gap: 1rem;
padding: 1.5rem;
border-radius: 0.75rem;
border: 1px solid color-mix(in srgb, var(--text-color) 10%, transparent);
.group-title {
font-size: settings.$settings-section-title-size;
font-weight: settings.$settings-section-title-weight;
color: var(--p-text-color);
margin: 0 0 0.5rem 0;
padding-bottom: 0.75rem;
border-bottom: 1px solid color-mix(in srgb, var(--text-color) 10%, transparent);
}
}
.setting-item {
display: flex;
align-items: flex-start;
gap: 2rem;
padding: 0.25rem 0;
&:last-child {
border-bottom: none;
padding-bottom: 0;
}
@media (max-width: 768px) {
flex-direction: column;
gap: 1rem;
}
}
.setting-info {
flex: 1;
min-width: 0;
.setting-label {
display: block;
font-weight: settings.$settings-section-title-weight;
color: var(--p-text-color);
font-size: 1rem;
margin-bottom: 0.5rem;
}
.setting-label-row {
display: flex;
align-items: center;
gap: 1rem;
margin-bottom: 0.5rem;
flex-wrap: wrap;
.setting-label {
margin-bottom: 0;
flex-shrink: 0;
min-width: 100px;
}
}
.setting-description {
color: var(--p-text-muted-color);
font-size: settings.$settings-section-description-size;
line-height: 1.5;
margin: 0;
}
}
.radio-group {
display: flex;
gap: 1.5rem;
@media (max-width: 768px) {
flex-direction: column;
gap: 0.75rem;
}
}
.radio-option {
display: flex;
align-items: center;
gap: 0.5rem;
label {
font-size: settings.$settings-section-description-size;
color: var(--p-text-color);
cursor: pointer;
}
}
.font-size-controls {
display: flex;
align-items: center;
gap: 0.5rem;
.font-size-value {
min-width: 3rem;
text-align: center;
font-weight: settings.$settings-label-weight;
color: var(--p-text-color);
}
}
.theme-selector {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
.theme-option {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.5rem;
background: color-mix(in srgb, var(--text-color) 5%, transparent);
color: var(--text-color);
cursor: pointer;
transition: all 0.2s ease;
position: relative;
min-width: 48px;
.theme-colors {
display: flex;
gap: 0;
padding: 0;
border-radius: 0.5rem;
overflow: hidden;
border: 2px solid color-mix(in srgb, var(--text-color) 20%, transparent);
box-sizing: border-box;
width: 72px;
height: 36px;
background: none;
}
.theme-color {
width: 36px;
height: 36px;
display: inline-block;
border-radius: 0;
border: none;
margin: 0;
padding: 0;
}
i {
position: absolute;
top: 4px;
right: 4px;
font-size: 0.75rem;
color: var(--primary-color);
margin-left: 0;
padding-left: 0;
}
&:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
.theme-colors {
border-color: color-mix(in srgb, var(--primary-color) 40%, transparent);
}
}
&.selected {
.theme-colors {
border-color: var(--primary-color);
box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-color) 15%, transparent);
}
color: var(--primary-color);
background: color-mix(in srgb, var(--primary-color) 10%, transparent);
&:hover {
transform: translateY(-2px);
}
}
}
}
.button-group {
@include settings.settings-button-group;
.option-button {
&.font-button {
font-size: 1rem;
&[data-font="serif"] .option-text {
font-family: Georgia, 'Times New Roman', serif;
}
&[data-font="sans-serif"] .option-text {
font-family: Arial, Helvetica, sans-serif;
}
&[data-font="roboto"] .option-text {
font-family: 'Roboto', sans-serif;
}
&[data-font="cursive"] .option-text {
font-family: cursive;
}
&[data-font="monospace"] .option-text {
font-family: 'Courier New', monospace;
}
// Custom font buttons use the loaded font
&[data-font^="custom:"] .option-text {
font-size: settings.$settings-section-description-size;
}
}
&.separator {
cursor: default;
pointer-events: none;
opacity: 0.6;
background: transparent;
border-color: transparent;
font-weight: settings.$settings-section-title-weight;
color: var(--p-text-muted-color);
min-width: auto;
padding: 0.25rem 0.5rem;
&:hover {
transform: none;
box-shadow: none;
}
}
}
}
@@ -0,0 +1,299 @@
import {DecimalPipe} from '@angular/common';
import {Component, effect, inject, Input, OnDestroy, OnInit} from '@angular/core';
import {Button} from 'primeng/button';
import {FormsModule} from '@angular/forms';
import {TranslocoDirective} from '@jsverse/transloco';
import {ReaderPreferencesService} from '../reader-preferences.service';
import {UserSettings} from '../../user-management/user.service';
import {Tooltip} from 'primeng/tooltip';
import {CustomFontService} from '../../../../shared/service/custom-font.service';
import {CustomFont} from '../../../../shared/model/custom-font.model';
import {skip, Subject, takeUntil} from 'rxjs';
import {addCustomFontsToDropdown} from '../../../../shared/util/custom-font.util';
import {Skeleton} from 'primeng/skeleton';
import {themes} from '../../../readers/ebook-reader/state/themes.constant';
@Component({
selector: 'app-epub-reader-preferences-component',
imports: [
Button,
DecimalPipe,
FormsModule,
TranslocoDirective,
Tooltip,
Skeleton
],
templateUrl: './epub-reader-preferences-component.html',
styleUrl: './epub-reader-preferences-component.scss'
})
export class EpubReaderPreferencesComponent implements OnInit, OnDestroy {
@Input() userSettings!: UserSettings;
private readonly readerPreferencesService = inject(ReaderPreferencesService);
private readonly customFontService = inject(CustomFontService);
private readonly destroy$ = new Subject<void>();
customFonts: CustomFont[] = [];
fonts = [
{name: 'Book Default', displayName: 'Default', key: null},
{name: 'Serif', displayName: 'Serif', key: 'serif'},
{name: 'Sans Serif', displayName: 'Sans Serif', key: 'sans-serif'},
{name: 'Roboto', displayName: 'Roboto', key: 'roboto'},
{name: 'Cursive', displayName: 'Cursive', key: 'cursive'},
{name: 'Monospace', displayName: 'Monospace', key: 'monospace'}
];
readonly themes = themes;
customFontsReady = false;
private readonly syncFontsEffect = effect(() => {
const fonts = this.customFontService.fonts();
if (fonts.length > 0 || !this.customFontService.isFontsLoading()) {
this.customFontsReady = true;
}
if (this.hasCustomFontsChanged(fonts)) {
this.onFontsChanged(fonts);
}
});
ngOnInit(): void {
}
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
}
private async onFontsChanged(fonts: CustomFont[]): Promise<void> {
try {
const selectedFontDeleted = this.isCurrentlySelectedFontDeleted(fonts);
this.customFonts = fonts;
await this.customFontService.loadAllFonts(fonts);
this.updateFontsDropdown(fonts);
if (selectedFontDeleted) {
this.resetToDefaultFont();
}
} catch (err) {
console.error('Failed to process custom fonts:', err);
}
}
private hasCustomFontsChanged(newFonts: CustomFont[]): boolean {
if (newFonts.length !== this.customFonts.length) {
return true;
}
const newIds = new Set(newFonts.map(f => f.id));
const currentIds = new Set(this.customFonts.map(f => f.id));
return newFonts.some(f => !currentIds.has(f.id)) || this.customFonts.some(f => !newIds.has(f.id));
}
private updateFontsDropdown(fonts: CustomFont[]): void {
this.fonts = this.fonts.filter(font => !font.key || !font.key.startsWith('custom:'));
addCustomFontsToDropdown(fonts, this.fonts, 'preference');
}
private isCurrentlySelectedFontDeleted(newFonts: CustomFont[]): boolean {
const fontFamily = this.userSettings.ebookReaderSetting.fontFamily;
if (!fontFamily || !fontFamily.startsWith('custom:')) {
return false;
}
const fontId = fontFamily.split(':')[1];
const fontStillExists = newFonts.some(font => font.id === parseInt(fontId, 10));
return !fontStillExists;
}
private resetToDefaultFont(): void {
console.log('Selected custom font was deleted, resetting to default font');
this.selectedFont = null;
}
get selectedTheme(): string | null {
return this.userSettings.ebookReaderSetting.theme;
}
set selectedTheme(value: string | null) {
if (typeof value === "string") {
this.userSettings.ebookReaderSetting.theme = value;
}
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'theme'], value);
}
get selectedFont(): string | null {
return this.userSettings.ebookReaderSetting.fontFamily;
}
set selectedFont(value: string | null) {
if (typeof value === "string") {
this.userSettings.ebookReaderSetting.fontFamily = value;
} else {
this.userSettings.ebookReaderSetting.fontFamily = null as any;
}
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'fontFamily'], value);
}
get fontSize(): number {
return this.userSettings.ebookReaderSetting.fontSize;
}
set fontSize(value: number) {
this.userSettings.ebookReaderSetting.fontSize = value;
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'fontSize'], value);
}
get lineHeight(): number {
return this.userSettings.ebookReaderSetting.lineHeight;
}
set lineHeight(value: number) {
this.userSettings.ebookReaderSetting.lineHeight = value;
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'lineHeight'], value);
}
get justify(): boolean {
return this.userSettings.ebookReaderSetting.justify;
}
set justify(value: boolean) {
this.userSettings.ebookReaderSetting.justify = value;
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'justify'], value);
}
get hyphenate(): boolean {
return this.userSettings.ebookReaderSetting.hyphenate;
}
set hyphenate(value: boolean) {
this.userSettings.ebookReaderSetting.hyphenate = value;
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'hyphenate'], value);
}
get maxColumnCount(): number {
return this.userSettings.ebookReaderSetting.maxColumnCount;
}
set maxColumnCount(value: number) {
this.userSettings.ebookReaderSetting.maxColumnCount = value;
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'maxColumnCount'], value);
}
get gap(): number {
return this.userSettings.ebookReaderSetting.gap;
}
set gap(value: number) {
this.userSettings.ebookReaderSetting.gap = value;
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'gap'], value);
}
get maxInlineSize(): number {
return this.userSettings.ebookReaderSetting.maxInlineSize;
}
set maxInlineSize(value: number) {
this.userSettings.ebookReaderSetting.maxInlineSize = value;
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'maxInlineSize'], value);
}
get maxBlockSize(): number {
return this.userSettings.ebookReaderSetting.maxBlockSize;
}
set maxBlockSize(value: number) {
this.userSettings.ebookReaderSetting.maxBlockSize = value;
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'maxBlockSize'], value);
}
get isDark(): boolean {
return this.userSettings.ebookReaderSetting.isDark;
}
set isDark(value: boolean) {
this.userSettings.ebookReaderSetting.isDark = value;
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'isDark'], value);
}
get flow(): 'paginated' | 'scrolled' {
return this.userSettings.ebookReaderSetting.flow;
}
set flow(value: 'paginated' | 'scrolled') {
this.userSettings.ebookReaderSetting.flow = value;
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'flow'], value);
}
increaseFontSize() {
if (this.fontSize < 72) {
this.fontSize += 1;
}
}
decreaseFontSize() {
if (this.fontSize > 8) {
this.fontSize -= 1;
}
}
increaseLineHeight() {
if (this.lineHeight < 3) {
this.lineHeight = Math.round((this.lineHeight + 0.1) * 10) / 10;
}
}
decreaseLineHeight() {
if (this.lineHeight > 1) {
this.lineHeight = Math.round((this.lineHeight - 0.1) * 10) / 10;
}
}
increaseGap() {
if (this.gap < 0.5) {
this.gap = Math.round((this.gap + 0.05) * 100) / 100;
}
}
decreaseGap() {
if (this.gap > 0) {
this.gap = Math.round((this.gap - 0.05) * 100) / 100;
}
}
increaseMaxInlineSize() {
if (this.maxInlineSize < 2000) {
this.maxInlineSize += 50;
}
}
decreaseMaxInlineSize() {
if (this.maxInlineSize > 400) {
this.maxInlineSize -= 50;
}
}
increaseMaxBlockSize() {
if (this.maxBlockSize < 2000) {
this.maxBlockSize += 50;
}
}
decreaseMaxBlockSize() {
if (this.maxBlockSize > 400) {
this.maxBlockSize -= 50;
}
}
getCustomFontName(fontKey: string): string | null {
if (!fontKey || !fontKey.startsWith('custom:')) {
return null;
}
const fontId = parseInt(fontKey.split(':')[1]);
const customFont = this.customFonts.find(f => f.id === fontId);
return customFont ? customFont.fontName : null;
}
}
@@ -0,0 +1,53 @@
<ng-container *transloco="let t; prefix: 'settingsReader.pdf'">
<div class="pdf-preferences-container">
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('pageSpread') }}</label>
<div class="button-group">
@for (spread of spreads; track spread) {
<button
type="button"
class="option-button"
[class.selected]="selectedSpread === spread.key"
(click)="selectedSpread = spread.key"
[pTooltip]="t(spread.translationKey)"
tooltipPosition="bottom">
<i [class]="spread.icon"></i>
<span class="option-text">{{ t(spread.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('pageSpreadDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('pageZoom') }}</label>
<div class="button-group">
@for (zoom of zooms; track zoom) {
<button
type="button"
class="option-button"
[class.selected]="selectedZoom === zoom.key"
(click)="selectedZoom = zoom.key"
[pTooltip]="t(zoom.translationKey)"
tooltipPosition="bottom">
<i [class]="zoom.icon"></i>
<span class="option-text">{{ t(zoom.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('pageZoomDesc') }}
</p>
</div>
</div>
</div>
</ng-container>
@@ -0,0 +1,62 @@
@use '../../../../shared/styles/settings-shared' as settings;
.pdf-preferences-container {
display: flex;
flex-direction: column;
gap: 1rem;
}
.setting-item {
display: flex;
align-items: flex-start;
gap: 2rem;
padding: 0.25rem 0;
&:last-child {
border-bottom: none;
padding-bottom: 0;
}
@media (max-width: 768px) {
flex-direction: column;
gap: 1rem;
}
}
.setting-info {
flex: 1;
min-width: 0;
.setting-label {
display: block;
font-weight: settings.$settings-section-title-weight;
color: var(--p-text-color);
font-size: 1rem;
margin-bottom: 0.5rem;
}
.setting-label-row {
display: flex;
align-items: center;
gap: 1rem;
margin-bottom: 0.5rem;
flex-wrap: wrap;
.setting-label {
margin-bottom: 0;
flex-shrink: 0;
min-width: 100px;
}
}
.setting-description {
color: var(--p-text-muted-color);
font-size: settings.$settings-section-description-size;
line-height: 1.5;
margin: 0;
}
}
.button-group {
@include settings.settings-button-group;
}
@@ -0,0 +1,53 @@
import {Component, inject, Input} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {TranslocoDirective} from '@jsverse/transloco';
import {ReaderPreferencesService} from '../reader-preferences.service';
import {PageSpread, UserSettings} from '../../user-management/user.service';
import {TooltipModule} from 'primeng/tooltip';
@Component({
selector: 'app-pdf-reader-preferences-component',
imports: [
FormsModule,
TranslocoDirective,
TooltipModule
],
templateUrl: './pdf-reader-preferences-component.html',
styleUrl: './pdf-reader-preferences-component.scss'
})
export class PdfReaderPreferencesComponent {
private readonly readerPreferencesService = inject(ReaderPreferencesService);
@Input() userSettings!: UserSettings;
readonly spreads: {name: string; key: PageSpread; icon: string; translationKey: string}[] = [
{name: 'Even', key: 'even', icon: 'pi pi-align-left', translationKey: 'even'},
{name: 'Odd', key: 'odd', icon: 'pi pi-align-right', translationKey: 'odd'},
{name: 'None', key: 'off', icon: 'pi pi-minus', translationKey: 'none'}
];
readonly zooms: {name: string; key: string; icon: string; translationKey: string}[] = [
{name: 'Auto Zoom', key: 'auto', icon: 'pi pi-sparkles', translationKey: 'autoZoom'},
{name: 'Page Fit', key: 'page-fit', icon: 'pi pi-window-maximize', translationKey: 'pageFit'},
{name: 'Page Width', key: 'page-width', icon: 'pi pi-arrows-h', translationKey: 'pageWidth'},
{name: 'Actual Size', key: 'page-actual', icon: 'pi pi-expand', translationKey: 'actualSize'}
];
get selectedSpread(): 'even' | 'odd' | 'off' {
return this.userSettings.pdfReaderSetting.pageSpread;
}
set selectedSpread(value: 'even' | 'odd' | 'off') {
this.userSettings.pdfReaderSetting.pageSpread = value;
this.readerPreferencesService.updatePreference(['pdfReaderSetting', 'pageSpread'], value);
}
get selectedZoom(): string {
return this.userSettings.pdfReaderSetting.pageZoom;
}
set selectedZoom(value: string) {
this.userSettings.pdfReaderSetting.pageZoom = value;
this.readerPreferencesService.updatePreference(['pdfReaderSetting', 'pageZoom'], value);
}
}
@@ -0,0 +1,88 @@
<ng-container *transloco="let t; prefix: 'settingsReader'">
<div class="main-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-book"></i>
{{ t('title') }}
</h2>
<p class="settings-description">
{{ t('description') }}
</p>
</div>
<div class="settings-content">
<app-settings-application-mode [userSettings]="userSettings"></app-settings-application-mode>
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-book"></i>
{{ t('ebook.sectionTitle') }}
</h3>
<p class="section-description">
{{ t('ebook.sectionDesc') }}
</p>
</div>
<div class="settings-card">
<app-epub-reader-preferences-component
[userSettings]="userSettings">
</app-epub-reader-preferences-component>
</div>
</div>
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-file-pdf"></i>
{{ t('pdf.sectionTitle') }}
</h3>
<p class="section-description">
{{ t('pdf.sectionDesc') }}
</p>
</div>
<div class="settings-card">
<app-pdf-reader-preferences-component
[userSettings]="userSettings">
</app-pdf-reader-preferences-component>
</div>
</div>
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-images"></i>
{{ t('cbx.sectionTitle') }}
</h3>
<p class="section-description">
{{ t('cbx.sectionDesc') }}
</p>
</div>
<div class="settings-card">
<app-cbx-reader-preferences-component
[userSettings]="userSettings">
</app-cbx-reader-preferences-component>
</div>
</div>
@if (hasFontManagementPermission) {
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-palette"></i>
{{ t('fonts.sectionTitle') }}
</h3>
<p class="section-description">
{{ t('fonts.sectionDesc') }}
</p>
</div>
<div class="settings-card">
<app-custom-fonts></app-custom-fonts>
</div>
</div>
}
</div>
</div>
</ng-container>
@@ -0,0 +1,92 @@
@use '../../../shared/styles/settings-shared' as settings;
.main-container {
@include settings.settings-page-container;
}
@include settings.settings-page-header;
.settings-title {
@include settings.settings-page-title;
margin-bottom: 0.75rem;
}
.settings-description {
@include settings.settings-page-description;
}
.settings-content {
display: flex;
flex-direction: column;
gap: 2rem;
}
.preferences-section {
@media (min-width: 768px) {
padding: 0 1rem;
}
}
.section-header {
@include settings.settings-section-header;
margin-bottom: 1rem;
}
.section-title {
@include settings.settings-section-title;
margin: 0 0 0.5rem 0;
}
.section-description {
@include settings.settings-section-description;
}
.settings-card {
@include settings.settings-card;
app-epub-reader-preferences-component,
app-pdf-reader-preferences-component,
app-cbx-reader-preferences-component {
display: block;
width: 100%;
}
}
.setting-control {
flex-shrink: 0;
display: flex;
flex-direction: column;
gap: 0.75rem;
align-items: flex-end;
@media (max-width: 768px) {
align-items: flex-start;
width: 100%;
}
}
.radio-group {
display: flex;
gap: 1.5rem;
@media (max-width: 768px) {
flex-direction: column;
gap: 0.75rem;
}
}
.radio-option {
display: flex;
align-items: center;
gap: 0.5rem;
label {
font-size: settings.$settings-section-description-size;
color: var(--p-text-color);
cursor: pointer;
}
}
.button-group {
@include settings.settings-button-group;
}
@@ -0,0 +1,38 @@
import {Component, effect, inject} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {TooltipModule} from 'primeng/tooltip';
import {TranslocoDirective} from '@jsverse/transloco';
import {UserService, UserSettings} from '../user-management/user.service';
import {ReaderPreferencesService} from './reader-preferences.service';
import {EpubReaderPreferencesComponent} from './epub-reader-preferences/epub-reader-preferences-component';
import {PdfReaderPreferencesComponent} from './pdf-reader-preferences/pdf-reader-preferences-component';
import {CbxReaderPreferencesComponent} from './cbx-reader-preferences/cbx-reader-preferences-component';
import {CustomFontsComponent} from '../custom-fonts/custom-fonts.component';
import {SettingsApplicationModeComponent} from './settings-application-mode/settings-application-mode.component';
@Component({
selector: 'app-reader-preferences',
templateUrl: './reader-preferences.component.html',
standalone: true,
styleUrls: ['./reader-preferences.component.scss'],
imports: [FormsModule, TooltipModule, TranslocoDirective, EpubReaderPreferencesComponent, PdfReaderPreferencesComponent, CbxReaderPreferencesComponent, CustomFontsComponent, SettingsApplicationModeComponent]
})
export class ReaderPreferences {
private readonly userService = inject(UserService);
userSettings!: UserSettings;
hasFontManagementPermission = false;
constructor() {
effect(() => {
const user = this.userService.currentUser();
if (!user) return;
this.userSettings = user.userSettings;
const perms = user.permissions;
this.hasFontManagementPermission = (perms.admin || perms.canManageFonts);
});
}
}
@@ -0,0 +1,42 @@
import {effect, inject, Injectable} from '@angular/core';
import {User, UserService, UserSettings} from '../user-management/user.service';
import {MessageService} from 'primeng/api';
import {TranslocoService} from '@jsverse/transloco';
@Injectable({providedIn: 'root'})
export class ReaderPreferencesService {
private readonly userService = inject(UserService);
private readonly messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
private currentUser: User | null = null;
constructor() {
effect(() => {
const user = this.userService.currentUser();
if (user) {
this.currentUser = user;
}
});
}
updatePreference(path: string[], value: unknown): void {
if (!this.currentUser) return;
let target: any = this.currentUser.userSettings;
for (let i = 0; i < path.length - 1; i++) {
target = target[path[i]] ||= {};
}
target[path.at(-1)!] = value;
const [rootKey] = path;
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
});
}
}
@@ -0,0 +1,107 @@
<ng-container *transloco="let t; prefix: 'settingsReader.appMode'">
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-cog"></i>
{{ t('title') }}
</h3>
<p class="section-description">
{{ t('description') }}
</p>
</div>
<div class="settings-card">
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('pdfLabel') }}</label>
<div class="button-group">
@for (item of scopeOptions; track item) {
<button
type="button"
class="option-button"
[class.selected]="selectedPdfScope === item.key"
(click)="selectedPdfScope = item.key; onPdfScopeChange()">
<i [class]="item.icon"></i>
<span class="option-text">{{ item.key === 'Global' ? t('defaultOverride') : t('bookSpecific') }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('pdfDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('ebookLabel') }}</label>
<div class="button-group">
@for (item of scopeOptions; track item) {
<button
type="button"
class="option-button"
[class.selected]="selectedEpubScope === item.key"
(click)="selectedEpubScope = item.key; onEpubScopeChange()">
<i [class]="item.icon"></i>
<span class="option-text">{{ item.key === 'Global' ? t('defaultOverride') : t('bookSpecific') }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('ebookDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('comicLabel') }}</label>
<div class="button-group">
@for (item of scopeOptions; track item) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxScope === item.key"
(click)="selectedCbxScope = item.key; onCbxScopeChange()">
<i [class]="item.icon"></i>
<span class="option-text">{{ item.key === 'Global' ? t('defaultOverride') : t('bookSpecific') }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('comicDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('streamingPdfLabel') }}</label>
<div class="button-group">
@for (item of scopeOptions; track item) {
<button
type="button"
class="option-button"
[class.selected]="selectedNewPdfScope === item.key"
(click)="selectedNewPdfScope = item.key; onNewPdfScopeChange()">
<i [class]="item.icon"></i>
<span class="option-text">{{ item.key === 'Global' ? t('defaultOverride') : t('bookSpecific') }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('streamingPdfDesc') }}
</p>
</div>
</div>
</div>
</div>
</ng-container>
@@ -0,0 +1,151 @@
.preferences-section {
@media (min-width: 768px) {
padding: 0 1rem;
}
}
.section-header {
margin-bottom: 1rem;
}
.section-title {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 1.125rem;
font-weight: 600;
color: var(--p-text-color);
margin: 0 0 0.5rem 0;
.pi {
color: var(--p-primary-color);
}
}
.section-description {
display: flex;
align-items: flex-start;
gap: 0.5rem;
color: var(--p-text-muted-color);
font-size: 0.875rem;
line-height: 1.5;
margin: 0;
.pi {
color: var(--p-primary-color);
margin-top: 0.125rem;
flex-shrink: 0;
}
}
.settings-card {
border: 1px solid var(--p-content-border-color);
border-radius: 8px;
background: var(--p-content-background);
padding: 1.5rem;
display: flex;
flex-direction: column;
gap: 1rem;
}
.setting-item {
display: flex;
align-items: flex-start;
gap: 2rem;
padding: 0.25rem 0;
&:last-child {
border-bottom: none;
padding-bottom: 0;
}
@media (max-width: 768px) {
flex-direction: column;
gap: 1rem;
}
}
.setting-info {
flex: 1;
min-width: 0;
.setting-label {
display: block;
font-weight: 600;
color: var(--p-text-color);
font-size: 1rem;
margin-bottom: 0.5rem;
min-width: 220px;
flex-shrink: 0;
}
.setting-label-row {
display: flex;
align-items: flex-start;
gap: 1rem;
margin-bottom: 0.5rem;
flex-wrap: wrap;
.setting-label {
margin-bottom: 0;
min-width: 220px;
flex-shrink: 0;
}
}
.setting-description {
color: var(--p-text-muted-color);
font-size: 0.875rem;
line-height: 1.5;
margin: 0;
}
}
.button-group {
display: flex;
flex-direction: row;
gap: 0.5rem;
flex-wrap: wrap;
.option-button {
display: flex;
align-items: center;
justify-content: center;
gap: 0.375rem;
padding: 0.5rem 0.75rem;
border-radius: 0.375rem;
border: 1.5px solid color-mix(in srgb, var(--text-color) 20%, transparent);
background: color-mix(in srgb, var(--text-color) 5%, transparent);
color: var(--text-color);
cursor: pointer;
transition: all 0.2s ease;
font-size: 0.875rem;
font-weight: 500;
min-width: 4.5rem;
i {
font-size: 0.875rem;
}
.option-text {
white-space: nowrap;
}
&:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
border-color: color-mix(in srgb, var(--primary-color) 40%, transparent);
}
&.selected {
border-color: var(--primary-color);
background: color-mix(in srgb, var(--primary-color) 10%, transparent);
color: var(--primary-color);
box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-color) 15%, transparent);
&:hover {
transform: translateY(-2px);
}
}
}
}
@@ -0,0 +1,55 @@
import {ChangeDetectionStrategy, Component, inject, Input, OnInit} from '@angular/core';
import {TranslocoDirective} from '@jsverse/transloco';
import {ReaderPreferencesService} from '../reader-preferences.service';
import {UserSettings} from '../../user-management/user.service';
@Component({
selector: 'app-settings-application-mode',
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './settings-application-mode.component.html',
standalone: true,
styleUrls: ['./settings-application-mode.component.scss'],
imports: [TranslocoDirective]
})
export class SettingsApplicationModeComponent implements OnInit {
@Input() userSettings!: UserSettings;
readonly scopeOptions = [
{name: 'Global', key: 'Global', icon: 'pi pi-globe'},
{name: 'Individual', key: 'Individual', icon: 'pi pi-user'}
];
selectedPdfScope!: string;
selectedNewPdfScope!: string;
selectedEpubScope!: string;
selectedCbxScope!: string;
private readonly readerPreferencesService = inject(ReaderPreferencesService);
ngOnInit(): void {
this.loadPreferences();
}
private loadPreferences(): void {
this.selectedPdfScope = this.userSettings.perBookSetting.pdf;
this.selectedNewPdfScope = this.userSettings.perBookSetting.newPdf || 'Global';
this.selectedEpubScope = this.userSettings.perBookSetting.epub;
this.selectedCbxScope = this.userSettings.perBookSetting.cbx;
}
onPdfScopeChange() {
this.readerPreferencesService.updatePreference(['perBookSetting', 'pdf'], this.selectedPdfScope);
}
onNewPdfScopeChange() {
this.readerPreferencesService.updatePreference(['perBookSetting', 'newPdf'], this.selectedNewPdfScope);
}
onEpubScopeChange() {
this.readerPreferencesService.updatePreference(['perBookSetting', 'epub'], this.selectedEpubScope);
}
onCbxScopeChange() {
this.readerPreferencesService.updatePreference(['perBookSetting', 'cbx'], this.selectedCbxScope);
}
}