Align the layout to be consistent throughout all dialogs (#1737)

This commit is contained in:
Aditya Chandel
2025-12-02 16:31:19 -07:00
committed by GitHub
parent 8e8d57af73
commit 6b0b078044
38 changed files with 3663 additions and 1328 deletions
@@ -1,3 +1,4 @@
<p-toast position="top-right"></p-toast>
<p-confirmDialog></p-confirmDialog>
<div class="main-container enclosing-container">
@@ -26,33 +27,28 @@
</div>
<div class="settings-card">
<form #koboForm="ngForm">
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Enable Kobo Sync</label>
<p-toggle-switch
id="syncEnabled"
name="syncEnabled"
[(ngModel)]="koboSyncSettings.syncEnabled"
(ngModelChange)="onSyncToggle()">
</p-toggle-switch>
</div>
<p class="setting-description">
Turn on synchronization to automatically sync your library books to your Kobo device.
</p>
</div>
</div>
@if (koboSyncSettings.syncEnabled) {
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Enable Kobo Sync</label>
<p-toggle-switch
id="syncEnabled"
name="syncEnabled"
[(ngModel)]="koboSyncSettings.syncEnabled"
(ngModelChange)="onSyncToggle()">
</p-toggle-switch>
</div>
<p class="setting-description">
Turn on synchronization to automatically sync your library books to your Kobo device.
</p>
</div>
</div>
@if (koboSyncSettings.syncEnabled) {
<div class="setting-item">
<div class="setting-info">
<label class="setting-label">Kobo Sync Token</label>
<p class="setting-description">
Your unique sync token for authenticating with your Kobo device. Keep this secure.
</p>
</div>
<div class="setting-control">
<div class="token-input-group">
<input
pInputText
@@ -68,27 +64,29 @@
outlined="true"
severity="info"
size="small"
(onClick)="copyText(koboSyncSettings.token)">
(onClick)="copyText(koboSyncSettings.token, 'Token')"
[disabled]="!koboSyncSettings.token">
</p-button>
<p-button
[icon]="showToken ? 'pi pi-eye-slash' : 'pi pi-eye'"
outlined="true"
severity="info"
size="small"
(onClick)="toggleShowToken()">
(onClick)="toggleShowToken()"
[disabled]="!koboSyncSettings.token">
</p-button>
</div>
</div>
<p class="setting-description">
Your unique sync token for authenticating with your Kobo device. Keep this secure.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Token Management</label>
<p class="setting-description">
Regenerate your sync token if needed. This will invalidate the current token.
</p>
</div>
<div class="setting-control">
<p-button
icon="pi pi-refresh"
outlined="true"
@@ -99,57 +97,60 @@
[disabled]="!credentialsSaved">
</p-button>
</div>
<p class="setting-description">
Regenerate your sync token if needed. This will invalidate the current token.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Mark as Reading at: {{ koboSyncSettings.progressMarkAsReadingThreshold?.toFixed(0) }}%</label>
<div class="slider-container">
<p-slider
id="markAsReadingThreshold"
name="markAsReadingThreshold"
[(ngModel)]="koboSyncSettings.progressMarkAsReadingThreshold"
[min]="1"
[max]="10"
[step]="1"
(ngModelChange)="onProgressThresholdsChange()">
</p-slider>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Mark as Reading at: {{ koboSyncSettings.progressMarkAsReadingThreshold?.toFixed(0) }}%</label>
<div class="slider-container">
<p-slider
id="markAsReadingThreshold"
name="markAsReadingThreshold"
[(ngModel)]="koboSyncSettings.progressMarkAsReadingThreshold"
[min]="1"
[max]="10"
[step]="1"
(ngModelChange)="onProgressThresholdsChange()">
</p-slider>
</div>
<p class="setting-description">
Books are marked as "Reading" when progress exceeds this percentage. This helps automatically track which books you've started.
<br>
<strong>Recommended:</strong> 1% (default) - marks as reading after the first page or two.
</p>
</div>
<p class="setting-description">
Books are marked as "Reading" when progress exceeds this percentage. This helps automatically track which books you've started.
<br>
<strong>Recommended:</strong> 1% (default) - marks as reading after the first page or two.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Mark as Finished at: {{ koboSyncSettings.progressMarkAsFinishedThreshold?.toFixed(0) }}%</label>
<div class="slider-container">
<p-slider
id="markAsFinishedThreshold"
name="markAsFinishedThreshold"
[(ngModel)]="koboSyncSettings.progressMarkAsFinishedThreshold"
[min]="90"
[max]="100"
[step]="1"
(ngModelChange)="onProgressThresholdsChange()">
</p-slider>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Mark as Finished at: {{ koboSyncSettings.progressMarkAsFinishedThreshold?.toFixed(0) }}%</label>
<div class="slider-container">
<p-slider
id="markAsFinishedThreshold"
name="markAsFinishedThreshold"
[(ngModel)]="koboSyncSettings.progressMarkAsFinishedThreshold"
[min]="90"
[max]="100"
[step]="1"
(ngModelChange)="onProgressThresholdsChange()">
</p-slider>
</div>
<p class="setting-description">
Books are marked as "Finished" when progress reaches this percentage. Accounts for books where the last few pages are acknowledgments or index.
<br>
<strong>Recommended:</strong> 99% (default) - marks as finished when nearly complete.
</p>
</div>
<p class="setting-description">
Books are marked as "Finished" when progress reaches this percentage. Accounts for books where the last few pages are acknowledgments or index.
<br>
<strong>Recommended:</strong> 99% (default) - marks as finished when nearly complete.
</p>
</div>
}
</form>
</div>
}
</div>
</div>
@@ -220,13 +221,13 @@
</div>
<p class="setting-description">
Force enable hyphenation. Otherwise, hyphenation is only enabled when text alignment on the Kobo
device is explicitly set to <i>justified</i>.
device is explicitly set to <i>justified</i>.
</p>
</div>
</div>
<p-divider></p-divider>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
@@ -77,22 +77,16 @@
border: 1px solid var(--p-content-border-color);
border-radius: 8px;
background: var(--p-content-background);
padding: 1.5rem;
padding: 1.75rem;
display: flex;
flex-direction: column;
gap: 1.5rem;
gap: 1.25rem;
}
.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;
@@ -122,6 +116,7 @@
.setting-label {
margin-bottom: 0;
flex-shrink: 0;
min-width: 150px;
}
.slider-container {
@@ -134,6 +129,17 @@
max-width: 250px;
}
}
.token-input-group {
flex: 1;
min-width: 300px;
max-width: 500px;
@media (max-width: 768px) {
min-width: 250px;
max-width: 100%;
}
}
}
.setting-description {
@@ -162,11 +168,6 @@
align-items: center;
gap: 0.5rem;
width: 100%;
max-width: 500px;
@media (max-width: 768px) {
max-width: 100%;
}
.token-input {
flex: 1;
@@ -1,6 +1,5 @@
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
import {ConfirmationService, MessageService} from 'primeng/api';
import {Clipboard} from '@angular/cdk/clipboard';
import {KoboService, KoboSyncSettings} from './kobo.service';
import {FormsModule} from '@angular/forms';
import {Button} from 'primeng/button';
@@ -17,20 +16,20 @@ import {SettingsHelperService} from '../../../../../shared/service/settings-help
import {AppSettingKey, KoboSettings} from '../../../../../shared/model/app-settings.model';
import {ShelfService} from '../../../../book/service/shelf.service';
import {ExternalDocLinkComponent} from '../../../../../shared/components/external-doc-link/external-doc-link.component';
import {ToastModule} from 'primeng/toast';
@Component({
selector: 'app-kobo-sync-setting-component',
standalone: true,
templateUrl: './kobo-sync-settings-component.html',
styleUrl: './kobo-sync-settings-component.scss',
imports: [FormsModule, Button, InputText, ConfirmDialog, ToggleSwitch, Slider, Divider, ExternalDocLinkComponent],
imports: [FormsModule, Button, InputText, ConfirmDialog, ToggleSwitch, Slider, Divider, ExternalDocLinkComponent, ToastModule],
providers: [MessageService, ConfirmationService]
})
export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
private koboService = inject(KoboService);
private messageService = inject(MessageService);
private confirmationService = inject(ConfirmationService);
private clipboard = inject(Clipboard);
protected userService = inject(UserService);
protected appSettingsService = inject(AppSettingsService);
protected settingsHelperService = inject(SettingsHelperService);
@@ -132,9 +131,24 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
});
}
copyText(text: string) {
this.clipboard.copy(text);
this.messageService.add({severity: 'success', summary: 'Copied', detail: 'Token copied to clipboard'});
copyText(text: string, label: string = 'Text') {
if (!text) {
return;
}
navigator.clipboard.writeText(text).then(() => {
this.messageService.add({
severity: 'success',
summary: 'Copied',
detail: `${label} copied to clipboard`
});
}).catch(err => {
console.error('Copy failed', err);
this.messageService.add({
severity: 'error',
summary: 'Copy Failed',
detail: `Unable to copy ${label.toLowerCase()} to clipboard`
});
});
}
toggleShowToken() {
@@ -61,7 +61,8 @@
outlined="true"
severity="info"
size="small"
(onClick)="copyText(koreaderEndpoint)">
(onClick)="copyText(koreaderEndpoint, 'API Path')"
[disabled]="!koreaderEndpoint">
</p-button>
</div>
</div>
@@ -91,7 +92,8 @@
outlined="true"
severity="info"
size="small"
(onClick)="copyText(koReaderUsername)">
(onClick)="copyText(koReaderUsername, 'Username')"
[disabled]="!koReaderUsername">
</p-button>
</div>
</div>
@@ -128,14 +130,16 @@
outlined="true"
severity="info"
size="small"
(onClick)="copyText(koReaderPassword)">
(onClick)="copyText(koReaderPassword, 'Password')"
[disabled]="!koReaderPassword">
</p-button>
<p-button
[icon]="showPassword ? 'pi pi-eye-slash' : 'pi pi-eye'"
outlined="true"
severity="info"
size="small"
(onClick)="toggleShowPassword()">
(onClick)="toggleShowPassword()"
[disabled]="!koReaderPassword">
</p-button>
</div>
</div>
@@ -120,12 +120,23 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
});
}
copyText(text: string) {
copyText(text: string, label: string = 'Text') {
if (!text) {
return;
}
navigator.clipboard.writeText(text).catch(err => {
navigator.clipboard.writeText(text).then(() => {
this.messageService.add({
severity: 'success',
summary: 'Copied',
detail: `${label} copied to clipboard`
});
}).catch(err => {
console.error('Copy failed', err);
this.messageService.add({
severity: 'error',
summary: 'Copy Failed',
detail: `Unable to copy ${label.toLowerCase()} to clipboard`
});
});
}