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:
@@ -0,0 +1,118 @@
|
||||
<div class="comic-reader-container" tabindex="0"
|
||||
[class.rtl-reading]="readingDirection === CbxReadingDirection.RTL"
|
||||
[class.fullscreen-mode]="isFullscreen"
|
||||
[class.slideshow-active]="isSlideshowActive">
|
||||
<app-cbx-header [isCurrentPageBookmarked]="isCurrentPageBookmarked" [currentPageHasNotes]="currentPageHasNotes"></app-cbx-header>
|
||||
|
||||
<app-cbx-sidebar></app-cbx-sidebar>
|
||||
|
||||
@if (showQuickSettings) {
|
||||
<app-cbx-quick-settings></app-cbx-quick-settings>
|
||||
}
|
||||
|
||||
@if (isCurrentPageBookmarked) {
|
||||
<div class="bookmark-indicator">
|
||||
<svg width="48" height="64" viewBox="0 0 48 64">
|
||||
<polygon points="0,0 48,0 48,64 24,48 0,64" fill="red"/>
|
||||
</svg>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (showNoteDialog) {
|
||||
<app-cbx-note-dialog
|
||||
[data]="noteDialogData"
|
||||
(save)="onNoteSave($event)"
|
||||
(cancel)="onNoteCancel()"
|
||||
></app-cbx-note-dialog>
|
||||
}
|
||||
|
||||
@if (showShortcutsHelp) {
|
||||
<app-cbx-shortcuts-help
|
||||
(close)="onShortcutsHelpClose()"
|
||||
></app-cbx-shortcuts-help>
|
||||
}
|
||||
|
||||
@if (isSlideshowActive) {
|
||||
<div class="slideshow-progress" [class.above-footer]="isFooterVisible" [style.animation-duration.ms]="slideshowInterval"></div>
|
||||
}
|
||||
|
||||
<div #magnifierLens class="magnifier-lens"></div>
|
||||
|
||||
<div class="image-container"
|
||||
[class.magnifier-active]="isMagnifierActive"
|
||||
[class.two-page-view]="isTwoPageView && scrollMode === CbxScrollMode.PAGINATED"
|
||||
[class.infinite-scroll]="scrollMode === CbxScrollMode.INFINITE"
|
||||
[class.long-strip]="scrollMode === CbxScrollMode.LONG_STRIP"
|
||||
[class.fit-actual-size]="fitMode === CbxFitMode.ACTUAL_SIZE"
|
||||
[class.fit-page]="fitMode === CbxFitMode.FIT_PAGE"
|
||||
[class.fit-width]="fitMode === CbxFitMode.FIT_WIDTH"
|
||||
[class.fit-height]="fitMode === CbxFitMode.FIT_HEIGHT"
|
||||
[class.fit-auto]="fitMode === CbxFitMode.AUTO"
|
||||
[class.bg-black]="backgroundColor === CbxBackgroundColor.BLACK"
|
||||
[class.bg-gray]="backgroundColor === CbxBackgroundColor.GRAY"
|
||||
[class.bg-white]="backgroundColor === CbxBackgroundColor.WHITE"
|
||||
(scroll)="onScroll($event)">
|
||||
@if (!isLoading) {
|
||||
@if (pages.length > 0) {
|
||||
@if (scrollMode === CbxScrollMode.PAGINATED) {
|
||||
<div class="pages-wrapper" (click)="onImageClick()" (dblclick)="onImageDoubleClick()">
|
||||
@if (isPageTransitioning && previousImageUrls.length > 0) {
|
||||
<div class="previous-page-layer">
|
||||
@for (url of previousImageUrls; track url) {
|
||||
<img [src]="url" alt="Previous Page" class="page-image previous-image"/>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
<div class="current-page-layer" [class.fade-in]="isPageTransitioning && imagesLoaded">
|
||||
@for (url of currentImageUrls; track url; let i = $index) {
|
||||
<img [src]="url" alt="Page Image" class="page-image" (load)="onPageImageLoad($event, currentPage + i)"/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if (isAtLastPage && nextBookInSeries) {
|
||||
<div class="end-of-comic-action">
|
||||
<button class="next-book-action-button" (click)="navigateToNextBook()">
|
||||
<span class="action-icon">📖</span>
|
||||
<span class="action-text">{{ 'readerCbx.reader.continueToNextBook' | transloco }}</span>
|
||||
<span class="book-title">{{ getBookDisplayTitle(nextBookInSeries) }}</span>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
} @else {
|
||||
<div class="infinite-scroll-wrapper" [class.long-strip-wrapper]="scrollMode === CbxScrollMode.LONG_STRIP">
|
||||
@for (pageIdx of infiniteScrollPages; track pageIdx; let i = $index) {
|
||||
<img [src]="getPageImageUrl(pageIdx)" alt="Page {{ pageIdx + 1 }}" class="page-image" (click)="onImageClick()" (dblclick)="onImageDoubleClick()" (load)="onPageImageLoad($event, pageIdx)"/>
|
||||
}
|
||||
@if (isLoadingMore) {
|
||||
<div class="loading-more">
|
||||
<p-progressSpinner class="small-spinner"></p-progressSpinner>
|
||||
</div>
|
||||
}
|
||||
@if (infiniteScrollPages.length > 0 && infiniteScrollPages[infiniteScrollPages.length - 1] >= pages.length - 1 && nextBookInSeries) {
|
||||
<div class="end-of-comic-action">
|
||||
<button class="next-book-action-button" (click)="navigateToNextBook()">
|
||||
<span class="action-icon">📖</span>
|
||||
<span class="action-text">{{ 'readerCbx.reader.continueToNextBook' | transloco }}</span>
|
||||
<span class="book-title">{{ getBookDisplayTitle(nextBookInSeries) }}</span>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
} @else {
|
||||
<div class="no-pages">
|
||||
<p>{{ 'readerCbx.reader.noPagesAvailable' | transloco }}</p>
|
||||
</div>
|
||||
}
|
||||
} @else {
|
||||
<div class="loader-overlay">
|
||||
<div class="loader-content">
|
||||
<div class="spinner"></div>
|
||||
<p class="loader-text">{{ 'readerCbx.reader.loadingBook' | transloco }}</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<app-cbx-footer></app-cbx-footer>
|
||||
</div>
|
||||
@@ -0,0 +1,630 @@
|
||||
.comic-reader-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100dvh;
|
||||
width: 100vw;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
background: #1a1a1a;
|
||||
color: #ffffff;
|
||||
position: relative;
|
||||
touch-action: none;
|
||||
overscroll-behavior: none;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
// RTL reading mode - reverse page order in two-page view
|
||||
&.rtl-reading {
|
||||
.two-page-view {
|
||||
.pages-wrapper,
|
||||
.previous-page-layer,
|
||||
.current-page-layer {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Slideshow progress bar
|
||||
.slideshow-progress {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
height: 3px;
|
||||
background: #4a90e2;
|
||||
z-index: 1001;
|
||||
pointer-events: none;
|
||||
animation: slideshow-fill linear infinite;
|
||||
transition: bottom 0.3s ease;
|
||||
|
||||
&.above-footer {
|
||||
bottom: 52px;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slideshow-fill {
|
||||
from { width: 0; }
|
||||
to { width: 100%; }
|
||||
}
|
||||
|
||||
.magnifier-lens {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: none;
|
||||
border-radius: 50%;
|
||||
border: 3px solid rgba(255, 255, 255, 0.8);
|
||||
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 8px 32px rgba(0, 0, 0, 0.5);
|
||||
pointer-events: none;
|
||||
z-index: 1000;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.bookmark-indicator {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 24px;
|
||||
z-index: 10;
|
||||
pointer-events: none;
|
||||
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
|
||||
|
||||
svg {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.image-container {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
padding: 0.5rem;
|
||||
background: #0f0f0f;
|
||||
min-height: 0;
|
||||
|
||||
&:not(.two-page-view):not(.infinite-scroll) {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
.pages-wrapper {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.end-of-comic-action {
|
||||
flex: 0 0 auto;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
&.magnifier-active {
|
||||
cursor: none;
|
||||
}
|
||||
|
||||
&.bg-black {
|
||||
background: #000000;
|
||||
}
|
||||
|
||||
&.bg-gray {
|
||||
background: #0f0f0f;
|
||||
}
|
||||
|
||||
&.bg-white {
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
&:not(.infinite-scroll) {
|
||||
.pages-wrapper {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.previous-page-layer,
|
||||
.current-page-layer {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.previous-page-layer {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.current-page-layer {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
|
||||
&.fade-in {
|
||||
animation: fadeIn 0.15s ease-out forwards;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0.7;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.page-image {
|
||||
object-fit: contain;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
|
||||
border-radius: 4px;
|
||||
transition: transform 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
&.previous-image {
|
||||
&:hover {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-width {
|
||||
.pages-wrapper,
|
||||
.previous-page-layer,
|
||||
.current-page-layer {
|
||||
height: auto;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
}
|
||||
|
||||
&.two-page-view {
|
||||
.pages-wrapper,
|
||||
.previous-page-layer,
|
||||
.current-page-layer {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-height {
|
||||
.pages-wrapper,
|
||||
.previous-page-layer,
|
||||
.current-page-layer {
|
||||
width: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
width: auto;
|
||||
height: 100%;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
}
|
||||
|
||||
&.two-page-view {
|
||||
.page-image {
|
||||
width: auto;
|
||||
height: 100%;
|
||||
max-width: calc(50% - 0.5rem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-actual-size {
|
||||
overflow: auto;
|
||||
|
||||
.pages-wrapper,
|
||||
.previous-page-layer,
|
||||
.current-page-layer {
|
||||
width: max-content;
|
||||
height: max-content;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: none;
|
||||
max-height: none;
|
||||
|
||||
&:hover {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-page {
|
||||
.page-image {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
}
|
||||
|
||||
&.two-page-view {
|
||||
.page-image {
|
||||
max-width: calc(50% - 0.5rem);
|
||||
max-height: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-auto {
|
||||
.page-image {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
}
|
||||
|
||||
&.two-page-view {
|
||||
.page-image {
|
||||
max-width: calc(50% - 0.5rem);
|
||||
max-height: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.infinite-scroll {
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
align-items: flex-start;
|
||||
touch-action: pan-y;
|
||||
overscroll-behavior: contain;
|
||||
|
||||
.infinite-scroll-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
width: 100%;
|
||||
padding: 1rem 0;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
|
||||
border-radius: 4px;
|
||||
transition: none;
|
||||
|
||||
&:hover {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-width .page-image {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
&.fit-height {
|
||||
.infinite-scroll-wrapper {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
width: auto;
|
||||
height: calc(100vh - 2rem);
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-actual-size {
|
||||
overflow-x: auto;
|
||||
|
||||
.infinite-scroll-wrapper {
|
||||
align-items: center;
|
||||
width: max-content;
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-page {
|
||||
.infinite-scroll-wrapper {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
max-width: 100%;
|
||||
max-height: calc(100vh - 2rem);
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-auto {
|
||||
.infinite-scroll-wrapper {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
max-width: 100%;
|
||||
max-height: calc(100vh - 2rem);
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-more {
|
||||
padding: 2rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
// Long Strip / Webtoon mode - no gaps between pages
|
||||
&.long-strip {
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
align-items: flex-start;
|
||||
touch-action: pan-y;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overscroll-behavior: contain;
|
||||
|
||||
.long-strip-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
box-shadow: none;
|
||||
border-radius: 0;
|
||||
transition: none;
|
||||
display: block;
|
||||
|
||||
&:hover {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-width .page-image {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
&.fit-height .page-image {
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
&.fit-actual-size {
|
||||
overflow-x: auto;
|
||||
|
||||
.long-strip-wrapper {
|
||||
width: max-content;
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-page .page-image,
|
||||
&.fit-auto .page-image {
|
||||
max-width: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.loading-more {
|
||||
padding: 2rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
.no-pages {
|
||||
text-align: center;
|
||||
color: #999;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.loading-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 1.5rem;
|
||||
text-align: center;
|
||||
|
||||
.loading-text {
|
||||
color: #ccc;
|
||||
font-size: 16px;
|
||||
max-width: 400px;
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
::ng-deep .small-spinner {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.end-of-comic-action {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 2rem 1rem;
|
||||
|
||||
.next-book-action-button {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 2rem 3rem;
|
||||
background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 4px 20px rgba(74, 144, 226, 0.3);
|
||||
min-width: 280px;
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 30px rgba(74, 144, 226, 0.5);
|
||||
background: linear-gradient(135deg, #357abd 0%, #2a6399 100%);
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.action-icon {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
|
||||
.action-text {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.book-title {
|
||||
font-size: 0.95rem;
|
||||
font-weight: 400;
|
||||
opacity: 0.9;
|
||||
max-width: 350px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.comic-reader-container {
|
||||
.slideshow-progress.above-footer {
|
||||
bottom: 48px;
|
||||
}
|
||||
|
||||
.image-container {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.end-of-comic-action {
|
||||
padding: 1.5rem 1rem;
|
||||
|
||||
.next-book-action-button {
|
||||
min-width: 240px;
|
||||
padding: 1.5rem 2rem;
|
||||
|
||||
.action-icon { font-size: 2rem; }
|
||||
.action-text { font-size: 1rem; }
|
||||
.book-title {
|
||||
font-size: 0.85rem;
|
||||
max-width: 250px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.loader-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.loader-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 4px solid rgba(255, 255, 255, 0.2);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
.loader-text {
|
||||
color: #fff;
|
||||
font-size: 1.1rem;
|
||||
margin: 0;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
<div class="dialog-overlay" (click)="onOverlayClick($event)">
|
||||
<div class="dialog">
|
||||
<div class="dialog-header">
|
||||
<h2>{{ isEditing ? ('readerCbx.noteDialog.editNote' | transloco) : ('readerCbx.noteDialog.addNote' | transloco) }}</h2>
|
||||
<button class="close-btn" (click)="onCancel()">
|
||||
<app-reader-icon name="close" [size]="18"></app-reader-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="dialog-body">
|
||||
<div class="page-info-section">
|
||||
<span class="section-label">{{ 'readerCbx.noteDialog.pageLabel' | transloco }}</span>
|
||||
<p class="page-info">{{ 'readerCbx.noteDialog.pageInfo' | transloco: { pageNumber: data?.pageNumber } }}</p>
|
||||
</div>
|
||||
|
||||
<div class="note-section">
|
||||
<label class="section-label" for="noteContent">{{ 'readerCbx.noteDialog.yourNote' | transloco }}</label>
|
||||
<textarea
|
||||
id="noteContent"
|
||||
class="note-input"
|
||||
[(ngModel)]="noteContent"
|
||||
[placeholder]="'readerCbx.noteDialog.placeholder' | transloco"
|
||||
rows="6"
|
||||
autofocus
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<div class="color-section">
|
||||
<span class="section-label">{{ 'readerCbx.noteDialog.noteColor' | transloco }}</span>
|
||||
<div class="color-buttons">
|
||||
@for (color of noteColors; track color.value) {
|
||||
<button
|
||||
class="color-btn"
|
||||
[style.--color]="color.value"
|
||||
[class.selected]="selectedColor === color.value"
|
||||
[title]="color.label"
|
||||
(click)="selectColor(color.value)">
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dialog-footer">
|
||||
<button class="btn btn-secondary" (click)="onCancel()">{{ 'common.cancel' | transloco }}</button>
|
||||
<button class="btn btn-primary" (click)="onSave()" [disabled]="!noteContent.trim()">{{ isEditing ? ('readerCbx.noteDialog.updateNote' | transloco) : ('readerCbx.noteDialog.saveNote' | transloco) }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,258 @@
|
||||
// Variables matching reader styling
|
||||
$dialog-bg: #1a1a1a;
|
||||
$text-primary: rgba(255, 255, 255, 0.95);
|
||||
$text-secondary: rgba(255, 255, 255, 0.6);
|
||||
$text-muted: rgba(255, 255, 255, 0.4);
|
||||
$border-color: rgba(255, 255, 255, 0.08);
|
||||
$hover-bg: rgba(255, 255, 255, 0.08);
|
||||
$active-color: #4a90e2;
|
||||
$active-bg: rgba(74, 144, 226, 0.15);
|
||||
$transition-fast: 150ms ease;
|
||||
$transition-normal: 200ms ease;
|
||||
|
||||
.dialog-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
backdrop-filter: blur(4px);
|
||||
z-index: 13000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
animation: fadeIn $transition-normal;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
.dialog {
|
||||
background: $dialog-bg;
|
||||
border: 1px solid $border-color;
|
||||
border-radius: 12px;
|
||||
width: 90%;
|
||||
max-width: 500px;
|
||||
max-height: 85vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
|
||||
animation: slideUp 250ms cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
@keyframes slideUp {
|
||||
from {
|
||||
transform: translateY(20px);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-header {
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid $border-color;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%);
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: $text-primary;
|
||||
letter-spacing: -0.3px;
|
||||
}
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: $text-muted;
|
||||
cursor: pointer;
|
||||
padding: 6px;
|
||||
border-radius: 6px;
|
||||
transition: background $transition-fast, color $transition-fast;
|
||||
line-height: 1;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:hover {
|
||||
background: $hover-bg;
|
||||
color: $text-primary;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-body {
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 3px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.section-label {
|
||||
display: block;
|
||||
color: $text-muted;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.page-info-section {
|
||||
.page-info {
|
||||
margin: 0;
|
||||
padding: 12px 16px;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border-left: 3px solid $active-color;
|
||||
border-radius: 0 8px 8px 0;
|
||||
color: $text-secondary;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
}
|
||||
|
||||
.note-section {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.note-input {
|
||||
flex: 1;
|
||||
min-height: 120px;
|
||||
padding: 12px 16px;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border: 1px solid $border-color;
|
||||
border-radius: 8px;
|
||||
color: $text-primary;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
resize: vertical;
|
||||
font-family: inherit;
|
||||
transition: border-color $transition-fast, box-shadow $transition-fast;
|
||||
|
||||
&::placeholder {
|
||||
color: $text-muted;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: $active-color;
|
||||
box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
|
||||
}
|
||||
}
|
||||
|
||||
.color-section {
|
||||
.color-buttons {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.color-btn {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid transparent;
|
||||
background: var(--color);
|
||||
cursor: pointer;
|
||||
transition: transform $transition-fast, border-color $transition-fast, box-shadow $transition-fast;
|
||||
position: relative;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
&.selected {
|
||||
border-color: $text-primary;
|
||||
box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
|
||||
|
||||
&::after {
|
||||
content: '\2713';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
padding: 16px 20px;
|
||||
border-top: 1px solid $border-color;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
background: linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%);
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 10px 20px;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background $transition-fast, transform $transition-fast, opacity $transition-fast;
|
||||
border: none;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: $hover-bg;
|
||||
color: $text-primary;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
}
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: $active-color;
|
||||
color: white;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: #5a9ee6;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import {Component, EventEmitter, inject, Input, Output, OnChanges, SimpleChanges} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {TranslocoService, TranslocoPipe} from '@jsverse/transloco';
|
||||
import {ReaderIconComponent} from '../../ebook-reader/shared/icon.component';
|
||||
|
||||
export interface CbxNoteDialogData {
|
||||
pageNumber: number;
|
||||
noteId?: number;
|
||||
noteContent?: string;
|
||||
color?: string;
|
||||
}
|
||||
|
||||
export interface CbxNoteDialogResult {
|
||||
noteContent: string;
|
||||
color: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-cbx-note-dialog',
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, TranslocoPipe, ReaderIconComponent],
|
||||
templateUrl: './cbx-note-dialog.component.html',
|
||||
styleUrls: ['./cbx-note-dialog.component.scss']
|
||||
})
|
||||
export class CbxNoteDialogComponent implements OnChanges {
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
@Input() data: CbxNoteDialogData | null = null;
|
||||
@Output() save = new EventEmitter<CbxNoteDialogResult>();
|
||||
@Output() cancel = new EventEmitter<void>();
|
||||
|
||||
noteContent = '';
|
||||
selectedColor = '#FFC107';
|
||||
|
||||
get isEditing(): boolean {
|
||||
return !!this.data?.noteId;
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['data'] && this.data) {
|
||||
this.noteContent = this.data.noteContent || '';
|
||||
this.selectedColor = this.data.color || '#FFC107';
|
||||
}
|
||||
}
|
||||
|
||||
get noteColors() {
|
||||
return [
|
||||
{value: '#FFC107', label: this.t.translate('readerCbx.noteDialog.colorAmber')},
|
||||
{value: '#4CAF50', label: this.t.translate('readerCbx.noteDialog.colorGreen')},
|
||||
{value: '#2196F3', label: this.t.translate('readerCbx.noteDialog.colorBlue')},
|
||||
{value: '#E91E63', label: this.t.translate('readerCbx.noteDialog.colorPink')},
|
||||
{value: '#9C27B0', label: this.t.translate('readerCbx.noteDialog.colorPurple')},
|
||||
{value: '#FF5722', label: this.t.translate('readerCbx.noteDialog.colorDeepOrange')}
|
||||
];
|
||||
}
|
||||
|
||||
onSave(): void {
|
||||
if (this.noteContent.trim()) {
|
||||
this.save.emit({
|
||||
noteContent: this.noteContent.trim(),
|
||||
color: this.selectedColor
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onCancel(): void {
|
||||
this.cancel.emit();
|
||||
}
|
||||
|
||||
selectColor(color: string): void {
|
||||
this.selectedColor = color;
|
||||
}
|
||||
|
||||
onOverlayClick(event: MouseEvent): void {
|
||||
if ((event.target as HTMLElement).classList.contains('dialog-overlay')) {
|
||||
this.onCancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<div class="dialog-overlay" (click)="onOverlayClick($event)">
|
||||
<div class="dialog">
|
||||
<div class="dialog-header">
|
||||
<h2>{{ 'readerCbx.shortcutsHelp.title' | transloco }}</h2>
|
||||
<button class="close-btn" (click)="onClose()">
|
||||
<app-reader-icon name="close" [size]="18"></app-reader-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="dialog-body">
|
||||
@for (group of shortcutGroups; track group.title) {
|
||||
<div class="shortcut-group">
|
||||
<h3 class="group-title">{{ group.title }}</h3>
|
||||
<div class="shortcuts-list">
|
||||
@for (shortcut of group.shortcuts; track shortcut.description) {
|
||||
<div class="shortcut-item">
|
||||
<div class="shortcut-keys">
|
||||
@for (key of shortcut.keys; track key; let last = $last) {
|
||||
<kbd class="key">{{ key }}</kbd>
|
||||
@if (!last) {
|
||||
<span class="key-separator">+</span>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<div class="shortcut-info">
|
||||
<span class="shortcut-description">{{ shortcut.description }}</span>
|
||||
@if (isMobile && shortcut.mobileGesture) {
|
||||
<span class="mobile-gesture">{{ shortcut.mobileGesture }}</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="dialog-footer">
|
||||
<button class="btn btn-primary" (click)="onClose()">{{ 'readerCbx.shortcutsHelp.gotIt' | transloco }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+245
@@ -0,0 +1,245 @@
|
||||
$dialog-bg: #1a1a1a;
|
||||
$text-primary: rgba(255, 255, 255, 0.95);
|
||||
$text-secondary: rgba(255, 255, 255, 0.6);
|
||||
$text-muted: rgba(255, 255, 255, 0.4);
|
||||
$border-color: rgba(255, 255, 255, 0.08);
|
||||
$hover-bg: rgba(255, 255, 255, 0.08);
|
||||
$active-color: #4a90e2;
|
||||
$transition-fast: 150ms ease;
|
||||
$transition-normal: 200ms ease;
|
||||
|
||||
.dialog-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
backdrop-filter: blur(4px);
|
||||
z-index: 13000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
animation: fadeIn $transition-normal;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
.dialog {
|
||||
background: $dialog-bg;
|
||||
border: 1px solid $border-color;
|
||||
border-radius: 12px;
|
||||
width: 90%;
|
||||
max-width: 480px;
|
||||
max-height: 85vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
|
||||
animation: slideUp 250ms cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
@keyframes slideUp {
|
||||
from {
|
||||
transform: translateY(20px);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-header {
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid $border-color;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%);
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: $text-primary;
|
||||
letter-spacing: -0.3px;
|
||||
}
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: $text-muted;
|
||||
cursor: pointer;
|
||||
padding: 6px;
|
||||
border-radius: 6px;
|
||||
transition: background $transition-fast, color $transition-fast;
|
||||
line-height: 1;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:hover {
|
||||
background: $hover-bg;
|
||||
color: $text-primary;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-body {
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 3px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.shortcut-group {
|
||||
.group-title {
|
||||
margin: 0 0 12px 0;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
color: $text-muted;
|
||||
}
|
||||
}
|
||||
|
||||
.shortcuts-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.shortcut-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 8px 12px;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border-radius: 8px;
|
||||
transition: background $transition-fast;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
}
|
||||
|
||||
.shortcut-keys {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.key {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 28px;
|
||||
height: 26px;
|
||||
padding: 0 8px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||
border-radius: 5px;
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: $text-primary;
|
||||
box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.key-separator {
|
||||
color: $text-muted;
|
||||
font-size: 12px;
|
||||
margin: 0 2px;
|
||||
}
|
||||
|
||||
.shortcut-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 2px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.shortcut-description {
|
||||
font-size: 13px;
|
||||
color: $text-secondary;
|
||||
}
|
||||
|
||||
.mobile-gesture {
|
||||
font-size: 11px;
|
||||
color: $active-color;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
padding: 16px 20px;
|
||||
border-top: 1px solid $border-color;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
background: linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%);
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 10px 24px;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background $transition-fast, transform $transition-fast;
|
||||
border: none;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: $active-color;
|
||||
color: white;
|
||||
|
||||
&:hover {
|
||||
background: #5a9ee6;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.dialog {
|
||||
width: 95%;
|
||||
max-height: 90vh;
|
||||
}
|
||||
|
||||
.shortcut-item {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.shortcut-info {
|
||||
align-items: flex-start;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
import {Component, EventEmitter, inject, Output} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {TranslocoService, TranslocoPipe} from '@jsverse/transloco';
|
||||
import {ReaderIconComponent} from '../../ebook-reader/shared/icon.component';
|
||||
|
||||
interface ShortcutItem {
|
||||
keys: string[];
|
||||
description: string;
|
||||
mobileGesture?: string;
|
||||
}
|
||||
|
||||
interface ShortcutGroup {
|
||||
title: string;
|
||||
shortcuts: ShortcutItem[];
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-cbx-shortcuts-help',
|
||||
standalone: true,
|
||||
imports: [CommonModule, TranslocoPipe, ReaderIconComponent],
|
||||
templateUrl: './cbx-shortcuts-help.component.html',
|
||||
styleUrls: ['./cbx-shortcuts-help.component.scss']
|
||||
})
|
||||
export class CbxShortcutsHelpComponent {
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
@Output() close = new EventEmitter<void>();
|
||||
|
||||
get shortcutGroups(): ShortcutGroup[] {
|
||||
return [
|
||||
{
|
||||
title: this.t.translate('readerCbx.shortcutsHelp.groupNavigation'),
|
||||
shortcuts: [
|
||||
{keys: ['←', '→'], description: this.t.translate('readerCbx.shortcutsHelp.previousNextPage'), mobileGesture: this.t.translate('readerCbx.shortcutsHelp.swipeLeftRight')},
|
||||
{keys: ['Space'], description: this.t.translate('readerCbx.shortcutsHelp.nextPage')},
|
||||
{keys: ['Shift', 'Space'], description: this.t.translate('readerCbx.shortcutsHelp.previousPage')},
|
||||
{keys: ['Home'], description: this.t.translate('readerCbx.shortcutsHelp.firstPage')},
|
||||
{keys: ['End'], description: this.t.translate('readerCbx.shortcutsHelp.lastPage')},
|
||||
{keys: ['Page Up'], description: this.t.translate('readerCbx.shortcutsHelp.previousPage')},
|
||||
{keys: ['Page Down'], description: this.t.translate('readerCbx.shortcutsHelp.nextPage')}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: this.t.translate('readerCbx.shortcutsHelp.groupDisplay'),
|
||||
shortcuts: [
|
||||
{keys: ['F'], description: this.t.translate('readerCbx.shortcutsHelp.toggleFullscreen')},
|
||||
{keys: ['D'], description: this.t.translate('readerCbx.shortcutsHelp.toggleReadingDirection')},
|
||||
{keys: ['Escape'], description: this.t.translate('readerCbx.shortcutsHelp.exitFullscreenCloseDialogs')},
|
||||
{keys: ['Double-click'], description: this.t.translate('readerCbx.shortcutsHelp.toggleZoom'), mobileGesture: this.t.translate('readerCbx.shortcutsHelp.doubleTap')},
|
||||
{keys: ['M'], description: this.t.translate('readerCbx.shortcutsHelp.toggleMagnifier')},
|
||||
{keys: ['+', '−'], description: this.t.translate('readerCbx.shortcutsHelp.magnifierZoom')},
|
||||
{keys: ['[', ']'], description: this.t.translate('readerCbx.shortcutsHelp.magnifierLensSize')}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: this.t.translate('readerCbx.shortcutsHelp.groupPlayback'),
|
||||
shortcuts: [
|
||||
{keys: ['P'], description: this.t.translate('readerCbx.shortcutsHelp.toggleSlideshow')}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: this.t.translate('readerCbx.shortcutsHelp.groupOther'),
|
||||
shortcuts: [
|
||||
{keys: ['?'], description: this.t.translate('readerCbx.shortcutsHelp.showHelpDialog')}
|
||||
]
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
isMobile = window.innerWidth < 768;
|
||||
|
||||
onClose(): void {
|
||||
this.close.emit();
|
||||
}
|
||||
|
||||
onOverlayClick(event: MouseEvent): void {
|
||||
if ((event.target as HTMLElement).classList.contains('dialog-overlay')) {
|
||||
this.onClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<div class="cbx-footer" [class.visible]="forceVisible()">
|
||||
|
||||
@if (state().hasSeries) {
|
||||
<button
|
||||
class="nav-btn series-btn"
|
||||
(click)="onPreviousBook()"
|
||||
[disabled]="!state().previousBookInSeries"
|
||||
[title]="getPreviousBookTooltip()">
|
||||
<app-reader-icon name="chevron-double-left" [size]="14" />
|
||||
<span class="label hide-on-mobile">{{ 'readerCbx.footer.prevBook' | transloco }}</span>
|
||||
</button>
|
||||
}
|
||||
|
||||
<div class="page-nav-left">
|
||||
<button class="nav-btn" (click)="onFirstPage()" [disabled]="!canGoPrevious" [title]="'readerCbx.footer.firstPage' | transloco">
|
||||
<app-reader-icon name="chevron-first" [size]="16" />
|
||||
</button>
|
||||
<button class="nav-btn" (click)="onPreviousPage()" [disabled]="!canGoPrevious" [title]="'readerCbx.footer.previousPage' | transloco">
|
||||
<app-reader-icon name="chevron-left" [size]="16" />
|
||||
</button>
|
||||
<div class="page-info">
|
||||
<span class="current">{{ displayPage }}</span>
|
||||
@if (displaySecondPage) {
|
||||
<span class="separator">-{{ displaySecondPage }}</span>
|
||||
}
|
||||
<span class="total"> {{ 'readerCbx.footer.of' | transloco }} {{ state().totalPages }}</span>
|
||||
</div>
|
||||
|
||||
<button class="nav-btn" (click)="onNextPage()" [disabled]="!canGoNext" [title]="'readerCbx.footer.nextPage' | transloco">
|
||||
<app-reader-icon name="chevron-right" [size]="16" />
|
||||
</button>
|
||||
<button class="nav-btn" (click)="onLastPage()" [disabled]="!canGoNext" [title]="'readerCbx.footer.lastPage' | transloco">
|
||||
<app-reader-icon name="chevron-last" [size]="16" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="page-controls">
|
||||
<div class="slider-wrapper">
|
||||
<input
|
||||
type="range"
|
||||
class="page-slider"
|
||||
[min]="1"
|
||||
[max]="state().totalPages"
|
||||
[value]="sliderValue"
|
||||
(input)="onSliderChange($event)"
|
||||
list="page-ticks"
|
||||
[title]="'readerCbx.footer.pageSlider' | transloco"/>
|
||||
<datalist id="page-ticks">
|
||||
@for (tick of sliderTicks; track tick) {
|
||||
<option [value]="tick"></option>
|
||||
}
|
||||
</datalist>
|
||||
</div>
|
||||
|
||||
<div class="goto-page-wrapper">
|
||||
<div class="goto-page">
|
||||
<input
|
||||
type="number"
|
||||
[(ngModel)]="goToPageInput"
|
||||
[min]="1"
|
||||
[max]="state().totalPages"
|
||||
[placeholder]="'readerCbx.footer.pagePlaceholder' | transloco"
|
||||
class="page-input"
|
||||
(keyup.enter)="onGoToPage()"
|
||||
/>
|
||||
<button
|
||||
class="go-btn"
|
||||
(click)="onGoToPage()"
|
||||
[disabled]="goToPageInput === null || goToPageInput < 1 || goToPageInput > state().totalPages">
|
||||
{{ 'readerCbx.footer.go' | transloco }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-nav-right">
|
||||
|
||||
</div>
|
||||
|
||||
@if (state().hasSeries) {
|
||||
<button
|
||||
class="nav-btn series-btn"
|
||||
(click)="onNextBook()"
|
||||
[disabled]="!state().nextBookInSeries"
|
||||
[title]="getNextBookTooltip()">
|
||||
<span class="label hide-on-mobile">{{ 'readerCbx.footer.nextBook' | transloco }}</span>
|
||||
<app-reader-icon name="chevron-double-right" [size]="14" />
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,347 @@
|
||||
@use 'sass:color';
|
||||
|
||||
// Variables
|
||||
$footer-bg: #1a1a1a;
|
||||
$text-primary: rgba(255, 255, 255, 0.95);
|
||||
$text-secondary: rgba(255, 255, 255, 0.6);
|
||||
$text-muted: rgba(255, 255, 255, 0.4);
|
||||
$border-color: rgba(255, 255, 255, 0.08);
|
||||
$hover-bg: rgba(255, 255, 255, 0.08);
|
||||
$active-color: #4a90e2;
|
||||
$transition-fast: 150ms ease;
|
||||
|
||||
.cbx-footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 52px;
|
||||
padding: 0 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
z-index: 1000;
|
||||
background: linear-gradient(135deg, #2d2d2d 0%, #1f1f1f 100%);
|
||||
border-top: 1px solid #404040;
|
||||
box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
|
||||
color: $text-primary;
|
||||
transform: translateY(100%);
|
||||
opacity: 0;
|
||||
transition: transform 0.3s ease, opacity 0.3s ease;
|
||||
pointer-events: none;
|
||||
|
||||
&.visible {
|
||||
transform: translateY(0);
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.page-nav-left,
|
||||
.page-nav-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.series-nav {
|
||||
flex: 0 0 auto;
|
||||
min-width: 110px;
|
||||
}
|
||||
|
||||
.page-nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.nav-btn {
|
||||
background: rgba(51, 51, 51, 0.9);
|
||||
border: 1px solid #555;
|
||||
color: $text-primary;
|
||||
padding: 6px 10px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: all $transition-fast;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: #4a4a4a;
|
||||
border-color: #666;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
background: #2a2a2a;
|
||||
color: #666;
|
||||
cursor: not-allowed;
|
||||
border-color: #333;
|
||||
}
|
||||
|
||||
&.series-btn {
|
||||
gap: 6px;
|
||||
padding: 6px 12px;
|
||||
background: $active-color;
|
||||
border-color: $active-color;
|
||||
|
||||
.label {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: color.adjust($active-color, $lightness: -10%);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
background: #555;
|
||||
border-color: #555;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.page-info {
|
||||
padding: 4px 12px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
min-width: 90px;
|
||||
text-align: center;
|
||||
|
||||
.current {
|
||||
color: $active-color;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.separator {
|
||||
color: $active-color;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.total {
|
||||
color: $text-secondary;
|
||||
}
|
||||
}
|
||||
|
||||
.page-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex: 1;
|
||||
justify-content: center;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.slider-wrapper {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
|
||||
.page-slider {
|
||||
width: 100%;
|
||||
border-radius: 3px;
|
||||
outline: none;
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
|
||||
/* ===== Track ===== */
|
||||
&::-webkit-slider-runnable-track {
|
||||
width: 100%;
|
||||
height: 6px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&::-moz-range-track {
|
||||
width: 100%;
|
||||
height: 6px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&::-ms-fill-lower,
|
||||
&::-ms-fill-upper {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* ===== Thumb ===== */
|
||||
&::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 50%;
|
||||
background: $active-color;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
|
||||
transition: transform $transition-fast, box-shadow $transition-fast;
|
||||
margin-top: calc((6px - 18px) / 2); /* center thumb on track */
|
||||
}
|
||||
|
||||
&::-moz-range-thumb {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 50%;
|
||||
background: $active-color;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
|
||||
transition: transform $transition-fast, box-shadow $transition-fast;
|
||||
margin-top: calc((6px - 18px) / 2);
|
||||
}
|
||||
|
||||
&::-ms-thumb {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 50%;
|
||||
background: $active-color;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== Tick marks ===== */
|
||||
datalist {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
left: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
pointer-events: none;
|
||||
height: 10px;
|
||||
box-sizing: border-box;
|
||||
|
||||
option {
|
||||
width: 0;
|
||||
position: relative;
|
||||
padding: 0;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 2px;
|
||||
height: 10px;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.goto-page {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
background: rgba(51, 51, 51, 0.9);
|
||||
border-radius: 4px;
|
||||
padding: 2px;
|
||||
border: 1px solid #555;
|
||||
|
||||
.page-input {
|
||||
width: 55px;
|
||||
padding: 4px 6px;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
background: #404040;
|
||||
color: $text-primary;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
background: #4a4a4a;
|
||||
box-shadow: 0 0 0 1px rgba(74, 144, 226, 0.5);
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
.go-btn {
|
||||
padding: 4px 10px;
|
||||
background: $active-color;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: color.adjust($active-color, $lightness: -10%);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
background: #666;
|
||||
cursor: not-allowed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.cbx-footer {
|
||||
height: 48px;
|
||||
padding: 0 8px;
|
||||
gap: 8px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.page-nav-left .series-btn,
|
||||
.page-nav-right .series-btn {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.page-nav-left {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.page-nav-right {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.page-nav-left {
|
||||
margin: 0 auto;
|
||||
justify-content: center;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.page-controls {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.slider-wrapper {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.goto-page-wrapper {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.hide-on-mobile {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {TranslocoService, TranslocoPipe} from '@jsverse/transloco';
|
||||
import {Book} from '../../../../book/model/book.model';
|
||||
import {ReaderIconComponent} from '../../../ebook-reader/shared/icon.component';
|
||||
import {CbxFooterService} from './cbx-footer.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cbx-footer',
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, TranslocoPipe, ReaderIconComponent],
|
||||
templateUrl: './cbx-footer.component.html',
|
||||
styleUrls: ['./cbx-footer.component.scss']
|
||||
})
|
||||
export class CbxFooterComponent {
|
||||
private readonly footerService = inject(CbxFooterService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
readonly forceVisible = this.footerService.forceVisible;
|
||||
readonly state = this.footerService.state;
|
||||
|
||||
goToPageInput: number | null = null;
|
||||
|
||||
get displayPage(): number {
|
||||
return this.state().currentPage + 1;
|
||||
}
|
||||
|
||||
get displaySecondPage(): number | null {
|
||||
const state = this.state();
|
||||
if (state.isTwoPageView && state.currentPage + 1 < state.totalPages) {
|
||||
return state.currentPage + 2;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
get sliderValue(): number {
|
||||
return this.displayPage;
|
||||
}
|
||||
|
||||
get canGoPrevious(): boolean {
|
||||
return this.state().currentPage > 0;
|
||||
}
|
||||
|
||||
get canGoNext(): boolean {
|
||||
const state = this.state();
|
||||
return state.currentPage < state.totalPages - 1;
|
||||
}
|
||||
|
||||
get sliderTicks(): number[] {
|
||||
const totalPages = this.state().totalPages;
|
||||
if (totalPages <= 10) {
|
||||
return Array.from({length: totalPages}, (_, i) => i + 1);
|
||||
} else if (totalPages <= 20) {
|
||||
return Array.from({length: totalPages}, (_, i) => i + 1);
|
||||
} else if (totalPages <= 50) {
|
||||
const ticks: number[] = [];
|
||||
for (let i = 1; i <= totalPages; i += 2) {
|
||||
ticks.push(i);
|
||||
}
|
||||
if (!ticks.includes(totalPages)) {
|
||||
ticks.push(totalPages);
|
||||
}
|
||||
return ticks;
|
||||
} else if (totalPages <= 100) {
|
||||
const ticks: number[] = [];
|
||||
const step = 5;
|
||||
for (let i = 1; i <= totalPages; i += step) {
|
||||
ticks.push(i);
|
||||
}
|
||||
if (!ticks.includes(totalPages)) {
|
||||
ticks.push(totalPages);
|
||||
}
|
||||
return ticks;
|
||||
} else {
|
||||
const ticks: number[] = [];
|
||||
const step = Math.ceil(totalPages / 20);
|
||||
for (let i = 1; i <= totalPages; i += step) {
|
||||
ticks.push(i);
|
||||
}
|
||||
if (!ticks.includes(totalPages)) {
|
||||
ticks.push(totalPages);
|
||||
}
|
||||
return ticks;
|
||||
}
|
||||
}
|
||||
|
||||
onPreviousPage(): void {
|
||||
this.footerService.emitPreviousPage();
|
||||
}
|
||||
|
||||
onNextPage(): void {
|
||||
this.footerService.emitNextPage();
|
||||
}
|
||||
|
||||
onFirstPage(): void {
|
||||
this.footerService.emitFirstPage();
|
||||
}
|
||||
|
||||
onLastPage(): void {
|
||||
this.footerService.emitLastPage();
|
||||
}
|
||||
|
||||
onGoToPage(): void {
|
||||
if (this.goToPageInput !== null && this.goToPageInput >= 1 && this.goToPageInput <= this.state().totalPages) {
|
||||
this.footerService.emitGoToPage(this.goToPageInput);
|
||||
this.goToPageInput = null;
|
||||
}
|
||||
}
|
||||
|
||||
onSliderChange(event: Event): void {
|
||||
const target = event.target as HTMLInputElement;
|
||||
const page = parseInt(target.value, 10);
|
||||
this.footerService.emitSliderChange(page);
|
||||
}
|
||||
|
||||
onPreviousBook(): void {
|
||||
this.footerService.emitPreviousBook();
|
||||
}
|
||||
|
||||
onNextBook(): void {
|
||||
this.footerService.emitNextBook();
|
||||
}
|
||||
|
||||
getPreviousBookTooltip(): string {
|
||||
const previousBookInSeries = this.state().previousBookInSeries;
|
||||
if (!previousBookInSeries) return this.t.translate('readerCbx.footer.noPreviousBook');
|
||||
return this.t.translate('readerCbx.footer.previousBookTooltip', {title: this.getBookDisplayTitle(previousBookInSeries)});
|
||||
}
|
||||
|
||||
getNextBookTooltip(): string {
|
||||
const nextBookInSeries = this.state().nextBookInSeries;
|
||||
if (!nextBookInSeries) return this.t.translate('readerCbx.footer.noNextBook');
|
||||
return this.t.translate('readerCbx.footer.nextBookTooltip', {title: this.getBookDisplayTitle(nextBookInSeries)});
|
||||
}
|
||||
|
||||
private getBookDisplayTitle(book: Book): string {
|
||||
const parts: string[] = [];
|
||||
if (book.metadata?.seriesNumber) {
|
||||
parts.push(`#${book.metadata.seriesNumber}`);
|
||||
}
|
||||
const title = book.metadata?.title || book.fileName;
|
||||
if (title) {
|
||||
parts.push(title);
|
||||
}
|
||||
return parts.join(' - ');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
import {Injectable, signal} from '@angular/core';
|
||||
import {Subject} from 'rxjs';
|
||||
import {Book} from '../../../../book/model/book.model';
|
||||
|
||||
export interface CbxFooterState {
|
||||
currentPage: number;
|
||||
totalPages: number;
|
||||
isTwoPageView: boolean;
|
||||
previousBookInSeries: Book | null;
|
||||
nextBookInSeries: Book | null;
|
||||
hasSeries: boolean;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class CbxFooterService {
|
||||
private readonly defaultState: CbxFooterState = {
|
||||
currentPage: 0,
|
||||
totalPages: 0,
|
||||
isTwoPageView: false,
|
||||
previousBookInSeries: null,
|
||||
nextBookInSeries: null,
|
||||
hasSeries: false
|
||||
};
|
||||
|
||||
private readonly _state = signal<CbxFooterState>(this.defaultState);
|
||||
readonly state = this._state.asReadonly();
|
||||
|
||||
private readonly _forceVisible = signal(false);
|
||||
readonly forceVisible = this._forceVisible.asReadonly();
|
||||
|
||||
private _previousPage = new Subject<void>();
|
||||
previousPage$ = this._previousPage.asObservable();
|
||||
|
||||
private _nextPage = new Subject<void>();
|
||||
nextPage$ = this._nextPage.asObservable();
|
||||
|
||||
private _goToPage = new Subject<number>();
|
||||
goToPage$ = this._goToPage.asObservable();
|
||||
|
||||
private _firstPage = new Subject<void>();
|
||||
firstPage$ = this._firstPage.asObservable();
|
||||
|
||||
private _lastPage = new Subject<void>();
|
||||
lastPage$ = this._lastPage.asObservable();
|
||||
|
||||
private _previousBook = new Subject<void>();
|
||||
previousBook$ = this._previousBook.asObservable();
|
||||
|
||||
private _nextBook = new Subject<void>();
|
||||
nextBook$ = this._nextBook.asObservable();
|
||||
|
||||
private _sliderChange = new Subject<number>();
|
||||
sliderChange$ = this._sliderChange.asObservable();
|
||||
|
||||
setForceVisible(visible: boolean): void {
|
||||
this._forceVisible.set(visible);
|
||||
}
|
||||
|
||||
updateState(partial: Partial<CbxFooterState>): void {
|
||||
this._state.update(current => ({...current, ...partial}));
|
||||
}
|
||||
|
||||
setCurrentPage(page: number): void {
|
||||
this.updateState({currentPage: page});
|
||||
}
|
||||
|
||||
setTotalPages(total: number): void {
|
||||
this.updateState({totalPages: total});
|
||||
}
|
||||
|
||||
setTwoPageView(isTwoPage: boolean): void {
|
||||
this.updateState({isTwoPageView: isTwoPage});
|
||||
}
|
||||
|
||||
setSeriesBooks(previous: Book | null, next: Book | null): void {
|
||||
this.updateState({
|
||||
previousBookInSeries: previous,
|
||||
nextBookInSeries: next
|
||||
});
|
||||
}
|
||||
|
||||
setHasSeries(hasSeries: boolean): void {
|
||||
this.updateState({hasSeries});
|
||||
}
|
||||
|
||||
// Navigation actions (called from footer component)
|
||||
emitPreviousPage(): void {
|
||||
this._previousPage.next();
|
||||
}
|
||||
|
||||
emitNextPage(): void {
|
||||
this._nextPage.next();
|
||||
}
|
||||
|
||||
emitGoToPage(page: number): void {
|
||||
this._goToPage.next(page);
|
||||
}
|
||||
|
||||
emitFirstPage(): void {
|
||||
this._firstPage.next();
|
||||
}
|
||||
|
||||
emitLastPage(): void {
|
||||
this._lastPage.next();
|
||||
}
|
||||
|
||||
emitPreviousBook(): void {
|
||||
this._previousBook.next();
|
||||
}
|
||||
|
||||
emitNextBook(): void {
|
||||
this._nextBook.next();
|
||||
}
|
||||
|
||||
emitSliderChange(page: number): void {
|
||||
this._sliderChange.next(page);
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this._state.set(this.defaultState);
|
||||
this._forceVisible.set(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<div class="cbx-header" [class.visible]="forceVisible()">
|
||||
<div class="header-left">
|
||||
<button class="icon-btn" (click)="onOpenSidebar()" [title]="'readerCbx.header.contents' | transloco">
|
||||
<app-reader-icon name="menu" [size]="20" />
|
||||
</button>
|
||||
<button class="icon-btn" (click)="onToggleBookmark()" [title]="isCurrentPageBookmarked ? ('readerCbx.header.removeBookmark' | transloco) : ('readerCbx.header.addBookmark' | transloco)" [class.active]="isCurrentPageBookmarked">
|
||||
<app-reader-icon name="bookmark" [size]="20" />
|
||||
</button>
|
||||
<button class="icon-btn" (click)="onOpenNoteDialog()" [title]="currentPageHasNotes ? ('readerCbx.header.pageHasNotesAddAnother' | transloco) : ('readerCbx.header.addNote' | transloco)" [class.has-notes]="currentPageHasNotes">
|
||||
<app-reader-icon name="note" [size]="20" />
|
||||
@if (currentPageHasNotes) {
|
||||
<span class="indicator-dot"></span>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
<span class="book-title">{{ bookTitle() }}</span>
|
||||
<div class="header-right">
|
||||
<button class="icon-btn desktop-only" (click)="onToggleMagnifier()" [title]="state().isMagnifierActive ? ('readerCbx.header.disableMagnifier' | transloco) : ('readerCbx.header.enableMagnifier' | transloco)" [class.active]="state().isMagnifierActive">
|
||||
<app-reader-icon name="magnifier" [size]="20" />
|
||||
</button>
|
||||
<button class="icon-btn desktop-only" (click)="onToggleSlideshow()" [title]="state().isSlideshowActive ? ('readerCbx.header.stopSlideshow' | transloco) : ('readerCbx.header.startSlideshow' | transloco)" [class.active]="state().isSlideshowActive">
|
||||
<app-reader-icon [name]="state().isSlideshowActive ? 'pause' : 'play'" [size]="20" />
|
||||
</button>
|
||||
<button class="icon-btn desktop-only" (click)="onToggleFullscreen()" [title]="state().isFullscreen ? ('readerCbx.header.exitFullscreen' | transloco) : ('readerCbx.header.fullscreen' | transloco)">
|
||||
<app-reader-icon [name]="state().isFullscreen ? 'fullscreen-exit' : 'fullscreen'" [size]="20" />
|
||||
</button>
|
||||
<button class="icon-btn desktop-only" (click)="onShowShortcutsHelp()" [title]="'readerCbx.header.keyboardShortcuts' | transloco">
|
||||
<app-reader-icon name="help" [size]="20" />
|
||||
</button>
|
||||
<div class="overflow-menu mobile-only">
|
||||
<button class="icon-btn" (click)="overflowOpen = !overflowOpen; $event.stopPropagation()" [title]="'readerCbx.header.more' | transloco">
|
||||
<app-reader-icon name="dots-vertical" [size]="20" />
|
||||
</button>
|
||||
@if (overflowOpen) {
|
||||
<div class="overflow-backdrop" (click)="overflowOpen = false"></div>
|
||||
<div class="overflow-dropdown">
|
||||
<button class="overflow-item" (click)="onToggleSlideshow(); overflowOpen = false" [class.active]="state().isSlideshowActive">
|
||||
<app-reader-icon [name]="state().isSlideshowActive ? 'pause' : 'play'" [size]="18" />
|
||||
<span>{{ state().isSlideshowActive ? ('readerCbx.header.stopSlideshowLabel' | transloco) : ('readerCbx.header.startSlideshowLabel' | transloco) }}</span>
|
||||
</button>
|
||||
<button class="overflow-item" (click)="onToggleFullscreen(); overflowOpen = false">
|
||||
<app-reader-icon [name]="state().isFullscreen ? 'fullscreen-exit' : 'fullscreen'" [size]="18" />
|
||||
<span>{{ state().isFullscreen ? ('readerCbx.header.exitFullscreenLabel' | transloco) : ('readerCbx.header.fullscreenLabel' | transloco) }}</span>
|
||||
</button>
|
||||
<button class="overflow-item" (click)="onShowShortcutsHelp(); overflowOpen = false">
|
||||
<app-reader-icon name="help" [size]="18" />
|
||||
<span>{{ 'readerCbx.header.keyboardShortcutsLabel' | transloco }}</span>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<button class="icon-btn" (click)="onOpenSettings()" [title]="'readerCbx.header.settings' | transloco">
|
||||
<app-reader-icon name="settings" [size]="20" />
|
||||
</button>
|
||||
<button class="icon-btn close-btn" (click)="onClose(); $event.stopPropagation()" [title]="'readerCbx.header.closeReader' | transloco">
|
||||
<app-reader-icon name="close" [size]="20" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,187 @@
|
||||
.cbx-header {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 38px;
|
||||
padding: 0 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: 14px;
|
||||
z-index: 1000;
|
||||
background: linear-gradient(135deg, #2d2d2d 0%, #1f1f1f 100%);
|
||||
border-bottom: 1px solid #404040;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
||||
color: #ffffff;
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
transform: translateY(0);
|
||||
transition: opacity 0.25s ease-out, transform 0.25s ease-out;
|
||||
|
||||
&:not(.visible) {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transform: translateY(-100%);
|
||||
}
|
||||
|
||||
.header-left,
|
||||
.header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.icon-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
padding: 8px;
|
||||
border-radius: 6px;
|
||||
transition: background 0.15s, box-shadow 0.15s;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 8px;
|
||||
|
||||
.icon {
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
&.close-btn {
|
||||
.icon {
|
||||
font-size: 22px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: rgba(239, 68, 68, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: #ef4444;
|
||||
background: rgba(239, 68, 68, 0.15);
|
||||
}
|
||||
|
||||
&.has-notes {
|
||||
color: #ffc107;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.indicator-dot {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 4px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background: #ffc107;
|
||||
border-radius: 50%;
|
||||
border: 1px solid #1f1f1f;
|
||||
}
|
||||
}
|
||||
|
||||
.book-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
padding: 0 12px;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: inherit;
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.mobile-only {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.overflow-menu {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.overflow-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.overflow-dropdown {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
margin-top: 4px;
|
||||
background: #2d2d2d;
|
||||
border: 1px solid #404040;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
|
||||
z-index: 1000;
|
||||
min-width: 180px;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.overflow-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
padding: 8px 12px;
|
||||
background: none;
|
||||
border: none;
|
||||
color: #ffffff;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
border-radius: 6px;
|
||||
white-space: nowrap;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: #ef4444;
|
||||
background: rgba(239, 68, 68, 0.15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.cbx-header {
|
||||
padding: 0 4px;
|
||||
|
||||
.icon-btn {
|
||||
padding: 5px;
|
||||
margin-right: 6px;
|
||||
|
||||
app-reader-icon {
|
||||
transform: scale(0.9);
|
||||
}
|
||||
}
|
||||
|
||||
.book-title {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.desktop-only {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mobile-only {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import {Component, inject, Input} from '@angular/core';
|
||||
import {TranslocoPipe} from '@jsverse/transloco';
|
||||
import {CbxHeaderService} from './cbx-header.service';
|
||||
import {ReaderIconComponent} from '../../../ebook-reader';
|
||||
import {CommonModule} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cbx-header',
|
||||
standalone: true,
|
||||
imports: [CommonModule, TranslocoPipe, ReaderIconComponent],
|
||||
templateUrl: './cbx-header.component.html',
|
||||
styleUrls: ['./cbx-header.component.scss']
|
||||
})
|
||||
export class CbxHeaderComponent {
|
||||
private readonly headerService = inject(CbxHeaderService);
|
||||
|
||||
@Input() isCurrentPageBookmarked = false;
|
||||
@Input() currentPageHasNotes = false;
|
||||
|
||||
readonly forceVisible = this.headerService.forceVisible;
|
||||
readonly state = this.headerService.state;
|
||||
readonly bookTitle = this.headerService.bookTitle;
|
||||
|
||||
overflowOpen = false;
|
||||
|
||||
onOpenSidebar(): void {
|
||||
this.headerService.openSidebar();
|
||||
}
|
||||
|
||||
onOpenSettings(): void {
|
||||
this.headerService.openQuickSettings();
|
||||
}
|
||||
|
||||
onToggleBookmark(): void {
|
||||
this.headerService.toggleBookmark();
|
||||
}
|
||||
|
||||
onOpenNoteDialog(): void {
|
||||
this.headerService.openNoteDialog();
|
||||
}
|
||||
|
||||
onToggleFullscreen(): void {
|
||||
this.headerService.toggleFullscreen();
|
||||
}
|
||||
|
||||
onToggleSlideshow(): void {
|
||||
this.headerService.toggleSlideshow();
|
||||
}
|
||||
|
||||
onToggleMagnifier(): void {
|
||||
this.headerService.toggleMagnifier();
|
||||
}
|
||||
|
||||
onShowShortcutsHelp(): void {
|
||||
this.headerService.showShortcutsHelp();
|
||||
}
|
||||
|
||||
onClose(): void {
|
||||
this.headerService.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import {inject, Injectable, signal} from '@angular/core';
|
||||
import {Location} from '@angular/common';
|
||||
import {Subject} from 'rxjs';
|
||||
import {CbxSidebarService} from '../sidebar/cbx-sidebar.service';
|
||||
|
||||
export interface CbxHeaderState {
|
||||
isFullscreen: boolean;
|
||||
isSlideshowActive: boolean;
|
||||
isMagnifierActive: boolean;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class CbxHeaderService {
|
||||
private readonly defaultState: CbxHeaderState = {
|
||||
isFullscreen: false,
|
||||
isSlideshowActive: false,
|
||||
isMagnifierActive: false
|
||||
};
|
||||
|
||||
private sidebarService = inject(CbxSidebarService);
|
||||
private location = inject(Location);
|
||||
|
||||
private readonly _bookTitle = signal('');
|
||||
readonly bookTitle = this._bookTitle.asReadonly();
|
||||
|
||||
private readonly _forceVisible = signal(true);
|
||||
readonly forceVisible = this._forceVisible.asReadonly();
|
||||
|
||||
private readonly _state = signal<CbxHeaderState>(this.defaultState);
|
||||
readonly state = this._state.asReadonly();
|
||||
|
||||
private _showQuickSettings = new Subject<void>();
|
||||
showQuickSettings$ = this._showQuickSettings.asObservable();
|
||||
|
||||
private _toggleBookmark = new Subject<void>();
|
||||
toggleBookmark$ = this._toggleBookmark.asObservable();
|
||||
|
||||
private _openNoteDialog = new Subject<void>();
|
||||
openNoteDialog$ = this._openNoteDialog.asObservable();
|
||||
|
||||
private _toggleFullscreen = new Subject<void>();
|
||||
toggleFullscreen$ = this._toggleFullscreen.asObservable();
|
||||
|
||||
private _toggleSlideshow = new Subject<void>();
|
||||
toggleSlideshow$ = this._toggleSlideshow.asObservable();
|
||||
|
||||
private _toggleMagnifier = new Subject<void>();
|
||||
toggleMagnifier$ = this._toggleMagnifier.asObservable();
|
||||
|
||||
private _showShortcutsHelp = new Subject<void>();
|
||||
showShortcutsHelp$ = this._showShortcutsHelp.asObservable();
|
||||
|
||||
initialize(title: string | undefined): void {
|
||||
this._bookTitle.set(title || '');
|
||||
}
|
||||
|
||||
setForceVisible(visible: boolean): void {
|
||||
this._forceVisible.set(visible);
|
||||
}
|
||||
|
||||
updateState(partial: Partial<CbxHeaderState>): void {
|
||||
this._state.update(current => ({...current, ...partial}));
|
||||
}
|
||||
|
||||
openSidebar(): void {
|
||||
this.sidebarService.open();
|
||||
}
|
||||
|
||||
openQuickSettings(): void {
|
||||
this._showQuickSettings.next();
|
||||
}
|
||||
|
||||
toggleBookmark(): void {
|
||||
this._toggleBookmark.next();
|
||||
}
|
||||
|
||||
openNoteDialog(): void {
|
||||
this._openNoteDialog.next();
|
||||
}
|
||||
|
||||
toggleFullscreen(): void {
|
||||
this._toggleFullscreen.next();
|
||||
}
|
||||
|
||||
toggleSlideshow(): void {
|
||||
this._toggleSlideshow.next();
|
||||
}
|
||||
|
||||
toggleMagnifier(): void {
|
||||
this._toggleMagnifier.next();
|
||||
}
|
||||
|
||||
showShortcutsHelp(): void {
|
||||
this._showShortcutsHelp.next();
|
||||
}
|
||||
|
||||
close(): void {
|
||||
this.location.back();
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this._forceVisible.set(true);
|
||||
this._state.set(this.defaultState);
|
||||
this._bookTitle.set('');
|
||||
}
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
<div class="quick-settings-overlay" (click)="onOverlayClick()">
|
||||
<div class="quick-settings-panel" (click)="$event.stopPropagation()">
|
||||
<div class="pointer"></div>
|
||||
<div class="panel-body">
|
||||
<!-- Fit Mode -->
|
||||
<div class="control">
|
||||
<label>{{ 'readerCbx.quickSettings.fitMode' | transloco }}</label>
|
||||
<div class="control-right">
|
||||
<div class="button-group">
|
||||
@for (option of fitModeOptions; track option.value) {
|
||||
<button
|
||||
class="option-btn"
|
||||
[class.active]="state().fitMode === option.value"
|
||||
(click)="onFitModeSelect(option.value)"
|
||||
[title]="option.label">
|
||||
<app-reader-icon [name]="option.icon" [size]="16" />
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Scroll Mode -->
|
||||
<div class="control">
|
||||
<label>{{ 'readerCbx.quickSettings.scrollMode' | transloco }}</label>
|
||||
<div class="control-right">
|
||||
<div class="button-group text-btns">
|
||||
@for (option of scrollModeOptions; track option.value) {
|
||||
<button
|
||||
class="option-btn text-btn"
|
||||
[class.active]="state().scrollMode === option.value"
|
||||
(click)="onScrollModeSelect(option.value)"
|
||||
[title]="option.label">
|
||||
{{ option.label }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Page View (only in paginated mode) -->
|
||||
@if (isPaginated && !isPhonePortrait) {
|
||||
<div class="control">
|
||||
<label>{{ 'readerCbx.quickSettings.pageView' | transloco }}</label>
|
||||
<div class="control-right">
|
||||
<span class="mode-label">{{ isTwoPageView ? ('readerCbx.quickSettings.twoPage' | transloco) : ('readerCbx.quickSettings.single' | transloco) }}</span>
|
||||
<button class="switch" [class.active]="isTwoPageView" (click)="onPageViewToggle()">
|
||||
<span class="slider"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Page Spread (only in two-page mode) -->
|
||||
@if (isPaginated && isTwoPageView) {
|
||||
<div class="control">
|
||||
<label>{{ 'readerCbx.quickSettings.pageSpread' | transloco }}</label>
|
||||
<div class="control-right">
|
||||
<span class="mode-label">{{ state().pageSpread === CbxPageSpread.ODD ? ('readerCbx.quickSettings.oddFirst' | transloco) : ('readerCbx.quickSettings.evenFirst' | transloco) }}</span>
|
||||
<button class="switch" [class.active]="state().pageSpread === CbxPageSpread.EVEN" (click)="onPageSpreadToggle()">
|
||||
<span class="slider"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Reading Direction -->
|
||||
<div class="control">
|
||||
<label>{{ 'readerCbx.quickSettings.readingDirection' | transloco }}</label>
|
||||
<div class="control-right">
|
||||
<span class="mode-label">{{ state().readingDirection === CbxReadingDirection.LTR ? ('readerCbx.quickSettings.leftToRight' | transloco) : ('readerCbx.quickSettings.rightToLeft' | transloco) }}</span>
|
||||
<button class="switch" [class.active]="state().readingDirection === CbxReadingDirection.RTL" (click)="onReadingDirectionToggle()">
|
||||
<span class="slider"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Slideshow Interval -->
|
||||
<div class="control">
|
||||
<label>{{ 'readerCbx.quickSettings.slideshowInterval' | transloco }}</label>
|
||||
<div class="control-right">
|
||||
<div class="button-group text-btns">
|
||||
@for (option of slideshowIntervalOptions; track option.value) {
|
||||
<button
|
||||
class="option-btn text-btn small"
|
||||
[class.active]="state().slideshowInterval === option.value"
|
||||
(click)="onSlideshowIntervalSelect(option.value)"
|
||||
[title]="option.label">
|
||||
{{ option.label }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Background Color -->
|
||||
<div class="control">
|
||||
<label>{{ 'readerCbx.quickSettings.background' | transloco }}</label>
|
||||
<div class="control-right">
|
||||
<div class="button-group">
|
||||
@for (option of backgroundOptions; track option.value) {
|
||||
<button
|
||||
class="option-btn color-btn"
|
||||
[class.active]="state().backgroundColor === option.value"
|
||||
(click)="onBackgroundSelect(option.value)"
|
||||
[title]="option.label">
|
||||
<span class="color-swatch" [style.background]="option.color"></span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Magnifier Lens Size -->
|
||||
<div class="control">
|
||||
<label>{{ 'readerCbx.quickSettings.magnifierLensSize' | transloco }}</label>
|
||||
<div class="control-right">
|
||||
<div class="button-group text-btns">
|
||||
@for (option of magnifierLensSizeOptions; track option.value) {
|
||||
<button
|
||||
class="option-btn text-btn small"
|
||||
[class.active]="state().magnifierLensSize === option.value"
|
||||
(click)="onMagnifierLensSizeSelect(option.value)"
|
||||
[title]="option.label">
|
||||
{{ option.label }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Magnifier Zoom -->
|
||||
<div class="control">
|
||||
<label>{{ 'readerCbx.quickSettings.magnifierZoom' | transloco }}</label>
|
||||
<div class="control-right">
|
||||
<div class="button-group text-btns">
|
||||
@for (option of magnifierZoomOptions; track option.value) {
|
||||
<button
|
||||
class="option-btn text-btn small"
|
||||
[class.active]="state().magnifierZoom === option.value"
|
||||
(click)="onMagnifierZoomSelect(option.value)"
|
||||
[title]="option.label">
|
||||
{{ option.label }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+222
@@ -0,0 +1,222 @@
|
||||
@use 'sass:color';
|
||||
|
||||
// Variables
|
||||
$panel-bg: #1a1a1a;
|
||||
$text-primary: rgba(255, 255, 255, 0.95);
|
||||
$text-secondary: rgba(255, 255, 255, 0.6);
|
||||
$text-muted: rgba(255, 255, 255, 0.4);
|
||||
$border-color: rgba(255, 255, 255, 0.08);
|
||||
$hover-bg: rgba(255, 255, 255, 0.08);
|
||||
$active-color: #4a90e2;
|
||||
$active-bg: rgba(74, 144, 226, 0.15);
|
||||
$transition-fast: 150ms ease;
|
||||
$transition-normal: 200ms ease;
|
||||
|
||||
.quick-settings-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 12000;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
animation: fadeIn $transition-normal;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
.quick-settings-panel {
|
||||
position: absolute;
|
||||
top: 52px;
|
||||
right: 60px;
|
||||
width: 340px;
|
||||
background: $panel-bg;
|
||||
border: 1px solid $border-color;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
|
||||
animation: slideDown 200ms cubic-bezier(0.4, 0, 0.2, 1);
|
||||
overflow: visible;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
@keyframes slideDown {
|
||||
from {
|
||||
transform: translateY(-8px);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Pointer arrow
|
||||
.pointer {
|
||||
position: absolute;
|
||||
top: -8px;
|
||||
right: 18px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background: $panel-bg;
|
||||
border-left: 1px solid $border-color;
|
||||
border-top: 1px solid $border-color;
|
||||
transform: rotate(45deg);
|
||||
border-radius: 3px 0 0 0;
|
||||
}
|
||||
|
||||
.panel-body {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.control {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 0;
|
||||
|
||||
&:not(:last-child) {
|
||||
border-bottom: 1px solid $border-color;
|
||||
}
|
||||
|
||||
> label {
|
||||
color: $text-primary;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.control-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.mode-label {
|
||||
font-size: 12px;
|
||||
color: $text-secondary;
|
||||
min-width: 60px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
// Toggle switch
|
||||
.switch {
|
||||
position: relative;
|
||||
width: 40px;
|
||||
height: 22px;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border: none;
|
||||
border-radius: 11px;
|
||||
cursor: pointer;
|
||||
transition: background 300ms ease;
|
||||
padding: 0;
|
||||
|
||||
&.active {
|
||||
background: $active-color;
|
||||
|
||||
.slider {
|
||||
transform: translateX(18px);
|
||||
}
|
||||
}
|
||||
|
||||
.slider {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
left: 2px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
background: #ffffff;
|
||||
border-radius: 50%;
|
||||
transition: transform 300ms ease;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
|
||||
&.active {
|
||||
background: color.adjust($active-color, $lightness: 5%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Button group
|
||||
.button-group {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
padding: 3px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid $border-color;
|
||||
}
|
||||
|
||||
.option-btn {
|
||||
width: 32px;
|
||||
height: 28px;
|
||||
background: transparent;
|
||||
color: $text-secondary;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all $transition-fast;
|
||||
|
||||
&:hover {
|
||||
background: $hover-bg;
|
||||
color: $text-primary;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: $active-color;
|
||||
color: white;
|
||||
}
|
||||
|
||||
&.text-btn {
|
||||
width: auto;
|
||||
padding: 0 10px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
|
||||
&.small {
|
||||
padding: 0 6px;
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
&.color-btn {
|
||||
padding: 4px;
|
||||
|
||||
&.active {
|
||||
background: transparent;
|
||||
box-shadow: 0 0 0 2px $active-color;
|
||||
}
|
||||
}
|
||||
|
||||
.color-swatch {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
.text-btns {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.quick-settings-panel {
|
||||
right: 16px;
|
||||
left: 16px;
|
||||
width: auto;
|
||||
top: 56px;
|
||||
}
|
||||
|
||||
.pointer {
|
||||
right: 30px;
|
||||
}
|
||||
}
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {TranslocoService, TranslocoPipe} from '@jsverse/transloco';
|
||||
import {
|
||||
CbxFitMode,
|
||||
CbxScrollMode,
|
||||
CbxPageViewMode,
|
||||
CbxPageSpread,
|
||||
CbxBackgroundColor,
|
||||
CbxReadingDirection,
|
||||
CbxSlideshowInterval,
|
||||
CbxMagnifierZoom,
|
||||
CbxMagnifierLensSize
|
||||
} from '../../../../settings/user-management/user.service';
|
||||
import {ReaderIconComponent, ReaderIconName} from '../../../ebook-reader/shared/icon.component';
|
||||
import {CbxQuickSettingsService} from './cbx-quick-settings.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cbx-quick-settings',
|
||||
standalone: true,
|
||||
imports: [CommonModule, TranslocoPipe, ReaderIconComponent],
|
||||
templateUrl: './cbx-quick-settings.component.html',
|
||||
styleUrls: ['./cbx-quick-settings.component.scss']
|
||||
})
|
||||
export class CbxQuickSettingsComponent {
|
||||
private readonly quickSettingsService = inject(CbxQuickSettingsService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
readonly state = this.quickSettingsService.state;
|
||||
|
||||
protected readonly CbxFitMode = CbxFitMode;
|
||||
protected readonly CbxScrollMode = CbxScrollMode;
|
||||
protected readonly CbxPageViewMode = CbxPageViewMode;
|
||||
protected readonly CbxPageSpread = CbxPageSpread;
|
||||
protected readonly CbxBackgroundColor = CbxBackgroundColor;
|
||||
protected readonly CbxReadingDirection = CbxReadingDirection;
|
||||
protected readonly CbxSlideshowInterval = CbxSlideshowInterval;
|
||||
protected readonly CbxMagnifierZoom = CbxMagnifierZoom;
|
||||
protected readonly CbxMagnifierLensSize = CbxMagnifierLensSize;
|
||||
|
||||
get fitModeOptions(): {value: CbxFitMode, label: string, icon: ReaderIconName}[] {
|
||||
return [
|
||||
{value: CbxFitMode.FIT_PAGE, label: this.t.translate('readerCbx.quickSettings.fitPage'), icon: 'fit-page'},
|
||||
{value: CbxFitMode.FIT_WIDTH, label: this.t.translate('readerCbx.quickSettings.fitWidth'), icon: 'fit-width'},
|
||||
{value: CbxFitMode.FIT_HEIGHT, label: this.t.translate('readerCbx.quickSettings.fitHeight'), icon: 'fit-height'},
|
||||
{value: CbxFitMode.ACTUAL_SIZE, label: this.t.translate('readerCbx.quickSettings.actualSize'), icon: 'actual-size'},
|
||||
{value: CbxFitMode.AUTO, label: this.t.translate('readerCbx.quickSettings.automatic'), icon: 'auto-fit'}
|
||||
];
|
||||
}
|
||||
|
||||
get scrollModeOptions(): {value: CbxScrollMode, label: string}[] {
|
||||
return [
|
||||
{value: CbxScrollMode.PAGINATED, label: this.t.translate('readerCbx.quickSettings.paginated')},
|
||||
{value: CbxScrollMode.INFINITE, label: this.t.translate('readerCbx.quickSettings.infinite')},
|
||||
{value: CbxScrollMode.LONG_STRIP, label: this.t.translate('readerCbx.quickSettings.longStrip')}
|
||||
];
|
||||
}
|
||||
|
||||
slideshowIntervalOptions: {value: CbxSlideshowInterval, label: string}[] = [
|
||||
{value: CbxSlideshowInterval.THREE_SECONDS, label: '3s'},
|
||||
{value: CbxSlideshowInterval.FIVE_SECONDS, label: '5s'},
|
||||
{value: CbxSlideshowInterval.TEN_SECONDS, label: '10s'},
|
||||
{value: CbxSlideshowInterval.FIFTEEN_SECONDS, label: '15s'},
|
||||
{value: CbxSlideshowInterval.THIRTY_SECONDS, label: '30s'}
|
||||
];
|
||||
|
||||
magnifierZoomOptions: {value: CbxMagnifierZoom, label: string}[] = [
|
||||
{value: CbxMagnifierZoom.ZOOM_1_5X, label: '1.5×'},
|
||||
{value: CbxMagnifierZoom.ZOOM_2X, label: '2×'},
|
||||
{value: CbxMagnifierZoom.ZOOM_2_5X, label: '2.5×'},
|
||||
{value: CbxMagnifierZoom.ZOOM_3X, label: '3×'},
|
||||
{value: CbxMagnifierZoom.ZOOM_4X, label: '4×'}
|
||||
];
|
||||
|
||||
magnifierLensSizeOptions: {value: CbxMagnifierLensSize, label: string}[] = [
|
||||
{value: CbxMagnifierLensSize.SMALL, label: 'S'},
|
||||
{value: CbxMagnifierLensSize.MEDIUM, label: 'M'},
|
||||
{value: CbxMagnifierLensSize.LARGE, label: 'L'},
|
||||
{value: CbxMagnifierLensSize.EXTRA_LARGE, label: 'XL'}
|
||||
];
|
||||
|
||||
get backgroundOptions() {
|
||||
return [
|
||||
{value: CbxBackgroundColor.BLACK, label: this.t.translate('readerCbx.quickSettings.black'), color: '#000000'},
|
||||
{value: CbxBackgroundColor.GRAY, label: this.t.translate('readerCbx.quickSettings.gray'), color: '#808080'},
|
||||
{value: CbxBackgroundColor.WHITE, label: this.t.translate('readerCbx.quickSettings.white'), color: '#ffffff'}
|
||||
];
|
||||
}
|
||||
|
||||
get isTwoPageView(): boolean {
|
||||
return this.state().pageViewMode === CbxPageViewMode.TWO_PAGE;
|
||||
}
|
||||
|
||||
get isPaginated(): boolean {
|
||||
return this.state().scrollMode === CbxScrollMode.PAGINATED;
|
||||
}
|
||||
|
||||
get isLongStrip(): boolean {
|
||||
return this.state().scrollMode === CbxScrollMode.LONG_STRIP;
|
||||
}
|
||||
|
||||
get isPhonePortrait(): boolean {
|
||||
return window.innerWidth < 768 && window.innerHeight > window.innerWidth;
|
||||
}
|
||||
|
||||
get currentScrollModeLabel(): string {
|
||||
return this.scrollModeOptions.find(o => o.value === this.state().scrollMode)?.label || this.t.translate('readerCbx.quickSettings.paginated');
|
||||
}
|
||||
|
||||
get currentSlideshowIntervalLabel(): string {
|
||||
return this.slideshowIntervalOptions.find(o => o.value === this.state().slideshowInterval)?.label || '5s';
|
||||
}
|
||||
|
||||
onFitModeSelect(mode: CbxFitMode): void {
|
||||
this.quickSettingsService.emitFitModeChange(mode);
|
||||
}
|
||||
|
||||
onScrollModeSelect(mode: CbxScrollMode): void {
|
||||
this.quickSettingsService.emitScrollModeChange(mode);
|
||||
}
|
||||
|
||||
onPageViewToggle(): void {
|
||||
const newMode = this.state().pageViewMode === CbxPageViewMode.SINGLE_PAGE
|
||||
? CbxPageViewMode.TWO_PAGE
|
||||
: CbxPageViewMode.SINGLE_PAGE;
|
||||
this.quickSettingsService.emitPageViewModeChange(newMode);
|
||||
}
|
||||
|
||||
onPageSpreadToggle(): void {
|
||||
const newSpread = this.state().pageSpread === CbxPageSpread.ODD
|
||||
? CbxPageSpread.EVEN
|
||||
: CbxPageSpread.ODD;
|
||||
this.quickSettingsService.emitPageSpreadChange(newSpread);
|
||||
}
|
||||
|
||||
onBackgroundSelect(color: CbxBackgroundColor): void {
|
||||
this.quickSettingsService.emitBackgroundColorChange(color);
|
||||
}
|
||||
|
||||
onReadingDirectionToggle(): void {
|
||||
const newDirection = this.state().readingDirection === CbxReadingDirection.LTR
|
||||
? CbxReadingDirection.RTL
|
||||
: CbxReadingDirection.LTR;
|
||||
this.quickSettingsService.emitReadingDirectionChange(newDirection);
|
||||
}
|
||||
|
||||
onSlideshowIntervalSelect(interval: CbxSlideshowInterval): void {
|
||||
this.quickSettingsService.emitSlideshowIntervalChange(interval);
|
||||
}
|
||||
|
||||
onMagnifierZoomSelect(zoom: CbxMagnifierZoom): void {
|
||||
this.quickSettingsService.emitMagnifierZoomChange(zoom);
|
||||
}
|
||||
|
||||
onMagnifierLensSizeSelect(size: CbxMagnifierLensSize): void {
|
||||
this.quickSettingsService.emitMagnifierLensSizeChange(size);
|
||||
}
|
||||
|
||||
onOverlayClick(): void {
|
||||
this.quickSettingsService.close();
|
||||
}
|
||||
}
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
import {Injectable, signal} from '@angular/core';
|
||||
import {Subject} from 'rxjs';
|
||||
import {CbxBackgroundColor, CbxFitMode, CbxMagnifierLensSize, CbxMagnifierZoom, CbxPageSpread, CbxPageViewMode, CbxScrollMode, CbxReadingDirection, CbxSlideshowInterval} from '../../../../settings/user-management/user.service';
|
||||
|
||||
export interface CbxQuickSettingsState {
|
||||
fitMode: CbxFitMode;
|
||||
scrollMode: CbxScrollMode;
|
||||
pageViewMode: CbxPageViewMode;
|
||||
pageSpread: CbxPageSpread;
|
||||
backgroundColor: CbxBackgroundColor;
|
||||
readingDirection: CbxReadingDirection;
|
||||
slideshowInterval: CbxSlideshowInterval;
|
||||
magnifierZoom: CbxMagnifierZoom;
|
||||
magnifierLensSize: CbxMagnifierLensSize;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class CbxQuickSettingsService {
|
||||
private readonly defaultState: CbxQuickSettingsState = {
|
||||
fitMode: CbxFitMode.FIT_PAGE,
|
||||
scrollMode: CbxScrollMode.PAGINATED,
|
||||
pageViewMode: CbxPageViewMode.SINGLE_PAGE,
|
||||
pageSpread: CbxPageSpread.ODD,
|
||||
backgroundColor: CbxBackgroundColor.GRAY,
|
||||
readingDirection: CbxReadingDirection.LTR,
|
||||
slideshowInterval: CbxSlideshowInterval.FIVE_SECONDS,
|
||||
magnifierZoom: CbxMagnifierZoom.ZOOM_3X,
|
||||
magnifierLensSize: CbxMagnifierLensSize.MEDIUM
|
||||
};
|
||||
|
||||
private readonly _state = signal<CbxQuickSettingsState>(this.defaultState);
|
||||
readonly state = this._state.asReadonly();
|
||||
|
||||
private readonly _visible = signal(false);
|
||||
readonly visible = this._visible.asReadonly();
|
||||
|
||||
private _fitModeChange = new Subject<CbxFitMode>();
|
||||
fitModeChange$ = this._fitModeChange.asObservable();
|
||||
|
||||
private _scrollModeChange = new Subject<CbxScrollMode>();
|
||||
scrollModeChange$ = this._scrollModeChange.asObservable();
|
||||
|
||||
private _pageViewModeChange = new Subject<CbxPageViewMode>();
|
||||
pageViewModeChange$ = this._pageViewModeChange.asObservable();
|
||||
|
||||
private _pageSpreadChange = new Subject<CbxPageSpread>();
|
||||
pageSpreadChange$ = this._pageSpreadChange.asObservable();
|
||||
|
||||
private _backgroundColorChange = new Subject<CbxBackgroundColor>();
|
||||
backgroundColorChange$ = this._backgroundColorChange.asObservable();
|
||||
|
||||
private _readingDirectionChange = new Subject<CbxReadingDirection>();
|
||||
readingDirectionChange$ = this._readingDirectionChange.asObservable();
|
||||
|
||||
private _slideshowIntervalChange = new Subject<CbxSlideshowInterval>();
|
||||
slideshowIntervalChange$ = this._slideshowIntervalChange.asObservable();
|
||||
|
||||
private _magnifierZoomChange = new Subject<CbxMagnifierZoom>();
|
||||
magnifierZoomChange$ = this._magnifierZoomChange.asObservable();
|
||||
|
||||
private _magnifierLensSizeChange = new Subject<CbxMagnifierLensSize>();
|
||||
magnifierLensSizeChange$ = this._magnifierLensSizeChange.asObservable();
|
||||
|
||||
show(): void {
|
||||
this._visible.set(true);
|
||||
}
|
||||
|
||||
close(): void {
|
||||
this._visible.set(false);
|
||||
}
|
||||
|
||||
updateState(partial: Partial<CbxQuickSettingsState>): void {
|
||||
this._state.update(current => ({...current, ...partial}));
|
||||
}
|
||||
|
||||
setFitMode(mode: CbxFitMode): void {
|
||||
this.updateState({fitMode: mode});
|
||||
}
|
||||
|
||||
setScrollMode(mode: CbxScrollMode): void {
|
||||
this.updateState({scrollMode: mode});
|
||||
}
|
||||
|
||||
setPageViewMode(mode: CbxPageViewMode): void {
|
||||
this.updateState({pageViewMode: mode});
|
||||
}
|
||||
|
||||
setPageSpread(spread: CbxPageSpread): void {
|
||||
this.updateState({pageSpread: spread});
|
||||
}
|
||||
|
||||
setBackgroundColor(color: CbxBackgroundColor): void {
|
||||
this.updateState({backgroundColor: color});
|
||||
}
|
||||
|
||||
setReadingDirection(direction: CbxReadingDirection): void {
|
||||
this.updateState({readingDirection: direction});
|
||||
}
|
||||
|
||||
setSlideshowInterval(interval: CbxSlideshowInterval): void {
|
||||
this.updateState({slideshowInterval: interval});
|
||||
}
|
||||
|
||||
setMagnifierZoom(zoom: CbxMagnifierZoom): void {
|
||||
this.updateState({magnifierZoom: zoom});
|
||||
}
|
||||
|
||||
setMagnifierLensSize(size: CbxMagnifierLensSize): void {
|
||||
this.updateState({magnifierLensSize: size});
|
||||
}
|
||||
|
||||
// Actions emitted from component
|
||||
emitFitModeChange(mode: CbxFitMode): void {
|
||||
this._fitModeChange.next(mode);
|
||||
}
|
||||
|
||||
emitScrollModeChange(mode: CbxScrollMode): void {
|
||||
this._scrollModeChange.next(mode);
|
||||
}
|
||||
|
||||
emitPageViewModeChange(mode: CbxPageViewMode): void {
|
||||
this._pageViewModeChange.next(mode);
|
||||
}
|
||||
|
||||
emitPageSpreadChange(spread: CbxPageSpread): void {
|
||||
this._pageSpreadChange.next(spread);
|
||||
}
|
||||
|
||||
emitBackgroundColorChange(color: CbxBackgroundColor): void {
|
||||
this._backgroundColorChange.next(color);
|
||||
}
|
||||
|
||||
emitReadingDirectionChange(direction: CbxReadingDirection): void {
|
||||
this._readingDirectionChange.next(direction);
|
||||
}
|
||||
|
||||
emitSlideshowIntervalChange(interval: CbxSlideshowInterval): void {
|
||||
this._slideshowIntervalChange.next(interval);
|
||||
}
|
||||
|
||||
emitMagnifierZoomChange(zoom: CbxMagnifierZoom): void {
|
||||
this._magnifierZoomChange.next(zoom);
|
||||
}
|
||||
|
||||
emitMagnifierLensSizeChange(size: CbxMagnifierLensSize): void {
|
||||
this._magnifierLensSizeChange.next(size);
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this._state.set(this.defaultState);
|
||||
this._visible.set(false);
|
||||
}
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
@if (isOpen()) {
|
||||
<div class="sidebar-overlay" (click)="onOverlayClick()" [class.closing]="closing()">
|
||||
<aside class="sidebar" (click)="$event.stopPropagation()" [class.closing]="closing()">
|
||||
<header class="sidebar-header">
|
||||
@if (bookInfo().coverUrl) {
|
||||
<img
|
||||
[src]="bookInfo().coverUrl"
|
||||
alt="Book cover"
|
||||
class="book-cover"
|
||||
/>
|
||||
}
|
||||
<div class="book-meta">
|
||||
<h2 class="book-title">{{ bookInfo().title }}</h2>
|
||||
@if (bookInfo().authors) {
|
||||
<p class="book-authors">{{ bookInfo().authors }}</p>
|
||||
}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<nav class="tabs">
|
||||
<button
|
||||
class="tab"
|
||||
[class.active]="activeTab() === 'pages'"
|
||||
(click)="setActiveTab('pages')">
|
||||
<app-reader-icon name="book" class="tab-icon"></app-reader-icon>
|
||||
<span>{{ 'readerCbx.sidebar.contentTab' | transloco }}</span>
|
||||
</button>
|
||||
<button
|
||||
class="tab"
|
||||
[class.active]="activeTab() === 'bookmarks'"
|
||||
(click)="setActiveTab('bookmarks')">
|
||||
<app-reader-icon name="bookmark" class="tab-icon"></app-reader-icon>
|
||||
<span>{{ 'readerCbx.sidebar.bookmarksTab' | transloco }}</span>
|
||||
@if (bookmarks().length > 0) {
|
||||
<span class="badge">{{ bookmarks().length }}</span>
|
||||
}
|
||||
</button>
|
||||
<button
|
||||
class="tab"
|
||||
[class.active]="activeTab() === 'notes'"
|
||||
(click)="setActiveTab('notes')">
|
||||
<app-reader-icon name="note" class="tab-icon"></app-reader-icon>
|
||||
<span>{{ 'readerCbx.sidebar.notesTab' | transloco }}</span>
|
||||
@if (notes().length > 0) {
|
||||
<span class="badge">{{ notes().length }}</span>
|
||||
}
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div class="content">
|
||||
@switch (activeTab()) {
|
||||
@case ('pages') {
|
||||
<ul class="page-list">
|
||||
@for (page of pages(); track page.pageNumber) {
|
||||
<li>
|
||||
<button
|
||||
class="page-row"
|
||||
[class.active]="isPageActive(page.pageNumber)"
|
||||
(click)="onPageClick(page.pageNumber)">
|
||||
<span class="page-number">{{ page.pageNumber }}</span>
|
||||
<span class="page-label">{{ page.displayName }}</span>
|
||||
</button>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
@if (pages().length === 0) {
|
||||
<div class="empty-state">
|
||||
<app-reader-icon name="book" class="empty-icon" [size]="48" [strokeWidth]="1.5"></app-reader-icon>
|
||||
<p>{{ 'readerCbx.sidebar.noPagesFound' | transloco }}</p>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@case ('bookmarks') {
|
||||
@if (bookmarks().length > 0) {
|
||||
<ul class="item-list">
|
||||
@for (bookmark of bookmarks(); track bookmark.id) {
|
||||
<li class="list-item" (click)="onBookmarkClick(bookmark.cfi!)">
|
||||
<div class="item-content">
|
||||
<span class="item-title">{{ bookmark.title }}</span>
|
||||
<span class="item-meta">{{ bookmark.createdAt | date: 'MMM d, y' }}</span>
|
||||
</div>
|
||||
<button class="delete-btn" (click)="onDeleteBookmark($event, bookmark.id)" [attr.aria-label]="'readerCbx.sidebar.deleteBookmark' | transloco">
|
||||
<app-reader-icon name="trash" [size]="16"></app-reader-icon>
|
||||
</button>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
} @else {
|
||||
<div class="empty-state">
|
||||
<app-reader-icon name="bookmark" class="empty-icon" [size]="48" [strokeWidth]="1.5"></app-reader-icon>
|
||||
<p>{{ 'readerCbx.sidebar.noBookmarksYet' | transloco }}</p>
|
||||
<span class="empty-hint">{{ 'readerCbx.sidebar.bookmarkHint' | transloco }}</span>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@case ('notes') {
|
||||
<div class="notes-container">
|
||||
@if (notes().length > 0) {
|
||||
<div class="notes-search-wrapper">
|
||||
<app-reader-icon name="search" class="search-icon" [size]="16"></app-reader-icon>
|
||||
<input
|
||||
type="text"
|
||||
class="search-input"
|
||||
[placeholder]="'readerCbx.sidebar.searchNotesPlaceholder' | transloco"
|
||||
[ngModel]="notesSearchQuery()"
|
||||
(ngModelChange)="onNotesSearchInput($event)"
|
||||
/>
|
||||
@if (notesSearchQuery()) {
|
||||
<button class="clear-btn" (click)="clearNotesSearch()" [attr.aria-label]="'readerCbx.sidebar.clearSearch' | transloco">
|
||||
<app-reader-icon name="close" [size]="14"></app-reader-icon>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (filteredNotes().length > 0) {
|
||||
<ul class="item-list">
|
||||
@for (note of filteredNotes(); track note.id) {
|
||||
<li class="list-item note-item" (click)="onNoteClick(note.cfi)">
|
||||
<div class="note-bar" [style.background-color]="note.color"></div>
|
||||
<div class="item-content">
|
||||
<span class="note-text">{{ note.noteContent }}</span>
|
||||
@if (note.chapterTitle) {
|
||||
<span class="item-chapter">{{ note.chapterTitle }}</span>
|
||||
}
|
||||
<span class="item-meta">{{ note.createdAt | date: 'MMM d, y' }}</span>
|
||||
</div>
|
||||
<div class="action-buttons">
|
||||
<button class="edit-btn" (click)="onEditNote($event, note)" [attr.aria-label]="'readerCbx.sidebar.editNote' | transloco">
|
||||
<app-reader-icon name="edit" [size]="16"></app-reader-icon>
|
||||
</button>
|
||||
<button class="delete-btn" (click)="onDeleteNote($event, note.id)" [attr.aria-label]="'readerCbx.sidebar.deleteNote' | transloco">
|
||||
<app-reader-icon name="trash" [size]="16"></app-reader-icon>
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
} @else if (notes().length > 0 && notesSearchQuery()) {
|
||||
<div class="empty-state">
|
||||
<app-reader-icon name="search" class="empty-icon" [size]="48" [strokeWidth]="1.5"></app-reader-icon>
|
||||
<p>{{ 'readerCbx.sidebar.noMatchingNotes' | transloco }}</p>
|
||||
<span class="empty-hint">{{ 'readerCbx.sidebar.tryDifferentSearch' | transloco }}</span>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="empty-state">
|
||||
<app-reader-icon name="note" class="empty-icon" [size]="48" [strokeWidth]="1.5"></app-reader-icon>
|
||||
<p>{{ 'readerCbx.sidebar.noNotesYet' | transloco }}</p>
|
||||
<span class="empty-hint">{{ 'readerCbx.sidebar.notesHint' | transloco }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
}
|
||||
+541
@@ -0,0 +1,541 @@
|
||||
// Variables
|
||||
$sidebar-width: 300px;
|
||||
$sidebar-bg: #1a1a1a;
|
||||
$text-primary: rgba(255, 255, 255, 0.95);
|
||||
$text-secondary: rgba(255, 255, 255, 0.6);
|
||||
$text-muted: rgba(255, 255, 255, 0.4);
|
||||
$border-color: rgba(255, 255, 255, 0.08);
|
||||
$hover-bg: rgba(255, 255, 255, 0.06);
|
||||
$active-bg: rgba(74, 144, 226, 0.15);
|
||||
$active-color: #4a90e2;
|
||||
$transition-fast: 150ms ease;
|
||||
$transition-normal: 200ms ease;
|
||||
|
||||
// Overlay
|
||||
.sidebar-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
backdrop-filter: blur(2px);
|
||||
z-index: 12000;
|
||||
animation: fadeIn $transition-normal;
|
||||
|
||||
&.closing {
|
||||
animation: fadeOut $transition-normal forwards;
|
||||
}
|
||||
}
|
||||
|
||||
// Sidebar container
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: $sidebar-width;
|
||||
background: $sidebar-bg;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
color: $text-primary;
|
||||
box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
|
||||
animation: slideIn 250ms cubic-bezier(0.4, 0, 0.2, 1);
|
||||
z-index: 12001;
|
||||
|
||||
&.closing {
|
||||
animation: slideOut 200ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
|
||||
}
|
||||
}
|
||||
|
||||
// Header
|
||||
.sidebar-header {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
padding: 20px 16px;
|
||||
border-bottom: 1px solid $border-color;
|
||||
background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
|
||||
}
|
||||
|
||||
.book-cover {
|
||||
width: 60px;
|
||||
height: 90px;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.book-meta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
min-width: 0;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.book-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 1.3;
|
||||
margin: 0;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.book-authors {
|
||||
font-size: 12px;
|
||||
color: $text-secondary;
|
||||
margin: 0;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
// Tabs
|
||||
.tabs {
|
||||
display: flex;
|
||||
border-bottom: 1px solid $border-color;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.tab {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 12px 8px;
|
||||
background: none;
|
||||
border: none;
|
||||
color: $text-secondary;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: color $transition-fast, background $transition-fast;
|
||||
position: relative;
|
||||
|
||||
&:hover {
|
||||
color: $text-primary;
|
||||
background: $hover-bg;
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: $active-color;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 16px;
|
||||
right: 16px;
|
||||
height: 2px;
|
||||
background: $active-color;
|
||||
border-radius: 1px 1px 0 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tab-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.badge {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
right: calc(50% - 20px);
|
||||
min-width: 16px;
|
||||
height: 16px;
|
||||
padding: 0 4px;
|
||||
background: $active-color;
|
||||
color: white;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
// Content area
|
||||
.content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 3px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Page list
|
||||
.page-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.page-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
background: none;
|
||||
border: none;
|
||||
color: $text-primary;
|
||||
font-size: 13px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: background $transition-fast;
|
||||
gap: 12px;
|
||||
|
||||
&:hover {
|
||||
background: $hover-bg;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: $active-bg;
|
||||
color: $active-color;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.page-number {
|
||||
min-width: 32px;
|
||||
text-align: right;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.page-label {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
// PDF Outline list
|
||||
.outline-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.outline-item {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.outline-children {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.outline-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding: 10px 16px;
|
||||
padding-right: 12px;
|
||||
background: none;
|
||||
border: none;
|
||||
color: $text-primary;
|
||||
font-size: 13px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: background $transition-fast;
|
||||
gap: 8px;
|
||||
|
||||
&:hover {
|
||||
background: $hover-bg;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: $active-bg;
|
||||
color: $active-color;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&.has-children {
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.expand-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
flex-shrink: 0;
|
||||
color: $text-muted;
|
||||
transition: transform $transition-fast;
|
||||
border-radius: 4px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: $text-primary;
|
||||
}
|
||||
|
||||
&.expanded {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
}
|
||||
|
||||
.outline-title {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.outline-page {
|
||||
font-size: 11px;
|
||||
color: $text-muted;
|
||||
flex-shrink: 0;
|
||||
min-width: 28px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
// Item list (bookmarks & notes)
|
||||
.item-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.list-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px 16px;
|
||||
cursor: pointer;
|
||||
transition: background $transition-fast;
|
||||
|
||||
&:hover {
|
||||
background: $hover-bg;
|
||||
|
||||
.delete-btn,
|
||||
.action-buttons {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.note-item {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.note-bar {
|
||||
width: 3px;
|
||||
align-self: stretch;
|
||||
border-radius: 2px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.item-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.item-title {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: $text-primary;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.note-text {
|
||||
font-size: 13px;
|
||||
color: $text-primary;
|
||||
line-height: 1.4;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 3;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.item-chapter {
|
||||
font-size: 11px;
|
||||
color: $text-secondary;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.item-meta {
|
||||
font-size: 11px;
|
||||
color: $text-muted;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
opacity: 0;
|
||||
transition: opacity $transition-fast;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.edit-btn,
|
||||
.delete-btn {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
color: $text-muted;
|
||||
cursor: pointer;
|
||||
transition: background $transition-fast, color $transition-fast;
|
||||
flex-shrink: 0;
|
||||
opacity: 0;
|
||||
|
||||
svg {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.list-item:hover .edit-btn,
|
||||
.list-item:hover .delete-btn {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.edit-btn:hover {
|
||||
background: rgba(74, 144, 226, 0.15);
|
||||
color: $active-color;
|
||||
}
|
||||
|
||||
.delete-btn:hover {
|
||||
background: rgba(239, 68, 68, 0.15);
|
||||
color: #ef4444;
|
||||
}
|
||||
|
||||
// Notes container
|
||||
.notes-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.notes-search-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 12px 16px;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
border-bottom: 1px solid $border-color;
|
||||
|
||||
.search-icon {
|
||||
color: $text-muted;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
background: none;
|
||||
border: none;
|
||||
color: $text-primary;
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
|
||||
&::placeholder {
|
||||
color: $text-muted;
|
||||
}
|
||||
}
|
||||
|
||||
.clear-btn {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
color: $text-secondary;
|
||||
cursor: pointer;
|
||||
transition: background $transition-fast, color $transition-fast;
|
||||
flex-shrink: 0;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
color: $text-primary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Empty state
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 48px 24px;
|
||||
text-align: center;
|
||||
color: $text-secondary;
|
||||
|
||||
.empty-icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
margin-bottom: 16px;
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.empty-hint {
|
||||
font-size: 12px;
|
||||
color: $text-muted;
|
||||
}
|
||||
|
||||
// Animations
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
@keyframes fadeOut {
|
||||
from { opacity: 1; }
|
||||
to { opacity: 0; }
|
||||
}
|
||||
|
||||
@keyframes slideIn {
|
||||
from { transform: translateX(-100%); }
|
||||
to { transform: translateX(0); }
|
||||
}
|
||||
|
||||
@keyframes slideOut {
|
||||
from { transform: translateX(0); }
|
||||
to { transform: translateX(-100%); }
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
import {Component, DestroyRef, effect, inject, signal} from '@angular/core';
|
||||
import {CommonModule, DatePipe} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {TranslocoPipe} from '@jsverse/transloco';
|
||||
import {CbxSidebarService, CbxSidebarTab} from './cbx-sidebar.service';
|
||||
import {BookNoteV2} from '../../../../../shared/service/book-note-v2.service';
|
||||
import {ReaderIconComponent} from '../../../ebook-reader';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cbx-sidebar',
|
||||
standalone: true,
|
||||
templateUrl: './cbx-sidebar.component.html',
|
||||
styleUrls: ['./cbx-sidebar.component.scss'],
|
||||
imports: [CommonModule, FormsModule, TranslocoPipe, ReaderIconComponent, DatePipe]
|
||||
})
|
||||
export class CbxSidebarComponent {
|
||||
private readonly sidebarService = inject(CbxSidebarService);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private closeAnimationTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
readonly activeTab = this.sidebarService.activeTab;
|
||||
readonly bookInfo = this.sidebarService.bookInfo;
|
||||
readonly pages = this.sidebarService.pages;
|
||||
readonly currentPage = this.sidebarService.currentPage;
|
||||
readonly bookmarks = this.sidebarService.bookmarks;
|
||||
readonly notes = this.sidebarService.notes;
|
||||
readonly notesSearchQuery = this.sidebarService.notesSearchQuery;
|
||||
readonly filteredNotes = this.sidebarService.filteredNotes;
|
||||
|
||||
readonly isOpen = signal(false);
|
||||
readonly closing = signal(false);
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
if (this.sidebarService.isOpen()) {
|
||||
this.clearCloseAnimation();
|
||||
this.isOpen.set(true);
|
||||
this.closing.set(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isOpen()) {
|
||||
this.closeWithAnimation();
|
||||
}
|
||||
});
|
||||
|
||||
this.destroyRef.onDestroy(() => this.clearCloseAnimation());
|
||||
}
|
||||
|
||||
private closeWithAnimation(): void {
|
||||
this.closing.set(true);
|
||||
this.closeAnimationTimeout = setTimeout(() => {
|
||||
this.isOpen.set(false);
|
||||
this.closing.set(false);
|
||||
this.closeAnimationTimeout = null;
|
||||
}, 250);
|
||||
}
|
||||
|
||||
private clearCloseAnimation(): void {
|
||||
if (this.closeAnimationTimeout) {
|
||||
clearTimeout(this.closeAnimationTimeout);
|
||||
this.closeAnimationTimeout = null;
|
||||
}
|
||||
}
|
||||
|
||||
onOverlayClick(): void {
|
||||
this.sidebarService.close();
|
||||
}
|
||||
|
||||
setActiveTab(tab: CbxSidebarTab): void {
|
||||
this.sidebarService.setActiveTab(tab);
|
||||
}
|
||||
|
||||
onPageClick(pageNumber: number): void {
|
||||
this.sidebarService.navigateToPage(pageNumber);
|
||||
}
|
||||
|
||||
isPageActive(pageNumber: number): boolean {
|
||||
return this.currentPage() === pageNumber;
|
||||
}
|
||||
|
||||
onBookmarkClick(cfi: string): void {
|
||||
this.sidebarService.navigateToBookmark(cfi);
|
||||
}
|
||||
|
||||
onDeleteBookmark(event: MouseEvent, bookmarkId: number): void {
|
||||
event.stopPropagation();
|
||||
this.sidebarService.deleteBookmark(bookmarkId);
|
||||
}
|
||||
|
||||
onNoteClick(cfi: string): void {
|
||||
this.sidebarService.navigateToNote(cfi);
|
||||
}
|
||||
|
||||
onEditNote(event: MouseEvent, note: BookNoteV2): void {
|
||||
event.stopPropagation();
|
||||
this.sidebarService.editNote(note);
|
||||
}
|
||||
|
||||
onDeleteNote(event: MouseEvent, noteId: number): void {
|
||||
event.stopPropagation();
|
||||
this.sidebarService.deleteNote(noteId);
|
||||
}
|
||||
|
||||
onNotesSearchInput(query: string): void {
|
||||
this.sidebarService.setNotesSearchQuery(query);
|
||||
}
|
||||
|
||||
clearNotesSearch(): void {
|
||||
this.sidebarService.setNotesSearchQuery('');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
import {computed, inject, Injectable, signal} from '@angular/core';
|
||||
import {Subject} from 'rxjs';
|
||||
import {takeUntil} from 'rxjs/operators';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
import {CbxPageInfo, CbxReaderService} from '../../../../book/service/cbx-reader.service';
|
||||
import {UrlHelperService} from '../../../../../shared/service/url-helper.service';
|
||||
import {Book} from '../../../../book/model/book.model';
|
||||
import {BookMark, BookMarkService, CreateBookMarkRequest} from '../../../../../shared/service/book-mark.service';
|
||||
import {BookNoteV2, BookNoteV2Service, CreateBookNoteV2Request, UpdateBookNoteV2Request} from '../../../../../shared/service/book-note-v2.service';
|
||||
|
||||
export interface SidebarBookInfo {
|
||||
id: number | null;
|
||||
title: string;
|
||||
authors: string;
|
||||
coverUrl: string | null;
|
||||
}
|
||||
|
||||
export type CbxSidebarTab = 'pages' | 'bookmarks' | 'notes';
|
||||
|
||||
@Injectable()
|
||||
export class CbxSidebarService {
|
||||
private urlHelper = inject(UrlHelperService);
|
||||
private cbxReaderService = inject(CbxReaderService);
|
||||
private bookMarkService = inject(BookMarkService);
|
||||
private bookNoteV2Service = inject(BookNoteV2Service);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
private bookId!: number;
|
||||
private altBookType?: string;
|
||||
|
||||
private readonly _isOpen = signal(false);
|
||||
readonly isOpen = this._isOpen.asReadonly();
|
||||
|
||||
private readonly _activeTab = signal<CbxSidebarTab>('pages');
|
||||
readonly activeTab = this._activeTab.asReadonly();
|
||||
|
||||
private readonly _bookInfo = signal<SidebarBookInfo>({
|
||||
id: null,
|
||||
title: '',
|
||||
authors: '',
|
||||
coverUrl: null
|
||||
});
|
||||
readonly bookInfo = this._bookInfo.asReadonly();
|
||||
|
||||
private readonly _pages = signal<CbxPageInfo[]>([]);
|
||||
readonly pages = this._pages.asReadonly();
|
||||
|
||||
private readonly _currentPage = signal(1);
|
||||
readonly currentPage = this._currentPage.asReadonly();
|
||||
|
||||
private readonly _bookmarks = signal<BookMark[]>([]);
|
||||
readonly bookmarks = this._bookmarks.asReadonly();
|
||||
|
||||
private readonly _notes = signal<BookNoteV2[]>([]);
|
||||
readonly notes = this._notes.asReadonly();
|
||||
|
||||
private readonly _notesSearchQuery = signal('');
|
||||
readonly notesSearchQuery = this._notesSearchQuery.asReadonly();
|
||||
readonly filteredNotes = computed(() => {
|
||||
const query = this._notesSearchQuery().toLowerCase().trim();
|
||||
const notes = this._notes();
|
||||
|
||||
if (!query) {
|
||||
return notes;
|
||||
}
|
||||
|
||||
return notes.filter(note =>
|
||||
note.noteContent.toLowerCase().includes(query) ||
|
||||
note.chapterTitle?.toLowerCase().includes(query)
|
||||
);
|
||||
});
|
||||
|
||||
private _navigateToPage = new Subject<number>();
|
||||
private _editNote = new Subject<BookNoteV2>();
|
||||
navigateToPage$ = this._navigateToPage.asObservable();
|
||||
editNote$ = this._editNote.asObservable();
|
||||
|
||||
initialize(bookId: number, book: Book, destroy$: Subject<void>, altBookType?: string): void {
|
||||
this.bookId = bookId;
|
||||
this.altBookType = altBookType;
|
||||
this.destroy$ = destroy$;
|
||||
|
||||
this._bookInfo.set({
|
||||
id: book.id,
|
||||
title: book.metadata?.title || book.fileName || this.t.translate('readerCbx.sidebar.untitled'),
|
||||
authors: (book.metadata?.authors || []).join(', '),
|
||||
coverUrl: this.urlHelper.getThumbnailUrl(book.id, book.metadata?.coverUpdatedOn)
|
||||
});
|
||||
|
||||
this.loadPageInfo();
|
||||
this.loadBookmarks();
|
||||
this.loadNotes();
|
||||
}
|
||||
|
||||
private loadPageInfo(): void {
|
||||
this.cbxReaderService.getPageInfo(this.bookId, this.altBookType)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(pages => this._pages.set(pages));
|
||||
}
|
||||
|
||||
private loadBookmarks(): void {
|
||||
this.bookMarkService.getBookmarksForBook(this.bookId)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(bookmarks => this._bookmarks.set(bookmarks));
|
||||
}
|
||||
|
||||
private loadNotes(): void {
|
||||
this.bookNoteV2Service.getNotesForBook(this.bookId)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(notes => this._notes.set(notes));
|
||||
}
|
||||
|
||||
setCurrentPage(page: number): void {
|
||||
this._currentPage.set(page);
|
||||
}
|
||||
|
||||
setActiveTab(tab: CbxSidebarTab): void {
|
||||
this._activeTab.set(tab);
|
||||
}
|
||||
|
||||
open(tab?: CbxSidebarTab): void {
|
||||
if (tab) {
|
||||
this._activeTab.set(tab);
|
||||
}
|
||||
this._isOpen.set(true);
|
||||
}
|
||||
|
||||
close(): void {
|
||||
this._isOpen.set(false);
|
||||
}
|
||||
|
||||
navigateToPage(pageNumber: number): void {
|
||||
this._navigateToPage.next(pageNumber);
|
||||
this.close();
|
||||
}
|
||||
|
||||
isPageBookmarked(pageNumber: number): boolean {
|
||||
const pageStr = pageNumber.toString();
|
||||
return this._bookmarks().some(bookmark => bookmark.cfi === pageStr);
|
||||
}
|
||||
|
||||
getBookmarkForPage(pageNumber: number): BookMark | undefined {
|
||||
const pageStr = pageNumber.toString();
|
||||
return this._bookmarks().find(bookmark => bookmark.cfi === pageStr);
|
||||
}
|
||||
|
||||
createBookmark(pageNumber: number, title?: string): void {
|
||||
const request: CreateBookMarkRequest = {
|
||||
bookId: this.bookId,
|
||||
cfi: pageNumber.toString(),
|
||||
title: title || `${this.t.translate('readerCbx.sidebar.page')} ${pageNumber}`
|
||||
};
|
||||
|
||||
this.bookMarkService.createBookmark(request)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(() => this.loadBookmarks());
|
||||
}
|
||||
|
||||
deleteBookmark(bookmarkId: number): void {
|
||||
this.bookMarkService.deleteBookmark(bookmarkId)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(() => this.loadBookmarks());
|
||||
}
|
||||
|
||||
toggleBookmark(pageNumber: number): void {
|
||||
const existingBookmark = this.getBookmarkForPage(pageNumber);
|
||||
if (existingBookmark) {
|
||||
this.deleteBookmark(existingBookmark.id);
|
||||
} else {
|
||||
this.createBookmark(pageNumber);
|
||||
}
|
||||
}
|
||||
|
||||
navigateToBookmark(pageNumber: string): void {
|
||||
const page = parseInt(pageNumber, 10);
|
||||
if (!isNaN(page)) {
|
||||
this._navigateToPage.next(page);
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
pageHasNotes(pageNumber: number): boolean {
|
||||
const pageStr = pageNumber.toString();
|
||||
return this._notes().some(note => note.cfi === pageStr);
|
||||
}
|
||||
|
||||
createNote(pageNumber: number, noteContent: string, color?: string): void {
|
||||
const request: CreateBookNoteV2Request = {
|
||||
bookId: this.bookId,
|
||||
cfi: pageNumber.toString(),
|
||||
noteContent,
|
||||
color: color || '#FFC107',
|
||||
chapterTitle: `${this.t.translate('readerCbx.sidebar.page')} ${pageNumber}`
|
||||
};
|
||||
|
||||
this.bookNoteV2Service.createNote(request)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(() => this.loadNotes());
|
||||
}
|
||||
|
||||
updateNote(noteId: number, noteContent: string, color?: string): void {
|
||||
const request: UpdateBookNoteV2Request = {
|
||||
noteContent,
|
||||
color
|
||||
};
|
||||
|
||||
this.bookNoteV2Service.updateNote(noteId, request)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(() => this.loadNotes());
|
||||
}
|
||||
|
||||
deleteNote(noteId: number): void {
|
||||
this.bookNoteV2Service.deleteNote(noteId)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(() => {
|
||||
this._notes.update(notes => notes.filter(note => note.id !== noteId));
|
||||
});
|
||||
}
|
||||
|
||||
editNote(note: BookNoteV2): void {
|
||||
this.close();
|
||||
this._editNote.next(note);
|
||||
}
|
||||
|
||||
navigateToNote(pageNumber: string): void {
|
||||
const page = parseInt(pageNumber, 10);
|
||||
if (!isNaN(page)) {
|
||||
this._navigateToPage.next(page);
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
setNotesSearchQuery(query: string): void {
|
||||
this._notesSearchQuery.set(query);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user