Improved play buttons in list

This commit is contained in:
patben8 committed 2026-09-28 22:15:36 +02:00
1 parent bd35418a89
commit a6f96d5943
3 files changed
+32 -7

No files matched your search

+7
View File
@@ -66,6 +66,7 @@ export default function App() {
const [showPaths, setShowPaths] = useState(false) const [showPaths, setShowPaths] = useState(false)
const [showHistory, setShowHistory] = useState(false) const [showHistory, setShowHistory] = useState(false)
const [prepTrack, setPrepTrack] = useState<Track | null>(null) const [prepTrack, setPrepTrack] = useState<Track | null>(null)
const [deckPlaying, setDeckPlaying] = useState(false)
// Which library the DECK's track came from — not the view's. Browsing to a // Which library the DECK's track came from — not the view's. Browsing to a
// playlist while a device or folder track is loaded must not switch the deck // playlist while a device or folder track is loaded must not switch the deck
// to endpoints that do not know that track. // to endpoints that do not know that track.
@@ -1019,6 +1020,7 @@ export default function App() {
onNotify={notify} onNotify={notify}
origin={prepOrigin} origin={prepOrigin}
cuesRefresh={cuesRefresh} cuesRefresh={cuesRefresh}
onPlayingChange={setDeckPlaying}
/> />
</CapabilitiesContext.Provider> </CapabilitiesContext.Provider>
@@ -1177,6 +1179,7 @@ export default function App() {
onPlay={playTrack} onPlay={playTrack}
onEditField={canEdit ? editField : undefined} onEditField={canEdit ? editField : undefined}
activeTrackId={prepTrack?.id ?? null} activeTrackId={prepTrack?.id ?? null}
activePlaying={deckPlaying}
columnVisibility={columnVisibility} columnVisibility={columnVisibility}
columnOrder={columnOrder} columnOrder={columnOrder}
columnSizing={columnSizing} columnSizing={columnSizing}
@@ -1215,6 +1218,7 @@ export default function App() {
onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })} onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })}
onPlay={playTrack} onPlay={playTrack}
activeTrackId={prepTrack?.id ?? null} activeTrackId={prepTrack?.id ?? null}
activePlaying={deckPlaying}
columnVisibility={columnVisibility} columnVisibility={columnVisibility}
columnOrder={columnOrder} columnOrder={columnOrder}
columnSizing={columnSizing} columnSizing={columnSizing}
@@ -1248,6 +1252,7 @@ export default function App() {
onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })} onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })}
onPlay={playTrack} onPlay={playTrack}
activeTrackId={prepTrack?.id ?? null} activeTrackId={prepTrack?.id ?? null}
activePlaying={deckPlaying}
columnVisibility={columnVisibility} columnVisibility={columnVisibility}
columnOrder={columnOrder} columnOrder={columnOrder}
columnSizing={columnSizing} columnSizing={columnSizing}
@@ -1272,6 +1277,7 @@ export default function App() {
onPlay={playTrack} onPlay={playTrack}
onEditField={canEdit ? editField : undefined} onEditField={canEdit ? editField : undefined}
activeTrackId={prepTrack?.id ?? null} activeTrackId={prepTrack?.id ?? null}
activePlaying={deckPlaying}
columnVisibility={columnVisibility} columnVisibility={columnVisibility}
columnOrder={columnOrder} columnOrder={columnOrder}
columnSizing={columnSizing} columnSizing={columnSizing}
@@ -1309,6 +1315,7 @@ export default function App() {
onPlay={playTrack} onPlay={playTrack}
onEditField={canEdit ? editField : undefined} onEditField={canEdit ? editField : undefined}
activeTrackId={prepTrack?.id ?? null} activeTrackId={prepTrack?.id ?? null}
activePlaying={deckPlaying}
columnVisibility={columnVisibility} columnVisibility={columnVisibility}
columnOrder={columnOrder} columnOrder={columnOrder}
columnSizing={columnSizing} columnSizing={columnSizing}
+4
View File
@@ -50,6 +50,8 @@ interface Props {
/** Bumped when something outside the deck (batch grid analysis) rewrote the /** Bumped when something outside the deck (batch grid analysis) rewrote the
* loaded track's cues/grid, so the deck re-reads them. */ * loaded track's cues/grid, so the deck re-reads them. */
cuesRefresh?: number cuesRefresh?: number
/** Reports whether the deck is playing, so the library can light its row. */
onPlayingChange?: (playing: boolean) => 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. */
@@ -92,9 +94,11 @@ export function PrepStrip({
onNotify, onNotify,
origin = 'collection', origin = 'collection',
cuesRefresh = 0, cuesRefresh = 0,
onPlayingChange,
}: Props) { }: Props) {
const qc = useQueryClient() const qc = useQueryClient()
const [playing, setPlaying] = useState(false) const [playing, setPlaying] = useState(false)
useEffect(() => onPlayingChange?.(playing), [playing, onPlayingChange])
const [previewing, setPreviewing] = useState(false) // momentary hold-to-play active const [previewing, setPreviewing] = useState(false) // momentary hold-to-play active
// CUE is held down (mouse OR the C key) — drives the button's pressed look, // CUE is held down (mouse OR the C key) — drives the button's pressed look,
// which the pointer's :active alone cannot, since the key never touches it. // which the pointer's :active alone cannot, since the key never touches it.
+21 -7
View File
@@ -79,31 +79,39 @@ interface Props {
onPlay?: (track: Track) => void onPlay?: (track: Track) => void
onEditField?: (track: Track, field: keyof Track, value: string | number) => void onEditField?: (track: Track, field: keyof Track, value: string | number) => void
activeTrackId?: string | null activeTrackId?: string | null
/** Whether the deck is playing `activeTrackId` (vs. loaded but paused). */
activePlaying?: boolean
} }
/** The per-row play button. /** The per-row play button, in three states: a small triangle always, an
* Fades in on row hover; stays lit for the active deck track. */ * outlined circle on row hover, and a filled circle while its track plays in
* the deck (the loaded track, paused, keeps an accent triangle). */
function PlayButton({ function PlayButton({
track, track,
isActive, isActive,
isPlaying,
onPlay, onPlay,
}: { }: {
track: Track track: Track
isActive: boolean isActive: boolean
isPlaying: boolean
onPlay: (track: Track) => void onPlay: (track: Track) => void
}) { }) {
const look = isPlaying
? 'border-accent bg-accent text-ink-950'
: `border-transparent group-hover:border-ink-600 hover:!border-accent hover:text-accent ${
isActive ? 'text-accent' : 'text-faint group-hover:text-text'
}`
return ( return (
<button <button
onClick={(e) => { onClick={(e) => {
e.stopPropagation() e.stopPropagation()
onPlay(track) onPlay(track)
}} }}
className={`flex h-6 w-6 items-center justify-center rounded-full transition-colors hover:bg-accent hover:text-ink-950 ${ className={`flex h-6 w-6 items-center justify-center rounded-full border-[1.5px] transition-colors ${look}`}
isActive ? 'text-accent opacity-100' : 'text-faint opacity-0 group-hover:opacity-100'
}`}
title="Play in deck" title="Play in deck"
> >
<svg width="11" height="11" viewBox="0 0 24 24" fill="currentColor" aria-hidden> <svg width="11" height="11" viewBox="0 0 24 24" fill="currentColor" aria-hidden className="ml-px">
<path d="M8 5.14v13.72a1 1 0 0 0 1.54.84l10.29-6.86a1 1 0 0 0 0-1.68L9.54 4.3A1 1 0 0 0 8 5.14z" /> <path d="M8 5.14v13.72a1 1 0 0 0 1.54.84l10.29-6.86a1 1 0 0 0 0-1.68L9.54 4.3A1 1 0 0 0 8 5.14z" />
</svg> </svg>
</button> </button>
@@ -275,6 +283,7 @@ export function TrackTable({
onPlay, onPlay,
onEditField, onEditField,
activeTrackId, activeTrackId,
activePlaying = false,
}: Props) { }: Props) {
// A local copy so a reorder shows instantly; re-syncs when the data changes. // A local copy so a reorder shows instantly; re-syncs when the data changes.
const [data, setData] = useState<Track[]>(tracks) const [data, setData] = useState<Track[]>(tracks)
@@ -599,7 +608,12 @@ export function TrackTable({
</span> </span>
{hasPlay && ( {hasPlay && (
<span className="flex w-9 shrink-0 items-center justify-center"> <span className="flex w-9 shrink-0 items-center justify-center">
{onPlay && <PlayButton track={row.original} isActive={isActive} onPlay={onPlay} />} {onPlay && <PlayButton
track={row.original}
isActive={isActive}
isPlaying={isActive && activePlaying}
onPlay={onPlay}
/>}
</span> </span>
)} )}
<RowCells row={row} /> <RowCells row={row} />