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:
James Cox
2026-04-22 17:26:39 -04:00
committed by Zach Yale
parent c99aa87877
commit 874b013f75
1493 changed files with 3 additions and 3 deletions
@@ -0,0 +1,131 @@
<ng-container *transloco="let t; prefix: 'settingsReader.fonts.upload'">
<div class="font-upload-dialog">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-upload header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">
{{ t('description') }}
</p>
</div>
<p-button
icon="pi pi-times"
(click)="cancel()"
severity="secondary"
[text]="true"
[rounded]="true"
[disabled]="isUploading"
class="close-button"/>
</div>
<div class="upload-container">
<div class="file-upload-section">
<div class="section-header">
<span class="section-title">
<i class="pi pi-file"></i>
{{ t('selectFile') }}
</span>
</div>
@if (!selectedFile) {
<div class="upload-zone"
[class.drag-over]="isDragOver"
(click)="onUploadZoneClick()"
(drop)="onDrop($event)"
(dragover)="onDragOver($event)"
(dragleave)="onDragLeave($event)">
<input
#fileInput
type="file"
accept=".ttf,.otf,.woff,.woff2"
[disabled]="isUploading"
(change)="onFileInputChange($event)"
style="display: none;"
/>
<div class="empty-state">
<div class="empty-icon-wrapper">
<i class="pi pi-cloud-upload empty-icon"></i>
</div>
<h3 class="empty-title">{{ t('dragDrop') }}</h3>
<p class="empty-description" [innerHTML]="t('supportedFormats')"></p>
<p class="empty-description">{{ t('maxSize') }}</p>
</div>
</div>
} @else {
<div class="file-selected">
<div class="file-info-card">
<i class="pi pi-file"></i>
<div class="file-details">
<span class="file-name">{{ selectedFile.name }}</span>
<span class="file-meta">{{ formatFileSize(selectedFile.size) }} • {{ selectedFile.name.split('.').pop()?.toUpperCase() }}</span>
</div>
</div>
@if (previewFontFamily) {
<div class="preview-section">
<label class="preview-label">
<i class="pi pi-eye"></i>
{{ t('fontPreview') }}
</label>
<div class="font-preview" [style.font-family]="previewFontFamily">
<p class="preview-paragraph">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
<p class="preview-paragraph-small">
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<div class="preview-characters">
<span>ABCDEFGHIJKLMNOPQRSTUVWXYZ</span>
<span>abcdefghijklmnopqrstuvwxyz</span>
<span>0123456789 !@#$%^&*()</span>
</div>
</div>
</div>
}
<div class="setting-item">
<div class="setting-info">
<label for="fontName" class="setting-label">{{ t('displayName') }}</label>
<p class="setting-description">
{{ t('displayNameDesc') }}
</p>
</div>
<div class="setting-control">
<input
pInputText
id="fontName"
[(ngModel)]="uploadedFontName"
[placeholder]="t('displayNamePlaceholder')"
[disabled]="isUploading"
class="font-name-input"
/>
</div>
</div>
</div>
}
</div>
</div>
<div class="dialog-footer">
<p-button
[label]="'common.cancel' | transloco"
icon="pi pi-times"
severity="secondary"
[outlined]="true"
(click)="cancel()"
[disabled]="isUploading"
></p-button>
<p-button
[label]="t('uploadBtn')"
icon="pi pi-upload"
(click)="uploadFont()"
[disabled]="isUploading || !selectedFile || !uploadedFontName.trim()"
[loading]="isUploading"
></p-button>
</div>
</div>
</ng-container>
@@ -0,0 +1,357 @@
@use '../../../../shared/styles/panel-shared' as panel;
.font-upload-dialog {
width: 700px;
max-width: 700px;
display: flex;
flex-direction: column;
@media (max-width: 768px) {
width: 100%;
max-width: 100%;
}
}
.panel-header {
@include panel.panel-header;
border-bottom: none;
}
.upload-container {
display: flex;
flex-direction: column;
gap: 1rem;
padding: 1.75rem;
background: var(--card-background);
border: 1px solid var(--border-color);
border-radius: 0 0 10px 10px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
@media (max-width: 480px) {
padding: 1rem;
gap: 1rem;
}
}
.file-upload-section {
display: flex;
flex-direction: column;
.section-header {
display: flex;
align-items: center;
justify-content: center;
padding: 0.625rem 0.875rem;
background: var(--overlay-background);
border-radius: 6px;
.section-title {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.9rem;
font-weight: 600;
color: var(--text-color);
i {
color: var(--primary-color);
font-size: 1rem;
}
}
@media (max-width: 480px) {
padding: 0.5rem 0.625rem;
.section-title {
font-size: 0.85rem;
}
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
padding: 1.5rem 1rem;
.empty-icon-wrapper {
display: flex;
align-items: center;
justify-content: center;
width: 80px;
height: 80px;
background: var(--overlay-background);
border-radius: 50%;
margin-bottom: 1rem;
border: 3px dashed var(--border-color);
.empty-icon {
font-size: 2.5rem;
color: var(--text-secondary-color);
opacity: 0.6;
}
}
.empty-title {
margin: 0 0 0.5rem 0;
font-size: 1.125rem;
font-weight: 600;
color: var(--text-color);
}
.empty-description {
margin: 0;
font-size: 0.875rem;
color: var(--text-secondary-color);
max-width: 450px;
line-height: 1.5;
strong {
color: var(--text-color);
}
}
@media (max-width: 480px) {
padding: 1.5rem 0.75rem;
min-height: 180px;
.empty-icon-wrapper {
width: 70px;
height: 70px;
margin-bottom: 0.75rem;
.empty-icon {
font-size: 2rem;
}
}
.empty-title {
font-size: 1rem;
}
.empty-description {
font-size: 0.8rem;
max-width: 100%;
}
}
}
}
// ==================== Upload Zone ====================
.upload-zone {
padding: 2rem;
text-align: center;
border: 2px dashed var(--border-color);
border-radius: 8px;
background: var(--ground-background);
transition: all 0.3s ease;
cursor: pointer;
&:hover:not(.disabled) {
border-color: var(--primary-color);
background: color-mix(
in srgb,
var(--primary-color) 3%,
var(--ground-background)
);
}
&.drag-over {
border-color: var(--primary-color);
background: color-mix(
in srgb,
var(--primary-color) 8%,
var(--ground-background)
);
.empty-icon-wrapper {
border-color: var(--primary-color);
.empty-icon {
color: var(--primary-color);
transform: scale(1.1);
}
}
}
&.disabled {
cursor: not-allowed;
opacity: 0.6;
}
}
// ==================== File Selected ====================
.file-selected {
display: flex;
flex-direction: column;
gap: 1.5rem;
width: 100%;
max-width: 100%;
overflow: hidden;
}
.file-info-card {
display: flex;
align-items: center;
gap: 1rem;
padding: 1rem;
border: 1px solid var(--border-color);
border-radius: 6px;
background: var(--overlay-background);
width: 100%;
max-width: 100%;
overflow: hidden;
i {
font-size: 2rem;
color: var(--primary-color);
flex-shrink: 0;
}
.file-details {
flex: 1;
display: flex;
flex-direction: column;
gap: 0.25rem;
min-width: 0;
overflow: hidden;
.file-name {
font-weight: 600;
color: var(--text-color);
font-size: 0.9375rem;
word-break: break-word;
overflow-wrap: break-word;
}
.file-meta {
font-size: 0.875rem;
color: var(--text-secondary-color);
}
}
}
.preview-section {
display: flex;
flex-direction: column;
gap: 0.75rem;
width: 100%;
max-width: 100%;
overflow: hidden;
.preview-label {
display: flex;
align-items: center;
gap: 0.375rem;
font-size: 0.75rem;
font-weight: 600;
color: var(--text-secondary-color);
text-transform: uppercase;
letter-spacing: 0.025em;
i {
font-size: 0.75rem;
color: var(--primary-color);
}
}
.font-preview {
padding: 1.5rem;
border: 1px solid var(--border-color);
border-radius: 6px;
background: var(--overlay-background);
display: flex;
flex-direction: column;
gap: 1rem;
max-height: 300px;
overflow-y: auto;
width: 100%;
max-width: 100%;
box-sizing: border-box;
.preview-paragraph {
color: var(--text-color);
font-size: 1rem;
line-height: 1.7;
margin: 0;
text-align: justify;
font-weight: 400;
}
.preview-paragraph-small {
color: var(--text-color);
font-size: 0.875rem;
line-height: 1.6;
margin: 0;
text-align: justify;
font-weight: 400;
}
.preview-characters {
display: flex;
flex-direction: column;
gap: 0.375rem;
padding-top: 0.75rem;
margin-top: 0.5rem;
border-top: 1px solid var(--border-color);
span {
font-size: 0.75rem;
color: var(--text-secondary-color);
letter-spacing: 0.025em;
font-weight: 400;
}
}
}
}
.setting-item {
display: flex;
flex-direction: column;
gap: 0.75rem;
padding: 0;
width: 100%;
max-width: 100%;
}
.setting-info {
width: 100%;
.setting-label {
display: block;
font-weight: 600;
color: var(--text-color);
font-size: 1rem;
margin-bottom: 0.5rem;
}
.setting-description {
color: var(--text-secondary-color);
font-size: 0.875rem;
line-height: 1.5;
margin: 0;
}
}
.setting-control {
display: flex;
flex-direction: column;
gap: 0.75rem;
width: 100%;
.font-name-input {
width: 100%;
}
}
// ==================== Dialog Footer ====================
.dialog-footer {
@include panel.dialog-footer-end;
border-top: 1px solid var(--border-color);
border-left: none;
border-right: none;
border-radius: 0;
box-shadow: none;
}
@@ -0,0 +1,245 @@
import {Component, ViewChild, ElementRef, OnDestroy, inject} from '@angular/core';
import {CommonModule} from '@angular/common';
import {Button} from 'primeng/button';
import {MessageService} from 'primeng/api';
import {CustomFontService} from '../../../../shared/service/custom-font.service';
import {formatFileSize} from '../../../../shared/model/custom-font.model';
import {InputText} from 'primeng/inputtext';
import {FormsModule} from '@angular/forms';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-font-upload-dialog',
standalone: true,
imports: [CommonModule, Button, InputText, FormsModule, TranslocoDirective, TranslocoPipe],
templateUrl: './font-upload-dialog.component.html',
styleUrls: ['./font-upload-dialog.component.scss']
})
export class FontUploadDialogComponent implements OnDestroy {
@ViewChild('fileInput') fileInput!: ElementRef<HTMLInputElement>;
private readonly t = inject(TranslocoService);
isUploading = false;
uploadedFontName = '';
selectedFile: File | null = null;
isDragOver = false;
previewFontFamily: string | null = null;
isLoadingPreview = false;
currentPreviewToken: number | null = null;
readonly maxFileSize = 5242880;
readonly maxFonts = 10;
readonly acceptedFormats = ['.ttf', '.otf', '.woff', '.woff2'];
constructor(
private customFontService: CustomFontService,
private messageService: MessageService,
private dialogRef: DynamicDialogRef
) {}
onUploadZoneClick(): void {
if (this.isUploading) {
return;
}
this.fileInput.nativeElement.click();
}
onFileInputChange(event: Event): void {
const input = event.target as HTMLInputElement;
const file = input.files?.[0];
if (!file) return;
if (!this.validateFile(file)) {
input.value = '';
return;
}
this.processFile(file);
input.value = '';
}
async loadFontPreview(file: File): Promise<void> {
this.cleanupPreviewFont();
const previewToken = Date.now();
this.currentPreviewToken = previewToken;
if (this.isLoadingPreview) {
console.log('Cancelling previous preview load');
}
this.isLoadingPreview = true;
try {
const previewFontName = `preview-font-${previewToken}`;
const arrayBuffer = await file.arrayBuffer();
if (this.currentPreviewToken !== previewToken) {
console.log('Preview operation cancelled - newer preview started');
return;
}
const fontFace = new FontFace(previewFontName, arrayBuffer);
await fontFace.load();
if (this.currentPreviewToken !== previewToken) {
console.log('Preview operation cancelled after load - newer preview started');
document.fonts.delete(fontFace);
return;
}
document.fonts.add(fontFace);
this.previewFontFamily = `"${previewFontName}"`;
} catch (error) {
if (this.currentPreviewToken === previewToken) {
console.error('Failed to load font preview:', error);
this.previewFontFamily = null;
this.messageService.add({
severity: 'warn',
summary: this.t.translate('settingsReader.fonts.upload.previewFailed'),
detail: this.t.translate('settingsReader.fonts.upload.previewFailedDetail')
});
}
} finally {
if (this.currentPreviewToken === previewToken) {
this.isLoadingPreview = false;
}
}
}
uploadFont(): void {
if (!this.selectedFile) {
this.messageService.add({
severity: 'warn',
summary: this.t.translate('settingsReader.fonts.upload.noFileSelected'),
detail: this.t.translate('settingsReader.fonts.upload.noFileSelectedDetail')
});
return;
}
this.isUploading = true;
this.customFontService.uploadFont(this.selectedFile, this.uploadedFontName || undefined).subscribe({
next: (font) => {
this.messageService.add({
severity: 'success',
summary: this.t.translate('settingsReader.fonts.upload.success'),
detail: this.t.translate('settingsReader.fonts.upload.successDetail', {name: font.fontName})
});
this.isUploading = false;
this.dialogRef.close(font); // Return the uploaded font
},
error: (error) => {
console.error('Failed to upload font:', error);
const errorMessage = error.status === 400
? this.t.translate('settingsReader.fonts.upload.uploadFailedInvalid')
: this.t.translate('settingsReader.fonts.upload.uploadFailedDefault');
this.messageService.add({
severity: 'error',
summary: this.t.translate('settingsReader.fonts.upload.uploadFailed'),
detail: errorMessage
});
this.isUploading = false;
this.selectedFile = null;
this.uploadedFontName = '';
this.cleanupPreviewFont();
}
});
}
formatFileSize(bytes: number): string {
return formatFileSize(bytes);
}
cancel(): void {
this.cleanupPreviewFont();
this.dialogRef.close(null);
}
onDragOver(event: DragEvent): void {
event.preventDefault();
event.stopPropagation();
this.isDragOver = true;
}
onDragLeave(event: DragEvent): void {
event.preventDefault();
event.stopPropagation();
this.isDragOver = false;
}
onDrop(event: DragEvent): void {
event.preventDefault();
event.stopPropagation();
this.isDragOver = false;
const files = event.dataTransfer?.files;
if (files && files.length > 0) {
const file = files[0];
if (!this.validateFile(file)) {
return;
}
this.processFile(file);
}
}
private validateFile(file: File): boolean {
const fileName = file.name.toLowerCase();
const isValidFormat = this.acceptedFormats.some(format => fileName.endsWith(format));
if (!isValidFormat) {
this.messageService.add({
severity: 'error',
summary: this.t.translate('settingsReader.fonts.upload.invalidFileType'),
detail: this.t.translate('settingsReader.fonts.upload.invalidFileTypeDetail')
});
return false;
}
if (file.size > this.maxFileSize) {
this.messageService.add({
severity: 'error',
summary: this.t.translate('settingsReader.fonts.upload.fileTooLarge'),
detail: this.t.translate('settingsReader.fonts.upload.fileTooLargeDetail', {size: this.formatFileSize(this.maxFileSize)})
});
return false;
}
return true;
}
private processFile(file: File): void {
this.selectedFile = file;
this.uploadedFontName = file.name.replace(/\.[^/.]+$/, '');
this.loadFontPreview(file);
}
cleanupPreviewFont(): void {
if (this.previewFontFamily) {
const fontName = this.previewFontFamily.replace(/"/g, '');
try {
for (const font of document.fonts) {
if (font.family === fontName) {
document.fonts.delete(font);
}
}
} catch (error) {
console.error('Failed to cleanup preview font:', fontName, error);
}
this.previewFontFamily = null;
}
this.currentPreviewToken = null;
this.isLoadingPreview = false;
}
ngOnDestroy(): void {
this.cleanupPreviewFont();
}
}