- Prevent buttons from overlapping the EPUB content area
- Display chapter name in the header section
This commit is contained in:
committed by
Aditya Chandel
parent
b8947dcf27
commit
f31b1b3796
+35
-29
@@ -2,41 +2,47 @@
|
|||||||
<p-progressSpinner *ngIf="isLoading"></p-progressSpinner>
|
<p-progressSpinner *ngIf="isLoading"></p-progressSpinner>
|
||||||
<div *ngIf="!isLoading">
|
<div *ngIf="!isLoading">
|
||||||
|
|
||||||
<p-button class="menu-toggle-button" (click)="toggleDrawer()" icon="pi pi-bars" severity="secondary"></p-button>
|
|
||||||
<p-drawer [(visible)]="isDrawerVisible" [modal]="false" [position]="'left'" header="Chapters">
|
|
||||||
<ul class="chapter-list">
|
|
||||||
<li *ngFor="let chapter of chapters" (click)="navigateToChapter(chapter); $event.stopPropagation()" class="chapter-item">
|
|
||||||
{{ chapter.label }}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</p-drawer>
|
|
||||||
|
|
||||||
<div class="epub-header">
|
<div class="epub-header">
|
||||||
<h3>Chapter 1: Introduction | Page 3 of 120</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p-button class="settings-toggle-button" (click)="toggleSettingsDrawer()" icon="pi pi-cog" severity="secondary"></p-button>
|
<div>
|
||||||
<p-drawer [(visible)]="isSettingsDrawerVisible" [modal]="false" [position]="'right'" header="Settings">
|
<p-button size="small" class="menu-toggle-button" (click)="toggleDrawer()" icon="pi pi-bars" severity="secondary"></p-button>
|
||||||
<div class="flex flex-col">
|
<p-drawer [(visible)]="isDrawerVisible" [modal]="false" [position]="'left'" header="Chapters">
|
||||||
<div class="settings-content">
|
<ul class="chapter-list">
|
||||||
<p>Font Size: {{ fontSize }}%</p>
|
<li *ngFor="let chapter of chapters" (click)="navigateToChapter(chapter); $event.stopPropagation()" class="chapter-item">
|
||||||
<div class="flex flex-row gap-4">
|
{{ chapter.label }}
|
||||||
<p-button icon="pi pi-minus" (click)="decreaseFontSize()" severity="info"></p-button>
|
</li>
|
||||||
<p-button icon="pi pi-plus" (click)="increaseFontSize()" severity="info"></p-button>
|
</ul>
|
||||||
</div>
|
</p-drawer>
|
||||||
<p-divider></p-divider>
|
|
||||||
<label for="font-type">Font Type:</label>
|
|
||||||
<p-select id="font-type" [options]="fontTypes" [(ngModel)]="selectedFontType" (onChange)="changeFontType()"></p-select>
|
|
||||||
<p-divider></p-divider>
|
|
||||||
<label for="theme">Theme:</label>
|
|
||||||
<p-select id="theme" [options]="themes" [(ngModel)]="selectedTheme" (onChange)="changeThemes()"></p-select>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</p-drawer>
|
|
||||||
|
<p>{{ currentChapter }}</p>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p-button size="small" class="settings-toggle-button" (click)="toggleSettingsDrawer()" icon="pi pi-cog" severity="secondary"></p-button>
|
||||||
|
<p-drawer [(visible)]="isSettingsDrawerVisible" [modal]="false" [position]="'right'" header="Settings">
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<div class="settings-content">
|
||||||
|
<p>Font Size: {{ fontSize }}%</p>
|
||||||
|
<div class="flex flex-row gap-4">
|
||||||
|
<p-button icon="pi pi-minus" (click)="decreaseFontSize()" severity="info"></p-button>
|
||||||
|
<p-button icon="pi pi-plus" (click)="increaseFontSize()" severity="info"></p-button>
|
||||||
|
</div>
|
||||||
|
<p-divider></p-divider>
|
||||||
|
<label for="font-type">Font Type:</label>
|
||||||
|
<p-select id="font-type" [options]="fontTypes" [(ngModel)]="selectedFontType" (onChange)="changeFontType()"></p-select>
|
||||||
|
<p-divider></p-divider>
|
||||||
|
<label for="theme">Theme:</label>
|
||||||
|
<p-select id="theme" [options]="themes" [(ngModel)]="selectedTheme" (onChange)="changeThemes()"></p-select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</p-drawer>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="epubContainer" #epubContainer></div>
|
<div id="epubContainer" #epubContainer></div>
|
||||||
|
|
||||||
<button class="epub-controls-left" (click)="prevPage()" >←</button>
|
<button class="epub-controls-left" (click)="prevPage()">←</button>
|
||||||
<button class="epub-controls-right" (click)="nextPage()">→</button>
|
<button class="epub-controls-right" (click)="nextPage()">→</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+9
-15
@@ -1,10 +1,15 @@
|
|||||||
.epub-viewer-container {
|
.epub-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: row;
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding-left: 1rem;
|
||||||
|
padding-right: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.epub-viewer-container {
|
||||||
|
overflow: hidden;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
position: relative;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#epubContainer {
|
#epubContainer {
|
||||||
@@ -16,7 +21,6 @@
|
|||||||
|
|
||||||
.menu-toggle-button,
|
.menu-toggle-button,
|
||||||
.settings-toggle-button {
|
.settings-toggle-button {
|
||||||
position: absolute;
|
|
||||||
top: 10px;
|
top: 10px;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -30,16 +34,6 @@
|
|||||||
right: 10px;
|
right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.epub-header {
|
|
||||||
position: absolute;
|
|
||||||
top: 2%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
z-index: 500;
|
|
||||||
text-align: center;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.epub-controls-left,
|
.epub-controls-left,
|
||||||
.epub-controls-right {
|
.epub-controls-right {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ export function getCfiFromHref(book: any, href: string): string {
|
|||||||
|
|
||||||
export function getChapter(book: any, location: any) {
|
export function getChapter(book: any, location: any) {
|
||||||
const locationHref = location.start.href;
|
const locationHref = location.start.href;
|
||||||
|
return flatten(book.navigation.toc)
|
||||||
let match = flatten(book.navigation.toc)
|
|
||||||
.filter((chapter: any) => {
|
.filter((chapter: any) => {
|
||||||
return book.canonical(chapter.href).includes(book.canonical(locationHref));
|
return book.canonical(chapter.href).includes(book.canonical(locationHref));
|
||||||
})
|
})
|
||||||
@@ -44,8 +43,6 @@ export function getChapter(book: any, location: any) {
|
|||||||
const locationAfterChapter = EpubCFI.prototype.compare(location.start.cfi, getCfiFromHref(book, chapter.href)) > 0;
|
const locationAfterChapter = EpubCFI.prototype.compare(location.start.cfi, getCfiFromHref(book, chapter.href)) > 0;
|
||||||
return locationAfterChapter ? chapter : result;
|
return locationAfterChapter ? chapter : result;
|
||||||
}, null);
|
}, null);
|
||||||
|
|
||||||
return match;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -60,6 +57,7 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
chapters: { label: string; href: string }[] = [];
|
chapters: { label: string; href: string }[] = [];
|
||||||
|
currentChapter = '';
|
||||||
isDrawerVisible = false;
|
isDrawerVisible = false;
|
||||||
isSettingsDrawerVisible = false;
|
isSettingsDrawerVisible = false;
|
||||||
private book: any;
|
private book: any;
|
||||||
@@ -263,7 +261,7 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
|||||||
if (this.rendition) {
|
if (this.rendition) {
|
||||||
this.rendition.on('relocated', (location: any) => {
|
this.rendition.on('relocated', (location: any) => {
|
||||||
const currentChapter = getChapter(this.book, location);
|
const currentChapter = getChapter(this.book, location);
|
||||||
console.log(currentChapter?.label || 'Unknown Chapter');
|
this.currentChapter = currentChapter?.label;
|
||||||
this.bookService.saveEpubProgress(this.epub.id, location.start.cfi).subscribe();
|
this.bookService.saveEpubProgress(this.epub.id, location.start.cfi).subscribe();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user