mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 18:22:53 +01:00
Improved play buttons in list
This commit is contained in:
1 parent
bd35418a89
commit
a6f96d5943
3 files changed
+32
-7
No files matched your search
@@ -66,6 +66,7 @@ export default function App() {
|
||||
const [showPaths, setShowPaths] = useState(false)
|
||||
const [showHistory, setShowHistory] = useState(false)
|
||||
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
|
||||
// playlist while a device or folder track is loaded must not switch the deck
|
||||
// to endpoints that do not know that track.
|
||||
@@ -1019,6 +1020,7 @@ export default function App() {
|
||||
onNotify={notify}
|
||||
origin={prepOrigin}
|
||||
cuesRefresh={cuesRefresh}
|
||||
onPlayingChange={setDeckPlaying}
|
||||
/>
|
||||
</CapabilitiesContext.Provider>
|
||||
|
||||
@@ -1177,6 +1179,7 @@ export default function App() {
|
||||
onPlay={playTrack}
|
||||
onEditField={canEdit ? editField : undefined}
|
||||
activeTrackId={prepTrack?.id ?? null}
|
||||
activePlaying={deckPlaying}
|
||||
columnVisibility={columnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
columnSizing={columnSizing}
|
||||
@@ -1215,6 +1218,7 @@ export default function App() {
|
||||
onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })}
|
||||
onPlay={playTrack}
|
||||
activeTrackId={prepTrack?.id ?? null}
|
||||
activePlaying={deckPlaying}
|
||||
columnVisibility={columnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
columnSizing={columnSizing}
|
||||
@@ -1248,6 +1252,7 @@ export default function App() {
|
||||
onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })}
|
||||
onPlay={playTrack}
|
||||
activeTrackId={prepTrack?.id ?? null}
|
||||
activePlaying={deckPlaying}
|
||||
columnVisibility={columnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
columnSizing={columnSizing}
|
||||
@@ -1272,6 +1277,7 @@ export default function App() {
|
||||
onPlay={playTrack}
|
||||
onEditField={canEdit ? editField : undefined}
|
||||
activeTrackId={prepTrack?.id ?? null}
|
||||
activePlaying={deckPlaying}
|
||||
columnVisibility={columnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
columnSizing={columnSizing}
|
||||
@@ -1309,6 +1315,7 @@ export default function App() {
|
||||
onPlay={playTrack}
|
||||
onEditField={canEdit ? editField : undefined}
|
||||
activeTrackId={prepTrack?.id ?? null}
|
||||
activePlaying={deckPlaying}
|
||||
columnVisibility={columnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
columnSizing={columnSizing}
|
||||
|
||||
@@ -50,6 +50,8 @@ interface Props {
|
||||
/** Bumped when something outside the deck (batch grid analysis) rewrote the
|
||||
* loaded track's cues/grid, so the deck re-reads them. */
|
||||
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. */
|
||||
@@ -92,9 +94,11 @@ export function PrepStrip({
|
||||
onNotify,
|
||||
origin = 'collection',
|
||||
cuesRefresh = 0,
|
||||
onPlayingChange,
|
||||
}: Props) {
|
||||
const qc = useQueryClient()
|
||||
const [playing, setPlaying] = useState(false)
|
||||
useEffect(() => onPlayingChange?.(playing), [playing, onPlayingChange])
|
||||
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,
|
||||
// which the pointer's :active alone cannot, since the key never touches it.
|
||||
|
||||
@@ -79,31 +79,39 @@ interface Props {
|
||||
onPlay?: (track: Track) => void
|
||||
onEditField?: (track: Track, field: keyof Track, value: string | number) => void
|
||||
activeTrackId?: string | null
|
||||
/** Whether the deck is playing `activeTrackId` (vs. loaded but paused). */
|
||||
activePlaying?: boolean
|
||||
}
|
||||
|
||||
/** The per-row play button.
|
||||
* Fades in on row hover; stays lit for the active deck track. */
|
||||
/** The per-row play button, in three states: a small triangle always, an
|
||||
* 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({
|
||||
track,
|
||||
isActive,
|
||||
isPlaying,
|
||||
onPlay,
|
||||
}: {
|
||||
track: Track
|
||||
isActive: boolean
|
||||
isPlaying: boolean
|
||||
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 (
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onPlay(track)
|
||||
}}
|
||||
className={`flex h-6 w-6 items-center justify-center rounded-full transition-colors hover:bg-accent hover:text-ink-950 ${
|
||||
isActive ? 'text-accent opacity-100' : 'text-faint opacity-0 group-hover:opacity-100'
|
||||
}`}
|
||||
className={`flex h-6 w-6 items-center justify-center rounded-full border-[1.5px] transition-colors ${look}`}
|
||||
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" />
|
||||
</svg>
|
||||
</button>
|
||||
@@ -275,6 +283,7 @@ export function TrackTable({
|
||||
onPlay,
|
||||
onEditField,
|
||||
activeTrackId,
|
||||
activePlaying = false,
|
||||
}: Props) {
|
||||
// A local copy so a reorder shows instantly; re-syncs when the data changes.
|
||||
const [data, setData] = useState<Track[]>(tracks)
|
||||
@@ -599,7 +608,12 @@ export function TrackTable({
|
||||
</span>
|
||||
{hasPlay && (
|
||||
<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>
|
||||
)}
|
||||
<RowCells row={row} />
|
||||
|
||||
Reference in new issue
Block a user