From b70798a0fe16291748fc9f039a78fa8ccd23f114 Mon Sep 17 00:00:00 2001 From: Benjamin Hardy Date: Thu, 15 Oct 2026 15:46:39 +0200 Subject: [PATCH] Implemented track info dialog popup --- frontend/src/App.tsx | 4 + frontend/src/components/PrepStrip.tsx | 41 ++++- frontend/src/components/TrackInfoDialog.tsx | 183 ++++++++++++++++++++ frontend/src/index.css | 12 ++ 4 files changed, 234 insertions(+), 6 deletions(-) create mode 100644 frontend/src/components/TrackInfoDialog.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index a7d1605..bce7c8b 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1450,6 +1450,10 @@ export default function App() { origin={prepOrigin} cuesRefresh={cuesRefresh} onPlayingChange={setDeckPlaying} + // As the context menu's: a library that would refuse the save is + // not offered the dialog, and a deck track outside the collection + // (a device's, a loose file's) is not the collection's to edit. + onEditTags={canEdit && prepOrigin === 'collection' ? setEditing : undefined} /> diff --git a/frontend/src/components/PrepStrip.tsx b/frontend/src/components/PrepStrip.tsx index b8de1be..6b703c0 100644 --- a/frontend/src/components/PrepStrip.tsx +++ b/frontend/src/components/PrepStrip.tsx @@ -28,6 +28,7 @@ import { ScratchEngine } from '../lib/scratchEngine' import { PlaybackEngine } from '../lib/playbackEngine' import { invalidateTrackLists } from '../lib/trackQueries' import { AutoCueDialog, eventLabel } from './AutoCueDialog' +import { TrackInfoDialog } from './TrackInfoDialog' import { ContextMenu, type MenuItem } from './ContextMenu' import { BpmReadout, GridEditStrip, TempoControls, TempoFold } from './GridControls' import { HotcueBar } from './HotcueBar' @@ -60,6 +61,9 @@ interface Props { cuesRefresh?: number /** Reports whether the deck is playing, so the library can light its row. */ onPlayingChange?: (playing: boolean) => void + /** Opens Edit Tags for the loaded track — passed only where the library + * will accept the edit, so the cover popup offers it only then. */ + onEditTags?: (track: Track) => void } /** m:ss.t — the deck's readouts show tenths, as a CDJ does. */ @@ -103,6 +107,7 @@ export function PrepStrip({ origin = 'collection', cuesRefresh = 0, onPlayingChange, + onEditTags, }: Props) { const qc = useQueryClient() const [playing, setPlaying] = useState(false) @@ -133,6 +138,7 @@ export function PrepStrip({ const [snap, setSnap] = useState(true) const [selectedSlot, setSelectedSlot] = useState(null) const [cuePoint, setCuePoint] = useState(0) // floating "CUE" point (frontend-only) + const [infoOpen, setInfoOpen] = useState(false) // the cover's track-info popup const [secPerView, setSecPerView] = useState(DEFAULT_SEC) // main-waveform zoom (persisted) const [rawWave, setRawWave] = useState(false) // main waveform: raw line instead of bars (persisted) // ONE size, in beats, for beat loops and beat jump alike (persisted). @@ -1297,7 +1303,10 @@ export function PrepStrip({
{/* ---- Header: the track, its readouts, the analysis actions ---- */}
- + setInfoOpen(true) : undefined} + />
{track ? ( <> @@ -1585,6 +1594,21 @@ export function PrepStrip({ onClose={() => setPadMenu(null)} /> )} + {infoOpen && track && ( + setInfoOpen(false)} + onEditTags={ + onEditTags + ? () => { + setInfoOpen(false) + onEditTags(track) + } + : undefined + } + /> + )} {autoOpen && track && ( void }) { const [failed, setFailed] = useState(null) const showArt = trackId != null && failed !== trackId return ( -
{showArt && ( @@ -1622,6 +1651,6 @@ function CoverThumb({ trackId }: { trackId: string | null }) { onError={() => setFailed(trackId)} /> )} -
+ ) } diff --git a/frontend/src/components/TrackInfoDialog.tsx b/frontend/src/components/TrackInfoDialog.tsx new file mode 100644 index 0000000..26f8b0f --- /dev/null +++ b/frontend/src/components/TrackInfoDialog.tsx @@ -0,0 +1,183 @@ +import { createPortal } from 'react-dom' +import { useEffect, useState, type ReactNode } from 'react' +import type { Track } from '../api' +import { formatBpm, formatDuration, keyColor } from '../lib/format' +import { useCaps } from '../lib/capabilities' +import { Icon } from '../lib/icons' +import { RatingStars } from './RatingStars' + +interface Props { + track: Track + /** The cover's URL, or null where this track's library serves none (a + * device or a loose file) — the ambient swatch stands in, as in the deck. */ + artUrl: string | null + onClose: () => void + /** Offered only where the library will accept the edit; closes this first. */ + onEditTags?: () => void +} + +/** + * The deck cover's popup: the art large, beside everything the library knows + * about the track. View-only apart from the one way out to Edit Tags. Rows with + * no value are left out rather than shown as dashes, so a sparse track reads + * as short rather than broken. + */ +export function TrackInfoDialog({ track, artUrl, onClose, onEditTags }: Props) { + const caps = useCaps() + const [artFailed, setArtFailed] = useState(false) + const showArt = artUrl != null && !artFailed + + useEffect(() => { + const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose() + window.addEventListener('keydown', onKey) + return () => window.removeEventListener('keydown', onKey) + }, [onClose]) + + const grid = + track.grid_marker_count === 0 + ? null + : `${track.grid_marker_count > 1 ? `Flexible · ${track.grid_marker_count} markers` : 'Constant tempo'}${ + track.grid_locked ? ' · locked' : '' + }` + const details: [string, ReactNode][] = ( + [ + ['Album', track.album], + ['Label', track.label], + ['Genre', track.genre], + ['Remixer', track.remixer], + ['Producer', track.producer], + ['Mix', track.mix], + ['Released', track.release_date], + ['Added', track.import_date], + ['Last played', track.last_played], + ['Plays', track.playcount ? String(track.playcount) : null], + // The generic bitrate is bits per second. + ['Bitrate', track.bitrate ? `${Math.round(track.bitrate / 1000)} kbps` : null], + ['Grid', grid], + ['Hotcues', track.hotcue_count ? String(track.hotcue_count) : null], + ['Comment', track.comment], + ['Comment 2', track.comment2], + ] as [string, ReactNode][] + ).filter(([, v]) => v != null && v !== '') + + return createPortal( +
+
e.stopPropagation()} + > + {/* The sleeve, bled into the card behind everything: a soft wash of the + art's own colours. `filter` on this leaf is safe — nothing can open + inside it. */} + {showArt && ( + + )} + +
+
+ {showArt ? ( + {`Cover setArtFailed(true)} + /> + ) : ( +
+ +
+ )} +
+ {track.rating > 0 && } +
+ +
+
+
+
+

+ {track.title ?? 'Untitled'} +

+
{track.artist ?? 'Unknown artist'}
+
+ +
+ +
+ + + + {track.media_kind !== 'audio' && } +
+ + {details.length > 0 && ( +
+ {details.map(([label, value]) => ( +
+
{label}
+
{value}
+
+ ))} +
+ )} + + {track.filepath && ( +
+ {track.filepath} +
+ )} +
+ + {onEditTags && ( +
+ +
+ )} +
+
+
, + document.body, + ) +} + +function Stat({ label, value, color }: { label: string; value: string; color?: string }) { + return ( +
+ {label} + + {value} + +
+ ) +} diff --git a/frontend/src/index.css b/frontend/src/index.css index 77d4004..e5cb750 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -291,6 +291,18 @@ option { } } +/* ---- Track info popup (see TrackInfoDialog.tsx) ---------------------- */ +.track-info-pop { + animation: track-info-pop 220ms cubic-bezier(0.2, 0.9, 0.3, 1.15); +} +@keyframes track-info-pop { + from { opacity: 0; transform: translateY(8px) scale(0.96); } + to { opacity: 1; transform: none; } +} +@media (prefers-reduced-motion: reduce) { + .track-info-pop { animation: none; } +} + /* ---- Ambient backdrop (see AmbientBackdrop.tsx) ------------------------ */ .ambient-wash { position: absolute;