- 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>
|
||||
<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">
|
||||
<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>
|
||||
<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-button size="small" 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>
|
||||
</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>
|
||||
|
||||
<button class="epub-controls-left" (click)="prevPage()" >←</button>
|
||||
<button class="epub-controls-left" (click)="prevPage()">←</button>
|
||||
<button class="epub-controls-right" (click)="nextPage()">→</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+9
-15
@@ -1,10 +1,15 @@
|
||||
.epub-viewer-container {
|
||||
.epub-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
|
||||
.epub-viewer-container {
|
||||
overflow: hidden;
|
||||
height: 100vh;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#epubContainer {
|
||||
@@ -16,7 +21,6 @@
|
||||
|
||||
.menu-toggle-button,
|
||||
.settings-toggle-button {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
z-index: 1000;
|
||||
margin: 0;
|
||||
@@ -30,16 +34,6 @@
|
||||
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-right {
|
||||
position: absolute;
|
||||
|
||||
@@ -35,8 +35,7 @@ export function getCfiFromHref(book: any, href: string): string {
|
||||
|
||||
export function getChapter(book: any, location: any) {
|
||||
const locationHref = location.start.href;
|
||||
|
||||
let match = flatten(book.navigation.toc)
|
||||
return flatten(book.navigation.toc)
|
||||
.filter((chapter: any) => {
|
||||
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;
|
||||
return locationAfterChapter ? chapter : result;
|
||||
}, null);
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
@Component({
|
||||
@@ -60,6 +57,7 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
||||
|
||||
isLoading = true;
|
||||
chapters: { label: string; href: string }[] = [];
|
||||
currentChapter = '';
|
||||
isDrawerVisible = false;
|
||||
isSettingsDrawerVisible = false;
|
||||
private book: any;
|
||||
@@ -263,7 +261,7 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
||||
if (this.rendition) {
|
||||
this.rendition.on('relocated', (location: any) => {
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user