Revamp the CBX reader layout for improved structure and usability (#2330)
Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
+49
@@ -0,0 +1,49 @@
|
||||
<div class="dialog-overlay" (click)="onOverlayClick($event)">
|
||||
<div class="dialog">
|
||||
<div class="dialog-header">
|
||||
<h2>{{ isEditing ? 'Edit Note' : 'Add Note' }}</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">Page</span>
|
||||
<p class="page-info">Page {{ data?.pageNumber }}</p>
|
||||
</div>
|
||||
|
||||
<div class="note-section">
|
||||
<label class="section-label" for="noteContent">Your Note</label>
|
||||
<textarea
|
||||
id="noteContent"
|
||||
class="note-input"
|
||||
[(ngModel)]="noteContent"
|
||||
placeholder="Write your note here..."
|
||||
rows="6"
|
||||
autofocus
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<div class="color-section">
|
||||
<span class="section-label">Note Color</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()">Cancel</button>
|
||||
<button class="btn btn-primary" (click)="onSave()" [disabled]="!noteContent.trim()">{{ isEditing ? 'Update Note' : 'Save Note' }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+258
@@ -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,75 @@
|
||||
import {Component, EventEmitter, Input, Output, OnChanges, SimpleChanges} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
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, ReaderIconComponent],
|
||||
templateUrl: './cbx-note-dialog.component.html',
|
||||
styleUrls: ['./cbx-note-dialog.component.scss']
|
||||
})
|
||||
export class CbxNoteDialogComponent implements OnChanges {
|
||||
@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';
|
||||
}
|
||||
}
|
||||
|
||||
noteColors = [
|
||||
{value: '#FFC107', label: 'Amber'},
|
||||
{value: '#4CAF50', label: 'Green'},
|
||||
{value: '#2196F3', label: 'Blue'},
|
||||
{value: '#E91E63', label: 'Pink'},
|
||||
{value: '#9C27B0', label: 'Purple'},
|
||||
{value: '#FF5722', label: 'Deep Orange'}
|
||||
];
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user