Implemented quick tag editing in library list

This commit is contained in:
Ben committed 2026-07-04 23:37:27 +02:00
1 parent aad1ec5bc0
commit c98b621f05
4 files changed
+191 -35

No files matched your search

+36 -7
View File
@@ -1,19 +1,48 @@
import { useState } from 'react'
interface Props {
value: number
/** When provided, the stars become clickable to set the rating (0–5). */
onChange?: (value: number) => void
}
// Compact 5-star rating. Filled stars use the gold accent; empties are faint.
export function RatingStars({ value }: Props) {
if (!value) return <span className="text-faint">—</span>
// Compact 5-star rating. Read-only by default (shows a dash when unrated). When
// `onChange` is given it's interactive: always shows five stars — hollow (☆) up
// to the rating, solid gold (★) below it — with hover preview. Clicking a star
// sets that rating; clicking the current top star again clears it to 0.
export function RatingStars({ value, onChange }: Props) {
const [hover, setHover] = useState(0)
if (!onChange) {
if (!value) return <span className="text-faint">—</span>
return (
<span className="whitespace-nowrap tracking-tight" title={`${value} / 5`}>
{[1, 2, 3, 4, 5].map((i) => (
<span key={i} className={i <= value ? 'text-gold' : 'text-ink-600'}>
{i <= value ? '★' : '☆'}
</span>
))}
</span>
)
}
const shown = hover || value
return (
<span className="whitespace-nowrap tracking-tight" title={`${value} / 5`}>
{[1, 2, 3, 4, 5].map((i) => (
<span
<button
key={i}
className={i <= value ? 'text-gold' : 'text-ink-600'}
onClick={(e) => {
e.stopPropagation()
onChange(i === value ? 0 : i)
}}
onMouseEnter={() => setHover(i)}
onMouseLeave={() => setHover(0)}
className={`transition-colors ${i <= shown ? 'text-gold' : 'text-ink-600 hover:text-gold/60'}`}
title={i === value ? 'Clear rating' : `Set ${i} star${i > 1 ? 's' : ''}`}
>
★
</span>
{i <= shown ? '★' : '☆'}
</button>
))}
</span>
)
+3
View File
@@ -48,6 +48,7 @@ interface Props {
selection?: Selection
onRowContextMenu?: (track: Track, x: number, y: number) => void
onPlay?: (track: Track) => void
onEditField?: (track: Track, field: keyof Track, value: string | number) => void
activeTrackId?: string | null
}
@@ -106,12 +107,14 @@ export function TrackTable({
selection,
onRowContextMenu,
onPlay,
onEditField,
activeTrackId,
}: Props) {
const table = useReactTable({
data: tracks,
columns: TRACK_COLUMNS,
state: { sorting, columnVisibility, columnOrder, columnSizing },
meta: { onEditField },
onSortingChange: (updater) =>
onSortingChange(typeof updater === 'function' ? updater(sorting) : updater),
onColumnSizingChange: (updater) =>