feat(credits): complete Album Credits Modal with Review tab
- Use custom info SVG icon without circle outline - All tracks collapsed by default (removed auto-expand) - Add description field to Album model for editorial reviews - Implement Review tab with album description content - Tab switches between Credits (track list) and Review (description) - Review tab disabled when no description available
This commit is contained in:
1 parent
3410774f32
commit
6eff22632a
5 files changed
+83
-9
No files matched your search
@@ -105,6 +105,8 @@ pub struct Album {
|
||||
pub tracks: Option<TracksContainer>,
|
||||
/// Universal Product Code for the album
|
||||
pub upc: Option<String>,
|
||||
/// Editorial description/review of the album
|
||||
pub description: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
||||
@@ -46,6 +46,8 @@ pub struct AlbumInfo {
|
||||
pub duration: String,
|
||||
pub bit_depth: Option<u32>,
|
||||
pub sampling_rate: Option<f64>,
|
||||
/// Editorial description/review of the album
|
||||
pub description: Option<String>,
|
||||
}
|
||||
|
||||
/// Format duration in seconds to "Xm Ys" or "Xh Ym" format
|
||||
@@ -104,6 +106,7 @@ fn album_to_info(album: &Album) -> AlbumInfo {
|
||||
duration: format_duration(total_duration),
|
||||
bit_depth: album.maximum_bit_depth,
|
||||
sampling_rate: album.maximum_sampling_rate,
|
||||
description: album.description.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,17 @@
|
||||
|
||||
let { isOpen, albumId, onClose, onTrackPlay }: Props = $props();
|
||||
|
||||
type TabType = 'credits' | 'review';
|
||||
|
||||
let loading = $state(false);
|
||||
let error = $state<string | null>(null);
|
||||
let credits = $state<AlbumCredits | null>(null);
|
||||
let expandedTracks = $state<Set<number>>(new Set());
|
||||
let hoveredTrack = $state<number | null>(null);
|
||||
let activeTab = $state<TabType>('credits');
|
||||
|
||||
// Check if review tab should be available
|
||||
const hasReview = $derived(credits?.album?.description ? true : false);
|
||||
|
||||
// Load album credits when modal opens
|
||||
$effect(() => {
|
||||
@@ -27,6 +33,7 @@
|
||||
credits = null;
|
||||
error = null;
|
||||
expandedTracks = new Set();
|
||||
activeTab = 'credits';
|
||||
}
|
||||
});
|
||||
|
||||
@@ -35,10 +42,6 @@
|
||||
error = null;
|
||||
try {
|
||||
credits = await invoke<AlbumCredits>('get_album_credits', { albumId: id });
|
||||
// Auto-expand first track if it has credits
|
||||
if (credits.tracks.length > 0 && credits.tracks[0].performers.length > 0) {
|
||||
expandedTracks = new Set([credits.tracks[0].id]);
|
||||
}
|
||||
} catch (e) {
|
||||
error = e instanceof Error ? e.message : String(e);
|
||||
credits = null;
|
||||
@@ -69,8 +72,22 @@
|
||||
<!-- Header with tabs -->
|
||||
<div class="modal-header">
|
||||
<div class="tabs">
|
||||
<button class="tab active">Credits</button>
|
||||
<button class="tab disabled" disabled>Review</button>
|
||||
<button
|
||||
class="tab"
|
||||
class:active={activeTab === 'credits'}
|
||||
onclick={() => activeTab = 'credits'}
|
||||
>
|
||||
Credits
|
||||
</button>
|
||||
<button
|
||||
class="tab"
|
||||
class:active={activeTab === 'review'}
|
||||
class:disabled={!hasReview}
|
||||
disabled={!hasReview}
|
||||
onclick={() => hasReview && (activeTab = 'review')}
|
||||
>
|
||||
Review
|
||||
</button>
|
||||
</div>
|
||||
<button class="close-btn" onclick={onClose} aria-label="Close">
|
||||
<X size={20} />
|
||||
@@ -133,7 +150,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right column: Track list -->
|
||||
<!-- Right column: Content based on active tab -->
|
||||
{#if activeTab === 'credits'}
|
||||
<div class="tracks-list">
|
||||
{#each credits.tracks as track (track.id)}
|
||||
{@const isExpanded = expandedTracks.has(track.id)}
|
||||
@@ -198,6 +216,13 @@
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{:else if activeTab === 'review' && credits.album.description}
|
||||
<div class="review-content">
|
||||
<div class="review-text">
|
||||
{@html credits.album.description}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -543,4 +568,45 @@
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* Review Content */
|
||||
.review-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.review-text {
|
||||
font-size: 14px;
|
||||
line-height: 1.7;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.review-text :global(p) {
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
|
||||
.review-text :global(p:last-child) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.review-text :global(a) {
|
||||
color: var(--accent-primary);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.review-text :global(a:hover) {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.review-text :global(strong),
|
||||
.review-text :global(b) {
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.review-text :global(em),
|
||||
.review-text :global(i) {
|
||||
font-style: italic;
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount, tick } from 'svelte';
|
||||
import { ArrowLeft, Play, Shuffle, Heart, CloudDownload, ChevronLeft, ChevronRight, Info } from 'lucide-svelte';
|
||||
import { ArrowLeft, Play, Shuffle, Heart, CloudDownload, ChevronLeft, ChevronRight } from 'lucide-svelte';
|
||||
import AlbumCard from '../AlbumCard.svelte';
|
||||
import TrackRow from '../TrackRow.svelte';
|
||||
import AlbumMenu from '../AlbumMenu.svelte';
|
||||
@@ -357,7 +357,9 @@
|
||||
onclick={onShowAlbumCredits}
|
||||
title="Album credits"
|
||||
>
|
||||
<Info size={18} />
|
||||
<svg width="18" height="18" viewBox="0 0 8 8" fill="currentColor">
|
||||
<path d="M3 0c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm-1.5 2.5c-.83 0-1.5.67-1.5 1.5h1c0-.28.22-.5.5-.5s.5.22.5.5-1 1.64-1 2.5c0 .86.67 1.5 1.5 1.5s1.5-.67 1.5-1.5h-1c0 .28-.22.5-.5.5s-.5-.22-.5-.5c0-.36 1-1.84 1-2.5 0-.81-.67-1.5-1.5-1.5z" transform="translate(2)" />
|
||||
</svg>
|
||||
</button>
|
||||
{/if}
|
||||
<AlbumMenu
|
||||
|
||||
@@ -65,6 +65,7 @@ export interface AlbumInfo {
|
||||
duration: string;
|
||||
bit_depth?: number;
|
||||
sampling_rate?: number;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface TrackCredits {
|
||||
|
||||
Reference in new issue
Block a user