mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 18:22:53 +01:00
Implemented track info dialog popup
This commit is contained in:
1 parent
4c51f57fe9
commit
b70798a0fe
4 files changed
+234
-6
No files matched your search
@@ -1450,6 +1450,10 @@ export default function App() {
|
|||||||
origin={prepOrigin}
|
origin={prepOrigin}
|
||||||
cuesRefresh={cuesRefresh}
|
cuesRefresh={cuesRefresh}
|
||||||
onPlayingChange={setDeckPlaying}
|
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}
|
||||||
/>
|
/>
|
||||||
</CapabilitiesContext.Provider>
|
</CapabilitiesContext.Provider>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import { ScratchEngine } from '../lib/scratchEngine'
|
|||||||
import { PlaybackEngine } from '../lib/playbackEngine'
|
import { PlaybackEngine } from '../lib/playbackEngine'
|
||||||
import { invalidateTrackLists } from '../lib/trackQueries'
|
import { invalidateTrackLists } from '../lib/trackQueries'
|
||||||
import { AutoCueDialog, eventLabel } from './AutoCueDialog'
|
import { AutoCueDialog, eventLabel } from './AutoCueDialog'
|
||||||
|
import { TrackInfoDialog } from './TrackInfoDialog'
|
||||||
import { ContextMenu, type MenuItem } from './ContextMenu'
|
import { ContextMenu, type MenuItem } from './ContextMenu'
|
||||||
import { BpmReadout, GridEditStrip, TempoControls, TempoFold } from './GridControls'
|
import { BpmReadout, GridEditStrip, TempoControls, TempoFold } from './GridControls'
|
||||||
import { HotcueBar } from './HotcueBar'
|
import { HotcueBar } from './HotcueBar'
|
||||||
@@ -60,6 +61,9 @@ interface Props {
|
|||||||
cuesRefresh?: number
|
cuesRefresh?: number
|
||||||
/** Reports whether the deck is playing, so the library can light its row. */
|
/** Reports whether the deck is playing, so the library can light its row. */
|
||||||
onPlayingChange?: (playing: boolean) => void
|
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. */
|
/** m:ss.t — the deck's readouts show tenths, as a CDJ does. */
|
||||||
@@ -103,6 +107,7 @@ export function PrepStrip({
|
|||||||
origin = 'collection',
|
origin = 'collection',
|
||||||
cuesRefresh = 0,
|
cuesRefresh = 0,
|
||||||
onPlayingChange,
|
onPlayingChange,
|
||||||
|
onEditTags,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const qc = useQueryClient()
|
const qc = useQueryClient()
|
||||||
const [playing, setPlaying] = useState(false)
|
const [playing, setPlaying] = useState(false)
|
||||||
@@ -133,6 +138,7 @@ export function PrepStrip({
|
|||||||
const [snap, setSnap] = useState(true)
|
const [snap, setSnap] = useState(true)
|
||||||
const [selectedSlot, setSelectedSlot] = useState<number | null>(null)
|
const [selectedSlot, setSelectedSlot] = useState<number | null>(null)
|
||||||
const [cuePoint, setCuePoint] = useState(0) // floating "CUE" point (frontend-only)
|
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 [secPerView, setSecPerView] = useState(DEFAULT_SEC) // main-waveform zoom (persisted)
|
||||||
const [rawWave, setRawWave] = useState(false) // main waveform: raw line instead of bars (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).
|
// ONE size, in beats, for beat loops and beat jump alike (persisted).
|
||||||
@@ -1297,7 +1303,10 @@ export function PrepStrip({
|
|||||||
<div className="glass flex h-[19.75rem] shrink-0 flex-col gap-2 p-4">
|
<div className="glass flex h-[19.75rem] shrink-0 flex-col gap-2 p-4">
|
||||||
{/* ---- Header: the track, its readouts, the analysis actions ---- */}
|
{/* ---- Header: the track, its readouts, the analysis actions ---- */}
|
||||||
<div className="flex h-12 shrink-0 items-center gap-3">
|
<div className="flex h-12 shrink-0 items-center gap-3">
|
||||||
<CoverThumb trackId={track && origin === 'collection' ? track.id : null} />
|
<CoverThumb
|
||||||
|
trackId={track && origin === 'collection' ? track.id : null}
|
||||||
|
onOpen={track ? () => setInfoOpen(true) : undefined}
|
||||||
|
/>
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
{track ? (
|
{track ? (
|
||||||
<>
|
<>
|
||||||
@@ -1585,6 +1594,21 @@ export function PrepStrip({
|
|||||||
onClose={() => setPadMenu(null)}
|
onClose={() => setPadMenu(null)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{infoOpen && track && (
|
||||||
|
<TrackInfoDialog
|
||||||
|
track={track}
|
||||||
|
artUrl={origin === 'collection' ? api.artUrl(track.id) : null}
|
||||||
|
onClose={() => setInfoOpen(false)}
|
||||||
|
onEditTags={
|
||||||
|
onEditTags
|
||||||
|
? () => {
|
||||||
|
setInfoOpen(false)
|
||||||
|
onEditTags(track)
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{autoOpen && track && (
|
{autoOpen && track && (
|
||||||
<AutoCueDialog
|
<AutoCueDialog
|
||||||
track={track}
|
track={track}
|
||||||
@@ -1603,14 +1627,19 @@ export function PrepStrip({
|
|||||||
/**
|
/**
|
||||||
* The loaded track's sleeve. Until it loads — and for a track with no art — a
|
* The loaded track's sleeve. Until it loads — and for a track with no art — a
|
||||||
* swatch of the ambient colours stands in, so the header never has a hole in it.
|
* swatch of the ambient colours stands in, so the header never has a hole in it.
|
||||||
|
* With a track loaded it is a button that opens the track-info popup.
|
||||||
*/
|
*/
|
||||||
function CoverThumb({ trackId }: { trackId: string | null }) {
|
function CoverThumb({ trackId, onOpen }: { trackId: string | null; onOpen?: () => void }) {
|
||||||
const [failed, setFailed] = useState<string | null>(null)
|
const [failed, setFailed] = useState<string | null>(null)
|
||||||
const showArt = trackId != null && failed !== trackId
|
const showArt = trackId != null && failed !== trackId
|
||||||
return (
|
return (
|
||||||
<div
|
<button
|
||||||
aria-hidden
|
type="button"
|
||||||
className="relative h-11 w-11 shrink-0 overflow-hidden rounded-xl shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_8px_24px_-6px_var(--amb-2)]"
|
onClick={onOpen}
|
||||||
|
disabled={!onOpen}
|
||||||
|
title={onOpen ? 'Track info' : undefined}
|
||||||
|
aria-label="Track info"
|
||||||
|
className="relative h-11 w-11 shrink-0 overflow-hidden rounded-xl shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_8px_24px_-6px_var(--amb-2)] transition-transform enabled:cursor-zoom-in enabled:hover:scale-105 enabled:active:scale-95 disabled:cursor-default"
|
||||||
style={{ background: 'linear-gradient(135deg, var(--amb-1), var(--amb-2) 55%, var(--amb-3))' }}
|
style={{ background: 'linear-gradient(135deg, var(--amb-1), var(--amb-2) 55%, var(--amb-3))' }}
|
||||||
>
|
>
|
||||||
{showArt && (
|
{showArt && (
|
||||||
@@ -1622,6 +1651,6 @@ function CoverThumb({ trackId }: { trackId: string | null }) {
|
|||||||
onError={() => setFailed(trackId)}
|
onError={() => setFailed(trackId)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -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(
|
||||||
|
<div
|
||||||
|
aria-modal="true"
|
||||||
|
role="dialog"
|
||||||
|
aria-label={track.title ?? 'Track info'}
|
||||||
|
className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4 backdrop-blur-[3px]"
|
||||||
|
onClick={onClose}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="track-info-pop glass-overlay flex max-h-[90vh] w-full max-w-[860px] flex-col overflow-hidden sm:flex-row"
|
||||||
|
onClick={(e) => 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 && (
|
||||||
|
<img
|
||||||
|
aria-hidden
|
||||||
|
src={artUrl}
|
||||||
|
alt=""
|
||||||
|
// Between the tint (::after, z -1, earlier) and the rim (::before).
|
||||||
|
style={{ zIndex: -1 }}
|
||||||
|
className="pointer-events-none absolute inset-0 h-full w-full scale-125 object-cover opacity-30 blur-3xl saturate-150"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="relative flex shrink-0 flex-col items-center gap-4 p-6 sm:pr-3">
|
||||||
|
<div
|
||||||
|
className="relative aspect-square w-[min(340px,70vw)] overflow-hidden rounded-2xl shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_24px_60px_-12px_var(--amb-2)]"
|
||||||
|
style={{ background: 'linear-gradient(135deg, var(--amb-1), var(--amb-2) 55%, var(--amb-3))' }}
|
||||||
|
>
|
||||||
|
{showArt ? (
|
||||||
|
<img
|
||||||
|
src={artUrl}
|
||||||
|
alt={`Cover of ${track.title ?? 'this track'}`}
|
||||||
|
className="absolute inset-0 h-full w-full object-cover"
|
||||||
|
onError={() => setArtFailed(true)}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="absolute inset-0 flex items-center justify-center text-white/40">
|
||||||
|
<Icon name="music" size={72} strokeWidth={1.2} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{track.rating > 0 && <RatingStars value={track.rating} max={caps.tracks.rating_max} />}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="relative flex min-h-0 min-w-0 flex-1 flex-col">
|
||||||
|
<div className="min-h-0 flex-1 overflow-y-auto p-6 sm:pl-3">
|
||||||
|
<div className="flex items-start gap-3">
|
||||||
|
<div className="min-w-0 flex-1">
|
||||||
|
<h2 className="text-2xl font-semibold leading-tight tracking-tight text-text select-text">
|
||||||
|
{track.title ?? 'Untitled'}
|
||||||
|
</h2>
|
||||||
|
<div className="mt-1 text-[15px] text-muted select-text">{track.artist ?? 'Unknown artist'}</div>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={onClose}
|
||||||
|
aria-label="Close"
|
||||||
|
className="btn-glass -mr-2 -mt-2 flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-muted hover:text-text"
|
||||||
|
>
|
||||||
|
<Icon name="close" size={14} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-5 flex flex-wrap gap-2">
|
||||||
|
<Stat label="KEY" value={track.key || '—'} color={keyColor(track.key_wheel)} />
|
||||||
|
<Stat label="BPM" value={formatBpm(track.bpm)} />
|
||||||
|
<Stat label="LENGTH" value={formatDuration(track.length)} />
|
||||||
|
{track.media_kind !== 'audio' && <Stat label="TYPE" value={track.media_kind.toUpperCase()} />}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{details.length > 0 && (
|
||||||
|
<dl className="mt-5 grid grid-cols-[auto_1fr] gap-x-5 gap-y-1.5 border-t border-line pt-4 text-[13px]">
|
||||||
|
{details.map(([label, value]) => (
|
||||||
|
<div key={label} className="contents">
|
||||||
|
<dt className="text-faint">{label}</dt>
|
||||||
|
<dd className="min-w-0 whitespace-pre-wrap break-words text-text select-text">{value}</dd>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</dl>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{track.filepath && (
|
||||||
|
<div
|
||||||
|
className="well mt-5 rounded-xl px-3 py-2 font-mono text-[11px] leading-relaxed text-muted break-all select-text"
|
||||||
|
title={track.filepath}
|
||||||
|
>
|
||||||
|
{track.filepath}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{onEditTags && (
|
||||||
|
<div className="flex justify-end px-6 pb-6 sm:pl-3">
|
||||||
|
<button
|
||||||
|
onClick={onEditTags}
|
||||||
|
className="btn-glass flex h-9 items-center gap-2 rounded-full px-4 text-[13px] font-medium"
|
||||||
|
>
|
||||||
|
<Icon name="pencil" size={15} />
|
||||||
|
Edit Tags…
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>,
|
||||||
|
document.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Stat({ label, value, color }: { label: string; value: string; color?: string }) {
|
||||||
|
return (
|
||||||
|
<div className="well flex flex-col gap-px rounded-xl px-4 py-2">
|
||||||
|
<span className="text-[10px] tracking-[0.08em] text-faint">{label}</span>
|
||||||
|
<span className="font-mono text-[17px] font-semibold" style={{ color }}>
|
||||||
|
{value}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -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 backdrop (see AmbientBackdrop.tsx) ------------------------ */
|
||||||
.ambient-wash {
|
.ambient-wash {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
Reference in new issue
Block a user