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>,
|
pub tracks: Option<TracksContainer>,
|
||||||
/// Universal Product Code for the album
|
/// Universal Product Code for the album
|
||||||
pub upc: Option<String>,
|
pub upc: Option<String>,
|
||||||
|
/// Editorial description/review of the album
|
||||||
|
pub description: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ pub struct AlbumInfo {
|
|||||||
pub duration: String,
|
pub duration: String,
|
||||||
pub bit_depth: Option<u32>,
|
pub bit_depth: Option<u32>,
|
||||||
pub sampling_rate: Option<f64>,
|
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
|
/// 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),
|
duration: format_duration(total_duration),
|
||||||
bit_depth: album.maximum_bit_depth,
|
bit_depth: album.maximum_bit_depth,
|
||||||
sampling_rate: album.maximum_sampling_rate,
|
sampling_rate: album.maximum_sampling_rate,
|
||||||
|
description: album.description.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,17 @@
|
|||||||
|
|
||||||
let { isOpen, albumId, onClose, onTrackPlay }: Props = $props();
|
let { isOpen, albumId, onClose, onTrackPlay }: Props = $props();
|
||||||
|
|
||||||
|
type TabType = 'credits' | 'review';
|
||||||
|
|
||||||
let loading = $state(false);
|
let loading = $state(false);
|
||||||
let error = $state<string | null>(null);
|
let error = $state<string | null>(null);
|
||||||
let credits = $state<AlbumCredits | null>(null);
|
let credits = $state<AlbumCredits | null>(null);
|
||||||
let expandedTracks = $state<Set<number>>(new Set());
|
let expandedTracks = $state<Set<number>>(new Set());
|
||||||
let hoveredTrack = $state<number | null>(null);
|
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
|
// Load album credits when modal opens
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
@@ -27,6 +33,7 @@
|
|||||||
credits = null;
|
credits = null;
|
||||||
error = null;
|
error = null;
|
||||||
expandedTracks = new Set();
|
expandedTracks = new Set();
|
||||||
|
activeTab = 'credits';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -35,10 +42,6 @@
|
|||||||
error = null;
|
error = null;
|
||||||
try {
|
try {
|
||||||
credits = await invoke<AlbumCredits>('get_album_credits', { albumId: id });
|
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) {
|
} catch (e) {
|
||||||
error = e instanceof Error ? e.message : String(e);
|
error = e instanceof Error ? e.message : String(e);
|
||||||
credits = null;
|
credits = null;
|
||||||
@@ -69,8 +72,22 @@
|
|||||||
<!-- Header with tabs -->
|
<!-- Header with tabs -->
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<div class="tabs">
|
<div class="tabs">
|
||||||
<button class="tab active">Credits</button>
|
<button
|
||||||
<button class="tab disabled" disabled>Review</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>
|
</div>
|
||||||
<button class="close-btn" onclick={onClose} aria-label="Close">
|
<button class="close-btn" onclick={onClose} aria-label="Close">
|
||||||
<X size={20} />
|
<X size={20} />
|
||||||
@@ -133,7 +150,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Right column: Track list -->
|
<!-- Right column: Content based on active tab -->
|
||||||
|
{#if activeTab === 'credits'}
|
||||||
<div class="tracks-list">
|
<div class="tracks-list">
|
||||||
{#each credits.tracks as track (track.id)}
|
{#each credits.tracks as track (track.id)}
|
||||||
{@const isExpanded = expandedTracks.has(track.id)}
|
{@const isExpanded = expandedTracks.has(track.id)}
|
||||||
@@ -198,6 +216,13 @@
|
|||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
{:else if activeTab === 'review' && credits.album.description}
|
||||||
|
<div class="review-content">
|
||||||
|
<div class="review-text">
|
||||||
|
{@html credits.album.description}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -543,4 +568,45 @@
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: var(--text-muted);
|
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>
|
</style>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount, tick } from 'svelte';
|
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 AlbumCard from '../AlbumCard.svelte';
|
||||||
import TrackRow from '../TrackRow.svelte';
|
import TrackRow from '../TrackRow.svelte';
|
||||||
import AlbumMenu from '../AlbumMenu.svelte';
|
import AlbumMenu from '../AlbumMenu.svelte';
|
||||||
@@ -357,7 +357,9 @@
|
|||||||
onclick={onShowAlbumCredits}
|
onclick={onShowAlbumCredits}
|
||||||
title="Album credits"
|
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>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
<AlbumMenu
|
<AlbumMenu
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ export interface AlbumInfo {
|
|||||||
duration: string;
|
duration: string;
|
||||||
bit_depth?: number;
|
bit_depth?: number;
|
||||||
sampling_rate?: number;
|
sampling_rate?: number;
|
||||||
|
description?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TrackCredits {
|
export interface TrackCredits {
|
||||||
|
|||||||
Reference in new issue
Block a user