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,403 @@
<ng-container *transloco="let t; prefix: 'readerAudiobook'">
@if (isLoading) {
<div class="loading-container">
<p-progressSpinner strokeWidth="3" />
<span class="loading-text">{{ t('loading') }}</span>
</div>
} @else if (audiobookInfo) {
<div class="audiobook-player">
<!-- Hidden audio element -->
<audio
#audioElement
(loadedmetadata)="onAudioLoaded()"
(timeupdate)="onTimeUpdate()"
(progress)="onProgress()"
(ended)="onAudioEnded()"
(error)="onAudioError()"
></audio>
<!-- Header -->
<header class="reader-header">
<p-button
icon="pi pi-arrow-left"
[rounded]="true"
[text]="true"
severity="secondary"
(onClick)="closeReader()"
[pTooltip]="t('header.backTooltip')"
tooltipPosition="bottom"
/>
<div class="header-info">
<h1 class="book-title">{{ audiobookInfo.title || t('untitled') }}</h1>
<span class="book-author">{{ audiobookInfo.author || t('unknownAuthor') }}</span>
</div>
<div class="header-actions">
<p-button
icon="pi pi-bookmark"
[rounded]="true"
[text]="true"
severity="secondary"
(onClick)="toggleBookmarkList()"
[pTooltip]="t('header.bookmarksTooltip')"
tooltipPosition="bottom"
/>
<p-button
icon="pi pi-list"
[rounded]="true"
[text]="true"
severity="secondary"
(onClick)="toggleTrackList()"
[pTooltip]="t('header.chaptersTracksTooltip')"
tooltipPosition="bottom"
/>
</div>
</header>
<!-- Main content -->
<main class="reader-main">
<!-- Cover art -->
<div class="cover-container">
<div class="cover-wrapper">
@if (coverUrl) {
<img
[src]="coverUrl"
(error)="onCoverError()"
[alt]="t('coverAlt')"
class="cover-image"
/>
} @else {
<div class="cover-placeholder">
<i class="pi pi-headphones"></i>
</div>
}
@if (audioLoading) {
<div class="cover-loading">
<p-progressSpinner strokeWidth="3" />
</div>
}
</div>
</div>
<!-- Track/Chapter info -->
<div class="track-info">
@if (audiobookInfo.folderBased && currentTrack) {
<span class="track-title">{{ currentTrack.title }}</span>
<span class="track-number">{{ t('trackInfo.trackOf', { current: currentTrackIndex + 1, total: audiobookInfo.tracks?.length }) }}</span>
} @else if (getCurrentChapter()) {
<span class="track-title">{{ getCurrentChapter()?.title }}</span>
@if (hasMultipleChapters()) {
<span class="track-number">{{ t('trackInfo.chapterOf', { current: getCurrentChapterIndex() + 1, total: audiobookInfo.chapters?.length }) }}</span>
}
}
</div>
<!-- Progress bar -->
<div class="progress-container">
<div class="time-display">
<span class="current-time">{{ formatTime(currentTime) }}</span>
<span class="duration">{{ formatTime(duration) }}</span>
</div>
<div class="progress-bar-wrapper">
<div class="buffered-bar" [style.width.%]="getBufferedPercent()"></div>
<p-slider
[(ngModel)]="currentTime"
[min]="0"
[max]="duration || 100"
[step]="1"
(onChange)="seek($event)"
class="progress-slider"
/>
</div>
</div>
<!-- Playback controls -->
<div class="playback-controls">
@if (audiobookInfo.folderBased) {
<p-button
icon="pi pi-step-backward"
[rounded]="true"
[text]="true"
severity="secondary"
(onClick)="previousTrack()"
[disabled]="currentTrackIndex === 0"
[pTooltip]="t('controls.previousTrackTooltip')"
tooltipPosition="top"
size="large"
/>
} @else if (hasMultipleChapters()) {
<p-button
icon="pi pi-step-backward"
[rounded]="true"
[text]="true"
severity="secondary"
(onClick)="previousChapter()"
[disabled]="!canGoPreviousChapter()"
[pTooltip]="t('controls.previousChapterTooltip')"
tooltipPosition="top"
size="large"
/>
}
<p-button
icon="pi pi-replay"
[rounded]="true"
[text]="true"
severity="secondary"
(onClick)="seekRelative(-30)"
[pTooltip]="t('controls.rewindTooltip')"
tooltipPosition="top"
size="large"
/>
<p-button
[icon]="isPlaying ? 'pi pi-pause' : 'pi pi-play'"
[rounded]="true"
severity="contrast"
(onClick)="togglePlay()"
[disabled]="audioLoading"
class="play-button"
size="large"
/>
<p-button
icon="pi pi-forward"
[rounded]="true"
[text]="true"
severity="secondary"
(onClick)="seekRelative(30)"
[pTooltip]="t('controls.forwardTooltip')"
tooltipPosition="top"
size="large"
/>
@if (audiobookInfo.folderBased) {
<p-button
icon="pi pi-step-forward"
[rounded]="true"
[text]="true"
severity="secondary"
(onClick)="nextTrack()"
[disabled]="!audiobookInfo.tracks || currentTrackIndex >= audiobookInfo.tracks.length - 1"
[pTooltip]="t('controls.nextTrackTooltip')"
tooltipPosition="top"
size="large"
/>
} @else if (hasMultipleChapters()) {
<p-button
icon="pi pi-step-forward"
[rounded]="true"
[text]="true"
severity="secondary"
(onClick)="nextChapter()"
[disabled]="!canGoNextChapter()"
[pTooltip]="t('controls.nextChapterTooltip')"
tooltipPosition="top"
size="large"
/>
}
</div>
<!-- Secondary controls -->
<div class="secondary-controls">
<!-- Volume -->
<div class="volume-control">
<p-button
[icon]="getVolumeIcon()"
[rounded]="true"
[text]="true"
severity="secondary"
(onClick)="toggleMute()"
size="small"
/>
<p-slider
[(ngModel)]="volume"
[min]="0"
[max]="1"
[step]="0.01"
(onChange)="setVolume($event)"
class="volume-slider"
/>
</div>
<!-- Playback speed -->
<div class="speed-control">
<p-selectButton
[options]="playbackRates"
[ngModel]="playbackRate"
(ngModelChange)="setPlaybackRate($event)"
optionLabel="label"
optionValue="value"
size="small"
/>
</div>
</div>
<!-- Extra controls row -->
<div class="extra-controls">
<!-- Add bookmark button -->
<p-button
icon="pi pi-bookmark-fill"
[label]="t('extra.addBookmark')"
[rounded]="true"
[text]="true"
severity="secondary"
(onClick)="addBookmark()"
size="small"
/>
<!-- Sleep timer -->
<p-button
#sleepTimerBtn
icon="pi pi-moon"
[label]="sleepTimerActive ? formatSleepTimerRemaining() : t('extra.sleepTimer')"
[rounded]="true"
[text]="true"
severity="secondary"
[class]="sleepTimerActive ? 'sleep-timer-active' : ''"
(onClick)="sleepTimerMenu.toggle($event)"
size="small"
/>
<p-menu
#sleepTimerMenu
[model]="sleepTimerOptions"
[popup]="true"
appendTo="body"
/>
</div>
<!-- Audio details -->
<div class="audio-details">
@if (audiobookInfo.narrator) {
<span class="detail-item">
<i class="pi pi-user"></i>
{{ t('details.narratedBy', { narrator: audiobookInfo.narrator }) }}
</span>
}
@if (audiobookInfo.bitrate) {
<span class="detail-item">
<i class="pi pi-sliders-h"></i>
{{ t('details.kbps', { bitrate: audiobookInfo.bitrate }) }}
</span>
}
@if (audiobookInfo.durationMs) {
<span class="detail-item">
<i class="pi pi-clock"></i>
{{ t('details.totalDuration', { duration: formatDuration(audiobookInfo.durationMs) }) }}
</span>
}
</div>
</main>
<!-- Track/Chapter list sidebar -->
@if (showTrackList) {
<aside class="track-list-sidebar">
<div class="sidebar-header">
<h2>{{ audiobookInfo.folderBased ? t('sidebar.tracks') : t('sidebar.chapters') }}</h2>
<p-button
icon="pi pi-times"
[rounded]="true"
[text]="true"
severity="secondary"
(onClick)="toggleTrackList()"
/>
</div>
<div class="sidebar-content">
@if (audiobookInfo.folderBased && audiobookInfo.tracks) {
<ul class="track-list">
@for (track of audiobookInfo.tracks; track track.index) {
<li
class="track-item"
[class.active]="track.index === currentTrackIndex"
(click)="selectTrack(track)"
>
<span class="track-index">{{ track.index + 1 }}</span>
<div class="track-details">
<span class="track-name">{{ track.title }}</span>
<span class="track-duration">{{ formatDuration(track.durationMs) }}</span>
</div>
@if (track.index === currentTrackIndex && isPlaying) {
<i class="pi pi-volume-up playing-indicator"></i>
}
</li>
}
</ul>
} @else if (audiobookInfo.chapters) {
<ul class="track-list">
@for (chapter of audiobookInfo.chapters; track chapter.index) {
<li
class="track-item"
[class.active]="getCurrentChapter()?.index === chapter.index"
(click)="selectChapter(chapter)"
>
<span class="track-index">{{ chapter.index + 1 }}</span>
<div class="track-details">
<span class="track-name">{{ chapter.title }}</span>
<span class="track-duration">{{ formatDuration(chapter.durationMs) }}</span>
</div>
@if (getCurrentChapter()?.index === chapter.index && isPlaying) {
<i class="pi pi-volume-up playing-indicator"></i>
}
</li>
}
</ul>
}
</div>
</aside>
}
<!-- Bookmark list sidebar -->
@if (showBookmarkList) {
<aside class="track-list-sidebar bookmark-sidebar">
<div class="sidebar-header">
<h2>{{ t('bookmarks.title') }}</h2>
<p-button
icon="pi pi-times"
[rounded]="true"
[text]="true"
severity="secondary"
(onClick)="toggleBookmarkList()"
/>
</div>
<div class="sidebar-content">
@if (bookmarks.length === 0) {
<div class="empty-bookmarks">
<i class="pi pi-bookmark"></i>
<p>{{ t('bookmarks.empty') }}</p>
<span>{{ t('bookmarks.emptyHint') }}</span>
</div>
} @else {
<ul class="track-list">
@for (bookmark of bookmarks; track bookmark.id) {
<li
class="track-item bookmark-item"
(click)="goToBookmark(bookmark)"
>
<i class="pi pi-bookmark-fill bookmark-icon"></i>
<div class="track-details">
<span class="track-name">{{ bookmark.title }}</span>
<span class="track-duration">{{ formatBookmarkPosition(bookmark) }}</span>
</div>
<p-button
icon="pi pi-trash"
[rounded]="true"
[text]="true"
severity="danger"
size="small"
(onClick)="deleteBookmark($event, bookmark.id)"
[pTooltip]="t('bookmarks.deleteTooltip')"
tooltipPosition="left"
/>
</li>
}
</ul>
}
</div>
</aside>
}
</div>
} @else {
<div class="loading-container">
<span class="loading-text">{{ t('toast.loadFailed') }}</span>
</div>
}
</ng-container>
@@ -0,0 +1,803 @@
@use 'sass:color';
// Variables - More vibrant color palette
$bg-primary: #0f0f1a;
$bg-secondary: #1a1a2e;
$bg-tertiary: #252542;
$bg-darker: #0a0a12;
$text-primary: #ffffff;
$text-secondary: rgba(255, 255, 255, 0.8);
$text-tertiary: rgba(255, 255, 255, 0.5);
$accent-secondary: #ec4899;
$accent-tertiary: #06b6d4;
$border-color: rgba(255, 255, 255, 0.1);
// CSS variable for primary color from theme
:host {
--accent-color: var(--primary-color, #8b5cf6);
--accent-hover: var(--primary-hover-color, #a78bfa);
}
// Gradient mixins
@mixin gradient-bg {
background: linear-gradient(135deg, $bg-secondary 0%, $bg-primary 50%, $bg-darker 100%);
}
@mixin accent-gradient {
background: linear-gradient(135deg, var(--accent-color) 0%, $accent-secondary 100%);
}
@mixin glow-effect($color, $intensity: 0.4) {
box-shadow: 0 0 40px rgba($color, $intensity),
0 0 80px rgba($color, $intensity * 0.5);
}
// Loading container
.loading-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
@include gradient-bg;
gap: 1rem;
.loading-text {
color: $text-secondary;
font-size: 0.9rem;
}
::ng-deep .p-progress-spinner-circle {
stroke: var(--accent-color) !important;
}
}
// Main container
.audiobook-player {
display: flex;
flex-direction: column;
height: 100vh;
@include gradient-bg;
color: $text-primary;
overflow: hidden;
position: relative;
// Subtle animated gradient overlay
&::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: radial-gradient(ellipse at 20% 0%, color-mix(in srgb, var(--accent-color) 15%, transparent) 0%, transparent 50%),
radial-gradient(ellipse at 80% 100%, rgba($accent-secondary, 0.1) 0%, transparent 50%);
pointer-events: none;
z-index: 0;
}
}
// Header
.reader-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem 1.5rem;
background: rgba(0, 0, 0, 0.4);
backdrop-filter: blur(20px);
border-bottom: 1px solid $border-color;
z-index: 10;
position: relative;
.header-info {
flex: 1;
text-align: center;
padding: 0 1rem;
overflow: hidden;
.book-title {
font-size: 1.1rem;
font-weight: 600;
margin: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
background: linear-gradient(90deg, $text-primary, var(--accent-color));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.book-author {
font-size: 0.85rem;
color: $text-secondary;
}
}
.header-actions {
display: flex;
gap: 0.25rem;
}
::ng-deep .p-button {
&.p-button-text {
color: $text-secondary;
&:hover {
color: $text-primary;
background: color-mix(in srgb, var(--accent-color) 20%, transparent);
}
}
}
}
// Main content
.reader-main {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
padding: 2rem 1.5rem;
overflow-y: auto;
gap: 1.5rem;
position: relative;
z-index: 1;
}
// Cover art
.cover-container {
flex-shrink: 0;
width: 100%;
max-width: min(480px, 40vh);
aspect-ratio: 1;
.cover-wrapper {
position: relative;
width: 100%;
height: 100%;
border-radius: 16px;
overflow: hidden;
box-shadow:
0 25px 60px -12px rgba(0, 0, 0, 0.6),
0 0 0 1px rgba(255, 255, 255, 0.1),
0 0 60px color-mix(in srgb, var(--accent-color) 20%, transparent),
0 0 100px rgba($accent-secondary, 0.1);
transition: transform 0.3s ease, box-shadow 0.3s ease;
&:hover {
transform: scale(1.02);
box-shadow:
0 30px 70px -12px rgba(0, 0, 0, 0.7),
0 0 0 1px rgba(255, 255, 255, 0.15),
0 0 80px color-mix(in srgb, var(--accent-color) 30%, transparent),
0 0 120px rgba($accent-secondary, 0.15);
}
.cover-image {
width: 100%;
height: 100%;
object-fit: cover;
}
.cover-loading {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
background: rgba(0, 0, 0, 0.7);
backdrop-filter: blur(4px);
}
.cover-placeholder {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
@include accent-gradient;
opacity: 0.8;
i {
font-size: 5rem;
color: rgba(255, 255, 255, 0.9);
text-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
}
}
}
}
// Track info
.track-info {
text-align: center;
min-height: 3rem;
.track-title {
display: block;
font-size: 1.1rem;
font-weight: 600;
color: $text-primary;
margin-bottom: 0.25rem;
}
.track-number {
font-size: 0.85rem;
color: var(--accent-color);
font-weight: 500;
}
}
// Progress bar
.progress-container {
width: 100%;
max-width: 500px;
.time-display {
display: flex;
justify-content: space-between;
margin-bottom: 0.75rem;
font-size: 0.85rem;
color: $text-secondary;
font-variant-numeric: tabular-nums;
font-weight: 500;
}
.progress-bar-wrapper {
position: relative;
height: 8px;
background: rgba(255, 255, 255, 0.1);
border-radius: 4px;
overflow: visible;
.buffered-bar {
position: absolute;
top: 0;
left: 0;
height: 100%;
background: rgba(255, 255, 255, 0.15);
border-radius: 4px;
transition: width 0.3s ease;
}
::ng-deep .progress-slider {
position: absolute;
top: 50%;
left: 0;
right: 0;
transform: translateY(-50%);
.p-slider {
background: transparent;
height: 8px;
.p-slider-range {
@include accent-gradient;
border-radius: 4px;
box-shadow: 0 0 10px color-mix(in srgb, var(--accent-color) 50%, transparent);
}
.p-slider-handle {
width: 18px;
height: 18px;
background: $text-primary;
border: 3px solid var(--accent-color);
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4),
0 0 15px color-mix(in srgb, var(--accent-color) 40%, transparent);
transition: transform 0.15s ease, box-shadow 0.15s ease;
&:hover {
transform: scale(1.2);
box-shadow: 0 2px 15px rgba(0, 0, 0, 0.5),
0 0 25px color-mix(in srgb, var(--accent-color) 60%, transparent);
}
}
}
}
}
}
// Playback controls
.playback-controls {
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
::ng-deep .play-button {
.p-button {
width: 72px;
height: 72px;
font-size: 1.75rem;
@include accent-gradient;
border: none;
box-shadow: 0 8px 30px color-mix(in srgb, var(--accent-color) 40%, transparent),
0 0 50px color-mix(in srgb, var(--accent-color) 20%, transparent);
transition: transform 0.2s ease, box-shadow 0.2s ease;
&:hover {
transform: scale(1.05);
box-shadow: 0 10px 40px color-mix(in srgb, var(--accent-color) 50%, transparent),
0 0 70px color-mix(in srgb, var(--accent-color) 30%, transparent);
}
&:active {
transform: scale(0.98);
}
.p-button-icon {
font-size: 1.75rem;
}
}
}
::ng-deep .p-button {
&.p-button-text {
color: $text-secondary;
transition: all 0.2s ease;
&:hover {
color: $text-primary;
background: color-mix(in srgb, var(--accent-color) 20%, transparent);
transform: scale(1.1);
}
&:disabled {
color: $text-tertiary;
opacity: 0.4;
transform: none;
}
}
&.p-button-lg {
width: 48px;
height: 48px;
}
}
}
// Secondary controls
.secondary-controls {
display: flex;
align-items: center;
justify-content: center;
gap: 2rem;
width: 100%;
max-width: 500px;
padding: 1rem 0;
}
.volume-control {
display: flex;
align-items: center;
gap: 0.75rem;
::ng-deep .p-button.p-button-text {
color: $text-secondary;
&:hover {
color: var(--accent-color);
background: color-mix(in srgb, var(--accent-color) 15%, transparent);
}
}
::ng-deep .volume-slider {
width: 100px;
.p-slider {
background: rgba(255, 255, 255, 0.15);
height: 5px;
border-radius: 3px;
.p-slider-range {
background: $accent-tertiary;
border-radius: 3px;
}
.p-slider-handle {
width: 14px;
height: 14px;
background: $text-primary;
border: 2px solid $accent-tertiary;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
}
}
}
.speed-control {
::ng-deep .p-selectbutton {
.p-button {
padding: 0.5rem 0.75rem;
font-size: 0.8rem;
font-weight: 600;
background: rgba(255, 255, 255, 0.08);
border: 1px solid rgba(255, 255, 255, 0.1);
color: $text-secondary;
transition: all 0.2s ease;
&:hover {
background: rgba(255, 255, 255, 0.12);
color: $text-primary;
border-color: rgba(255, 255, 255, 0.2);
}
&.p-highlight {
@include accent-gradient;
color: $text-primary;
border-color: transparent;
box-shadow: 0 4px 15px color-mix(in srgb, var(--accent-color) 30%, transparent);
}
}
}
}
// Audio details
.audio-details {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
gap: 1.25rem;
padding: 1rem;
color: $text-tertiary;
font-size: 0.8rem;
background: rgba(255, 255, 255, 0.03);
border-radius: 12px;
margin-top: 0.5rem;
.detail-item {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 0.75rem;
background: rgba(255, 255, 255, 0.05);
border-radius: 8px;
white-space: nowrap;
i {
font-size: 0.9rem;
color: $accent-tertiary;
}
}
}
// Extra controls (bookmark, sleep timer)
.extra-controls {
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
padding-top: 0.5rem;
::ng-deep .p-button {
&.p-button-text {
color: $text-secondary;
font-size: 0.85rem;
&:hover {
color: $text-primary;
background: color-mix(in srgb, var(--accent-color) 15%, transparent);
}
.p-button-icon {
font-size: 1rem;
}
}
&.sleep-timer-active {
color: #fbbf24 !important;
&:hover {
background: rgba(251, 191, 36, 0.15) !important;
}
}
}
}
// Empty bookmarks
.empty-bookmarks {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 3rem 1.5rem;
text-align: center;
color: $text-tertiary;
i {
font-size: 3rem;
margin-bottom: 1rem;
opacity: 0.5;
}
p {
margin: 0 0 0.5rem;
font-size: 1rem;
font-weight: 500;
color: $text-secondary;
}
span {
font-size: 0.85rem;
}
}
// Bookmark item
.bookmark-item {
.bookmark-icon {
color: var(--accent-color);
font-size: 1.1rem;
flex-shrink: 0;
}
::ng-deep .p-button {
opacity: 0;
transition: opacity 0.2s ease;
}
&:hover {
::ng-deep .p-button {
opacity: 1;
}
}
}
// Track list sidebar
.track-list-sidebar {
position: fixed;
top: 0;
right: 0;
width: 100%;
max-width: 400px;
height: 100vh;
background: linear-gradient(180deg, $bg-tertiary 0%, $bg-secondary 100%);
border-left: 1px solid color-mix(in srgb, var(--accent-color) 20%, transparent);
z-index: 100;
display: flex;
flex-direction: column;
animation: slideIn 0.25s ease-out;
box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
@keyframes slideIn {
from {
transform: translateX(100%);
opacity: 0.5;
}
to {
transform: translateX(0);
opacity: 1;
}
}
.sidebar-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1.25rem 1.5rem;
border-bottom: 1px solid $border-color;
background: rgba(0, 0, 0, 0.2);
h2 {
margin: 0;
font-size: 1.2rem;
font-weight: 600;
background: linear-gradient(90deg, $text-primary, var(--accent-color));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
::ng-deep .p-button.p-button-text {
color: $text-secondary;
&:hover {
color: $text-primary;
background: color-mix(in srgb, var(--accent-color) 20%, transparent);
}
}
}
.sidebar-content {
flex: 1;
overflow-y: auto;
padding: 0.5rem 0;
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-track {
background: transparent;
}
&::-webkit-scrollbar-thumb {
background: color-mix(in srgb, var(--accent-color) 30%, transparent);
border-radius: 3px;
&:hover {
background: color-mix(in srgb, var(--accent-color) 50%, transparent);
}
}
}
}
.track-list {
list-style: none;
margin: 0;
padding: 0;
.track-item {
display: flex;
align-items: center;
padding: 1rem 1.5rem;
cursor: pointer;
transition: all 0.2s ease;
gap: 1rem;
border-left: 3px solid transparent;
&:hover {
background: color-mix(in srgb, var(--accent-color) 10%, transparent);
border-left-color: color-mix(in srgb, var(--accent-color) 50%, transparent);
}
&.active {
background: linear-gradient(90deg, color-mix(in srgb, var(--accent-color) 20%, transparent) 0%, transparent 100%);
border-left-color: var(--accent-color);
.track-index {
color: var(--accent-color);
font-weight: 700;
}
.track-name {
color: var(--accent-color);
}
}
.track-index {
width: 2rem;
text-align: center;
font-size: 0.9rem;
color: $text-tertiary;
flex-shrink: 0;
font-weight: 600;
}
.track-details {
flex: 1;
min-width: 0;
.track-name {
display: block;
font-size: 0.95rem;
color: $text-primary;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-weight: 500;
}
.track-duration {
font-size: 0.8rem;
color: $text-tertiary;
margin-top: 0.2rem;
}
}
.playing-indicator {
color: var(--accent-color);
animation: pulse 1.5s ease-in-out infinite;
font-size: 1.1rem;
}
@keyframes pulse {
0%, 100% {
opacity: 1;
transform: scale(1);
}
50% {
opacity: 0.6;
transform: scale(0.95);
}
}
}
}
// Responsive adjustments
@media (max-width: 768px) {
.reader-main {
padding: 1rem;
gap: 1rem;
}
.cover-container {
max-width: min(360px, 35vh);
}
.secondary-controls {
flex-direction: column;
gap: 1rem;
}
.volume-control {
::ng-deep .volume-slider {
width: 150px;
}
}
.track-list-sidebar {
max-width: 75%;
}
.audio-details {
gap: 0.75rem;
padding: 0.75rem;
.detail-item {
padding: 0.4rem 0.6rem;
font-size: 0.75rem;
i {
font-size: 0.8rem;
}
}
}
}
@media (max-width: 480px) {
.cover-container {
max-width: min(300px, 30vh);
}
.playback-controls {
gap: 0.5rem;
::ng-deep .play-button {
.p-button {
width: 64px;
height: 64px;
}
}
::ng-deep .p-button.p-button-lg {
width: 40px;
height: 40px;
}
}
.audio-details {
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
gap: 0.5rem;
.detail-item {
flex: 0 1 auto;
}
}
}
// Landscape mode optimization
@media (max-height: 600px) and (orientation: landscape) {
.reader-main {
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
gap: 1rem;
}
.cover-container {
max-width: 180px;
}
.track-info,
.progress-container,
.playback-controls,
.secondary-controls {
width: auto;
}
.audio-details {
flex-direction: row;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,39 @@
export interface AudiobookInfo {
bookId: number;
bookFileId: number;
title?: string;
author?: string;
narrator?: string;
durationMs: number;
bitrate?: number;
codec?: string;
sampleRate?: number;
channels?: number;
folderBased: boolean;
chapters?: AudiobookChapter[];
tracks?: AudiobookTrack[];
}
export interface AudiobookChapter {
index: number;
title: string;
startTimeMs: number;
endTimeMs: number;
durationMs: number;
}
export interface AudiobookTrack {
index: number;
fileName: string;
title: string;
durationMs: number;
fileSizeBytes: number;
cumulativeStartMs: number;
}
export interface AudiobookProgress {
positionMs: number;
trackIndex?: number;
trackPositionMs?: number;
percentage: number;
}
@@ -0,0 +1,64 @@
import { inject, Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { API_CONFIG } from '../../../core/config/api-config';
import { AudiobookInfo, AudiobookProgress } from './audiobook.model';
import { AuthService } from '../../../shared/service/auth.service';
import { BookFileProgress } from '../../book/model/book.model';
@Injectable({
providedIn: 'root'
})
export class AudiobookService {
private readonly baseUrl = `${API_CONFIG.BASE_URL}/api/v1/audiobooks`;
private readonly booksUrl = `${API_CONFIG.BASE_URL}/api/v1/books`;
private http = inject(HttpClient);
private authService = inject(AuthService);
getAudiobookInfo(bookId: number, bookType?: string): Observable<AudiobookInfo> {
const params: Record<string, string> = {};
if (bookType) {
params['bookType'] = bookType;
}
return this.http.get<AudiobookInfo>(`${this.baseUrl}/${bookId}/info`, { params });
}
getStreamUrl(bookId: number, trackIndex?: number): string {
const token = this.authService.getInternalAccessToken();
let url = `${this.baseUrl}/${bookId}/stream?ngsw-bypass=true&token=${encodeURIComponent(token || '')}`;
if (trackIndex !== undefined && trackIndex !== null) {
url += `&trackIndex=${trackIndex}`;
}
return url;
}
getTrackStreamUrl(bookId: number, trackIndex: number): string {
const token = this.authService.getInternalAccessToken();
return `${this.baseUrl}/${bookId}/track/${trackIndex}/stream?ngsw-bypass=true&token=${encodeURIComponent(token || '')}`;
}
getEmbeddedCoverUrl(bookId: number): string {
const token = this.authService.getInternalAccessToken();
return `${this.baseUrl}/${bookId}/cover?ngsw-bypass=true&token=${encodeURIComponent(token || '')}`;
}
saveProgress(bookId: number, progress: AudiobookProgress, bookFileId?: number): Observable<void> {
if (bookFileId) {
const fileProgress: BookFileProgress = {
bookFileId: bookFileId,
positionData: progress.positionMs.toString(),
positionHref: progress.trackIndex?.toString(),
progressPercent: progress.percentage
};
return this.http.post<void>(`${this.booksUrl}/progress`, {
bookId,
fileProgress
});
}
return this.http.post<void>(`${this.booksUrl}/progress`, {
bookId,
audiobookProgress: progress
});
}
}
@@ -0,0 +1,3 @@
export * from './audiobook-player.component';
export * from './audiobook.service';
export * from './audiobook.model';