Added extensive add to in context menu

This commit is contained in:
patben8 committed 2026-09-25 10:32:01 +02:00
1 parent 07e85cfdc9
commit 5909c704f4
6 files changed
+167 -167

No files matched your search

+5 -4
View File
@@ -353,7 +353,8 @@ Two independent apps that talk over HTTP:
slot, a per-slot Replace tick for occupied slots — never remembered, since slot, a per-slot Replace tick for occupied slots — never remembered, since
overwriting is a decision about THIS track — and the template itself overwriting is a decision about THIS track — and the template itself
persisted as `autoCueTemplate` in userprefs), persisted as `autoCueTemplate` in userprefs),
`SelectionBar` (bulk add-to-playlist), `ContextMenu` + `EditTagsDialog` `ContextMenu` (supports `▸` submenus and section headings; "Add to" lists
playlists + exports and acts on the whole selection) + `EditTagsDialog`
(right-click → multi-field metadata + album-art edit), `StatusBar`, (right-click → multi-field metadata + album-art edit), `StatusBar`,
`RatingStars` (read-only, or click-to-set when given `onChange`), `Toast`, `RatingStars` (read-only, or click-to-set when given `onChange`), `Toast`,
`UpdateDialog` (`UpdateCheck`, mounted in `main.tsx` beside `App` so it shows `UpdateDialog` (`UpdateCheck`, mounted in `main.tsx` beside `App` so it shows
@@ -394,7 +395,7 @@ Two independent apps that talk over HTTP:
the digit shortcuts all read `cues.hotcue_slots`), the cue-type dropdown the digit shortcuts all read `cues.hotcue_slots`), the cue-type dropdown
(`cues.types`), the rating scale (`tracks.rating_max`), the grid Lock button (`cues.types`), the rating scale (`tracks.rating_max`), the grid Lock button
(`grid.lockable`). Per-node playlist flags (`can_rename`, `can_delete`, (`grid.lockable`). Per-node playlist flags (`can_rename`, `can_delete`,
`can_add_tracks`) gate the sidebar and `SelectionBar` — each on its OWN flag, `can_add_tracks`) gate the sidebar and the context menu's "Add to" — each on its OWN flag,
since a platform may allow renaming but not deleting. Carried but deliberately unused until a second adapter since a platform may allow renaming but not deleting. Carried but deliberately unused until a second adapter
exists: `slot_labels: 'letter'`, `palette`, `loops: 'separate_bank'`, and exists: `slot_labels: 'letter'`, `palette`, `loops: 'separate_bank'`, and
memory-cue *editing* (one-platform features stay preserved-but-uneditable). memory-cue *editing* (one-platform features stay preserved-but-uneditable).
@@ -790,8 +791,8 @@ that number and nothing else — everything derives from it:
tests. Exporters declare **static** capabilities: no instance, no path, because tests. Exporters declare **static** capabilities: no instance, no path, because
the library being described does not exist yet. the library being described does not exist yet.
**Steps 1–3 done**: `library_id.py`; `exports.py` + 10 routes + `api.ts`; and **Steps 1–3 done**: `library_id.py`; `exports.py` + 10 routes + `api.ts`; and
the UI (`ExportsSection`, `ExportDialog`, export views in `App`, "Add to…" on the UI (`ExportsSection`, `ExportDialog`, export views in `App`, "Add to" on
`SelectionBar`, the track context menu and each sidebar playlist row). the track context menu and each sidebar playlist row).
Next: `core/exporter.py` + the Traktor writer, and the export run itself on top Next: `core/exporter.py` + the Traktor writer, and the export run itself on top
of `jobs.py` and `importer.py`'s copy machinery — **there is no Export button of `jobs.py` and `importer.py`'s copy machinery — **there is no Export button
yet**, since nothing can be written. Note the OneLibrary work already demonstrated yet**, since nothing can be written. Note the OneLibrary work already demonstrated
+55 -23
View File
@@ -3,7 +3,7 @@ import { useQuery, useQueryClient } from '@tanstack/react-query'
import type { ColumnSizingState, SortingState, VisibilityState } from '@tanstack/react-table' import type { ColumnSizingState, SortingState, VisibilityState } from '@tanstack/react-table'
import { CapabilitiesContext } from './lib/capabilities' import { CapabilitiesContext } from './lib/capabilities'
import { writeHint } from './lib/platformCopy' import { writeHint } from './lib/platformCopy'
import { api, type Track } from './api' import { api, type PlaylistNode, type Track } from './api'
import { import {
DEFAULT_COLUMN_ORDER, DEFAULT_COLUMN_ORDER,
DEFAULT_COLUMN_VISIBILITY, DEFAULT_COLUMN_VISIBILITY,
@@ -11,11 +11,10 @@ import {
import { Sidebar, type Source } from './components/Sidebar' import { Sidebar, type Source } from './components/Sidebar'
import { Toolbar, emptyFilters, type Filters } from './components/Toolbar' import { Toolbar, emptyFilters, type Filters } from './components/Toolbar'
import { TrackTable, PlaylistTable } from './components/TrackTable' import { TrackTable, PlaylistTable } from './components/TrackTable'
import { SelectionBar } from './components/SelectionBar'
import { StatusBar } from './components/StatusBar' import { StatusBar } from './components/StatusBar'
import { Toast, type ToastMsg } from './components/Toast' import { Toast, type ToastMsg } from './components/Toast'
import { CollectionPicker } from './components/CollectionPicker' import { CollectionPicker } from './components/CollectionPicker'
import { ContextMenu } from './components/ContextMenu' import { ContextMenu, type MenuItem } from './components/ContextMenu'
import { EditTagsDialog } from './components/EditTagsDialog' import { EditTagsDialog } from './components/EditTagsDialog'
import { PathMappingDialog } from './components/PathMappingDialog' import { PathMappingDialog } from './components/PathMappingDialog'
import { HistoryPanel } from './components/HistoryPanel' import { HistoryPanel } from './components/HistoryPanel'
@@ -236,6 +235,15 @@ export default function App() {
}) })
const openDevice = useQuery({ queryKey: ['source'], queryFn: api.source }) const openDevice = useQuery({ queryKey: ['source'], queryFn: api.source })
const exportSets = useQuery({ queryKey: ['exports'], queryFn: api.exports, enabled: loaded }) const exportSets = useQuery({ queryKey: ['exports'], queryFn: api.exports, enabled: loaded })
const playlists = useQuery({ queryKey: ['playlists'], queryFn: api.playlists, enabled: loaded })
// Every playlist the context menu's "Add to" can target, flattened out of
// folders. Each node carries its own `can_add_tracks`, so a read-only library
// simply offers none.
const addablePlaylists = useMemo(() => {
const walk = (nodes: PlaylistNode[]): PlaylistNode[] =>
nodes.flatMap((n) => [...(n.can_add_tracks ? [n] : []), ...walk(n.children)])
return walk(playlists.data ?? [])
}, [playlists.data])
// Export membership. Both are no-ops on the library itself, so neither dirties // Export membership. Both are no-ops on the library itself, so neither dirties
// it nor touches version history — an export set is Konduktor's own data. // it nor touches version history — an export set is Konduktor's own data.
@@ -260,6 +268,21 @@ export default function App() {
}, },
[refreshExport, exportSets.data, notify, onError], [refreshExport, exportSets.data, notify, onError],
) )
const addToPlaylist = useCallback(
async (uuid: string, ids: string[]) => {
try {
const res = await api.addEntries(uuid, ids)
qc.invalidateQueries({ queryKey: ['state'] })
qc.invalidateQueries({ queryKey: ['playlists'] })
qc.invalidateQueries({ queryKey: ['playlist', uuid] })
const name = addablePlaylists.find((p) => p.id === uuid)?.name ?? 'playlist'
notify('success', `Added ${res.added} track${res.added === 1 ? '' : 's'} to ${name}`)
} catch (e) {
onError((e as Error).message)
}
},
[qc, addablePlaylists, notify, onError],
)
const removeFromExport = useCallback( const removeFromExport = useCallback(
async (id: string, ids: string[]) => { async (id: string, ids: string[]) => {
try { try {
@@ -407,6 +430,28 @@ export default function App() {
y, y,
}) })
// The "Add to" submenu. Exports are listed even on a read-only library:
// adding to one touches no library data — an export is Konduktor's own
// curation. The playlist being viewed is left out; adding a track to the
// playlist it came from would only duplicate it.
const addToItems = (ids: string[]): MenuItem[] => {
const lists = addablePlaylists.filter((p) => !(source.kind === 'playlist' && p.id === source.id))
return [
{ heading: 'Playlists', empty: lists.length ? undefined : 'No playlists' },
...lists.map((p) => ({
label: p.name,
hint: String(p.count),
onClick: () => addToPlaylist(p.id, ids),
})),
{ heading: 'Exports', empty: exportSets.data?.length ? undefined : 'No exports yet' },
...(exportSets.data ?? []).map((set) => ({
label: set.name,
icon: '◈',
onClick: () => addToExport(set.id, ids),
})),
]
}
return ( return (
<CapabilitiesContext.Provider value={capabilities.data!}> <CapabilitiesContext.Provider value={capabilities.data!}>
<div className="flex h-screen w-screen flex-col overflow-hidden bg-ink-950"> <div className="flex h-screen w-screen flex-col overflow-hidden bg-ink-950">
@@ -428,12 +473,9 @@ export default function App() {
...(canEdit && menu.ids.length === 1 ...(canEdit && menu.ids.length === 1
? [{ label: 'Edit Tags…', onClick: () => setEditing(menu.track) }] ? [{ label: 'Edit Tags…', onClick: () => setEditing(menu.track) }]
: []), : []),
// Adding to an export touches no library data, so it is offered even // A device's track ids belong to the stick, not the collection, so
// on a read-only one — an export is Konduktor's own curation. // there is nothing they could be added to.
...(exportSets.data ?? []).map((set) => ({ ...(viewingDevice ? [] : [{ label: 'Add to', submenu: addToItems(menu.ids) }]),
label: `Add to “${set.name}”`,
onClick: () => addToExport(set.id, menu.ids),
})),
// Only on the export's ROOT view. Inside a referenced playlist there // Only on the export's ROOT view. Inside a referenced playlist there
// is nothing to remove: the reference is live, and per-track removal // is nothing to remove: the reference is live, and per-track removal
// would need an exclusion list — hidden state deciding what a future // would need an exclusion list — hidden state deciding what a future
@@ -588,7 +630,7 @@ export default function App() {
table's × removes a track from the user's REAL playlist — same table's × removes a track from the user's REAL playlist — same
pixels, opposite meaning — and an export's own removal is offered pixels, opposite meaning — and an export's own removal is offered
through the context menu instead, on its root view only. through the context menu instead, on its root view only.
Selection stays on, so "Add to…" works from inside an export. */ Selection stays on, so right-click → Add to works from inside an export. */
filtered.length === 0 ? ( filtered.length === 0 ? (
<div className="flex h-full flex-col items-center justify-center gap-2 text-muted"> <div className="flex h-full flex-col items-center justify-center gap-2 text-muted">
<div className="text-lg"> <div className="text-lg">
@@ -596,7 +638,7 @@ export default function App() {
</div> </div>
<div className="text-sm text-faint"> <div className="text-sm text-faint">
{tracks.length === 0 {tracks.length === 0
? 'Select tracks in All Tracks and use “Add to…”, or add a whole playlist.' ? 'Right-click tracks in All Tracks and choose Add to, or add a whole playlist.'
: 'Try clearing some filters.'} : 'Try clearing some filters.'}
</div> </div>
</div> </div>
@@ -621,7 +663,7 @@ export default function App() {
/* A device uses the plain table, not the playlist one: a stick's /* A device uses the plain table, not the playlist one: a stick's
playlists cannot be reordered or have entries removed, so the playlists cannot be reordered or have entries removed, so the
drag handle and the × would exist only to be inert. Selection is drag handle and the × would exist only to be inert. Selection is
omitted for the same reason — SelectionBar adds to the loaded omitted too: its bulk action, "Add to", targets the loaded
COLLECTION's playlists, and these ids belong to the device. */ COLLECTION's playlists, and these ids belong to the device. */
filtered.length === 0 ? ( filtered.length === 0 ? (
<div className="flex h-full flex-col items-center justify-center gap-1 text-muted"> <div className="flex h-full flex-col items-center justify-center gap-1 text-muted">
@@ -702,23 +744,13 @@ export default function App() {
/> />
)} )}
{/* Also inside an export: its rows ARE collection tracks, so "Add
to…" means the same thing there as in All Tracks. */}
{(isAll || viewingExport) && (
<SelectionBar
count={selected.size}
trackIds={[...selected]}
onClear={() => setSelected(new Set())}
onDone={(msg) => notify('success', msg)}
onError={onError}
/>
)}
</div> </div>
<StatusBar <StatusBar
showing={filtered.length} showing={filtered.length}
total={tracks.length} total={tracks.length}
sourceName={viewName} sourceName={viewName}
selected={isAll || viewingExport ? selected.size : 0}
loading={loading} loading={loading}
collectionName={capabilities.data ? libraryName : null} collectionName={capabilities.data ? libraryName : null}
onChangeCollection={() => setForcePicker(true)} onChangeCollection={() => setForcePicker(true)}
+97 -16
View File
@@ -1,10 +1,10 @@
import { useEffect, useRef } from 'react' import { useEffect, useRef, useState } from 'react'
export interface MenuItem { /** One row of a menu: an action, a submenu (`label ▸`), or a section heading. */
label: string export type MenuItem =
onClick: () => void | { label: string; onClick: () => void; danger?: boolean; hint?: string; icon?: string }
danger?: boolean | { label: string; submenu: MenuItem[] }
} | { heading: string; empty?: string }
interface Props { interface Props {
x: number x: number
@@ -13,8 +13,12 @@ interface Props {
onClose: () => void onClose: () => void
} }
const SUBMENU_WIDTH = 240
const SUBMENU_MAX_HEIGHT = 288
// Lightweight fixed-position menu. Closes on outside click, scroll, or Escape. // Lightweight fixed-position menu. Closes on outside click, scroll, or Escape.
export function ContextMenu({ x, y, items, onClose }: Props) { export function ContextMenu({ x, y, items, onClose }: Props) {
const rootRef = useRef<HTMLDivElement>(null)
// Read through a ref so the listeners are attached ONCE. Callers pass an // Read through a ref so the listeners are attached ONCE. Callers pass an
// inline `onClose`; if the effect depended on it, a click that re-renders the // inline `onClose`; if the effect depended on it, a click that re-renders the
// parent (e.g. selecting a row) would detach the listeners before the // parent (e.g. selecting a row) would detach the listeners before the
@@ -23,47 +27,124 @@ export function ContextMenu({ x, y, items, onClose }: Props) {
onCloseRef.current = onClose onCloseRef.current = onClose
useEffect(() => { useEffect(() => {
const close = () => onCloseRef.current() const close = () => onCloseRef.current()
// Scrolling a long submenu must not dismiss the menu it belongs to.
const onScroll = (e: Event) => {
if (e.target instanceof Node && rootRef.current?.contains(e.target)) return
close()
}
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onCloseRef.current() const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onCloseRef.current()
// Defer attaching outside-dismiss listeners by a tick so the very // Defer attaching outside-dismiss listeners by a tick so the very
// right-click/click that opened the menu can't immediately close it. // right-click/click that opened the menu can't immediately close it.
const id = setTimeout(() => { const id = setTimeout(() => {
window.addEventListener('click', close) window.addEventListener('click', close)
window.addEventListener('contextmenu', close) window.addEventListener('contextmenu', close)
window.addEventListener('scroll', close, true) window.addEventListener('scroll', onScroll, true)
window.addEventListener('keydown', onKey) window.addEventListener('keydown', onKey)
}, 0) }, 0)
return () => { return () => {
clearTimeout(id) clearTimeout(id)
window.removeEventListener('click', close) window.removeEventListener('click', close)
window.removeEventListener('contextmenu', close) window.removeEventListener('contextmenu', close)
window.removeEventListener('scroll', close, true) window.removeEventListener('scroll', onScroll, true)
window.removeEventListener('keydown', onKey) window.removeEventListener('keydown', onKey)
} }
}, []) }, [])
return ( return (
<div <div ref={rootRef} role="menu" onClick={(e) => e.stopPropagation()}>
role="menu" <MenuPanel
className="fixed z-50 min-w-[160px] overflow-hidden rounded-lg border border-line bg-ink-850 py-1 shadow-2xl" items={items}
onClose={onClose}
className="min-w-[160px]"
style={{ top: Math.min(y, window.innerHeight - 100), left: Math.min(x, window.innerWidth - 180) }} style={{ top: Math.min(y, window.innerHeight - 100), left: Math.min(x, window.innerWidth - 180) }}
onClick={(e) => e.stopPropagation()} />
</div>
)
}
function MenuPanel({
items,
onClose,
className = '',
style,
}: {
items: MenuItem[]
onClose: () => void
className?: string
style: React.CSSProperties
}) {
// The open submenu: which row, and where to draw it. Fixed-positioned from
// the row's rect, flipping left / up when it would run off the window.
const [open, setOpen] = useState<{ index: number; style: React.CSSProperties } | null>(null)
const openSubmenu = (index: number, row: HTMLElement) => {
const r = row.getBoundingClientRect()
const left =
r.right + SUBMENU_WIDTH > window.innerWidth ? Math.max(0, r.left - SUBMENU_WIDTH) : r.right
const top = Math.max(8, Math.min(r.top - 4, window.innerHeight - SUBMENU_MAX_HEIGHT - 8))
setOpen({ index, style: { left, top, width: SUBMENU_WIDTH, maxHeight: SUBMENU_MAX_HEIGHT } })
}
const openItem = open ? items[open.index] : null
return (
<>
<div
className={`fixed z-50 overflow-y-auto rounded-lg border border-line bg-ink-850 py-1 shadow-2xl ${className}`}
style={style}
> >
{items.map((item, i) => ( {items.map((item, i) => {
if ('heading' in item) {
return (
<div key={i}>
<div className="px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wider text-faint">
{item.heading}
</div>
{item.empty && <div className="px-3 py-1.5 text-sm text-faint">{item.empty}</div>}
</div>
)
}
if ('submenu' in item) {
return (
<button <button
key={i} key={i}
onMouseEnter={(e) => openSubmenu(i, e.currentTarget)}
onClick={(e) => openSubmenu(i, e.currentTarget)}
className={`flex w-full items-center justify-between gap-4 px-3 py-1.5 text-left text-sm hover:bg-ink-800 hover:text-text ${
open?.index === i ? 'bg-ink-800 text-text' : 'text-muted'
}`}
>
<span>{item.label}</span>
<span className="text-[10px] text-faint">▸</span>
</button>
)
}
return (
<button
key={i}
onMouseEnter={() => setOpen(null)}
onClick={() => { onClick={() => {
item.onClick() item.onClick()
onClose() onClose()
}} }}
className={`block w-full px-3 py-1.5 text-left text-sm ${ className={`flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm ${
item.danger item.danger
? 'text-pink hover:bg-ink-800' ? 'text-pink hover:bg-ink-800'
: 'text-muted hover:bg-ink-800 hover:text-text' : 'text-muted hover:bg-ink-800 hover:text-text'
}`} }`}
> >
{item.label} {item.icon && <span className="shrink-0 text-[11px] text-gold">{item.icon}</span>}
<span className="min-w-0 flex-1 truncate">{item.label}</span>
{item.hint && (
<span className="shrink-0 text-[10px] tabular-nums text-faint">{item.hint}</span>
)}
</button> </button>
))} )
})}
</div> </div>
{open && openItem && 'submenu' in openItem && (
<MenuPanel items={openItem.submenu} onClose={onClose} style={open.style} />
)}
</>
) )
} }
+1 -1
View File
@@ -279,7 +279,7 @@ function ExportRow({
{expanded && data && data.tracks === 0 && ( {expanded && data && data.tracks === 0 && (
<div style={{ paddingLeft: 24 }} className="py-1 pr-2 text-[11px] text-faint"> <div style={{ paddingLeft: 24 }} className="py-1 pr-2 text-[11px] text-faint">
Empty — select tracks and use “Add to…”. Empty — right-click tracks and choose Add to.
</div> </div>
)} )}
-123
View File
@@ -1,123 +0,0 @@
import { useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { api, type PlaylistNode } from '../api'
interface Props {
count: number
trackIds: string[]
onClear: () => void
onDone: (msg: string) => void
onError: (msg: string) => void
}
function flattenPlaylists(nodes: PlaylistNode[]): PlaylistNode[] {
return nodes.flatMap((n) => [
...(n.can_add_tracks ? [n] : []),
...flattenPlaylists(n.children),
])
}
// Floating action bar shown when tracks are selected in the explorer.
export function SelectionBar({ count, trackIds, onClear, onDone, onError }: Props) {
const qc = useQueryClient()
const [menuOpen, setMenuOpen] = useState(false)
const { data: playlists } = useQuery({ queryKey: ['playlists'], queryFn: api.playlists })
const { data: exportSets } = useQuery({ queryKey: ['exports'], queryFn: api.exports })
const flat = playlists ? flattenPlaylists(playlists) : []
const sets = exportSets ?? []
// Adding to an EXPORT does not touch the library — an export set is
// Konduktor's own curation — so unlike the playlist mutation this dirties
// nothing and invalidates only the export's own live counts.
const addToExport = useMutation({
mutationFn: ({ id, ids }: { id: string; ids: string[] }) =>
api.addToExport(id, { track_ids: ids }),
onSuccess: (_res, vars) => {
qc.invalidateQueries({ queryKey: ['export-contents', vars.id] })
qc.invalidateQueries({ queryKey: ['export-tracks', vars.id] })
qc.invalidateQueries({ queryKey: ['export-loose', vars.id] })
const set = sets.find((s) => s.id === vars.id)
onDone(`Added ${vars.ids.length} track${vars.ids.length === 1 ? '' : 's'} to ${set?.name ?? 'export'}`)
setMenuOpen(false)
onClear()
},
onError: (e: Error) => onError(e.message),
})
const add = useMutation({
mutationFn: ({ uuid, ids }: { uuid: string; ids: string[] }) => api.addEntries(uuid, ids),
onSuccess: (res, vars) => {
qc.invalidateQueries({ queryKey: ['state'] })
qc.invalidateQueries({ queryKey: ['playlists'] })
qc.invalidateQueries({ queryKey: ['playlist', vars.uuid] })
const pl = flat.find((p) => p.id === vars.uuid)
onDone(`Added ${res.added} track${res.added === 1 ? '' : 's'} to ${pl?.name ?? 'playlist'}`)
setMenuOpen(false)
onClear()
},
onError: (e: Error) => onError(e.message),
})
if (count === 0) return null
return (
<div className="pointer-events-none absolute inset-x-0 bottom-4 z-20 flex justify-center">
<div className="pointer-events-auto flex items-center gap-3 rounded-full border border-line bg-ink-800 py-2 pl-4 pr-2 shadow-xl">
<span className="text-sm text-text">
<span className="font-semibold tabular-nums">{count}</span> selected
</span>
<div className="relative">
<button
onClick={() => setMenuOpen((o) => !o)}
className="rounded-full bg-accent px-3 py-1.5 text-sm font-medium text-ink-950 hover:brightness-110"
>
Add to… ▾
</button>
{menuOpen && (
<div className="absolute bottom-full right-0 mb-2 max-h-72 w-60 overflow-y-auto rounded-lg border border-line bg-ink-850 p-1 shadow-2xl">
<div className="px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wider text-faint">
Playlists
</div>
{flat.length === 0 && (
<div className="px-3 py-1.5 text-sm text-faint">No playlists yet</div>
)}
{flat.map((p) => (
<button
key={p.id}
onClick={() => add.mutate({ uuid: p.id, ids: trackIds })}
className="flex w-full items-center justify-between gap-2 rounded-md px-3 py-1.5 text-left text-sm text-muted hover:bg-ink-800 hover:text-text"
>
<span className="truncate">{p.name}</span>
<span className="shrink-0 text-[10px] tabular-nums text-faint">{p.count}</span>
</button>
))}
<div className="px-3 pb-1 pt-3 text-[10px] font-semibold uppercase tracking-wider text-faint">
Exports
</div>
{sets.length === 0 && (
<div className="px-3 py-1.5 text-sm text-faint">No exports yet</div>
)}
{sets.map((set) => (
<button
key={set.id}
onClick={() => addToExport.mutate({ id: set.id, ids: trackIds })}
className="flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-left text-sm text-muted hover:bg-ink-800 hover:text-text"
>
<span className="shrink-0 text-[11px] text-gold">◈</span>
<span className="truncate">{set.name}</span>
</button>
))}
</div>
)}
</div>
<button
onClick={onClear}
className="rounded-full px-2 py-1.5 text-sm text-muted hover:bg-ink-700 hover:text-text"
>
Clear
</button>
</div>
</div>
)
}
+9
View File
@@ -2,6 +2,8 @@ interface Props {
showing: number showing: number
total: number total: number
sourceName: string sourceName: string
/** Rows currently selected; shown only when non-zero. */
selected?: number
loading?: boolean loading?: boolean
collectionName?: string | null collectionName?: string | null
onChangeCollection?: () => void onChangeCollection?: () => void
@@ -11,6 +13,7 @@ export function StatusBar({
showing, showing,
total, total,
sourceName, sourceName,
selected = 0,
loading, loading,
collectionName, collectionName,
onChangeCollection, onChangeCollection,
@@ -32,6 +35,12 @@ export function StatusBar({
)} )}
</span> </span>
)} )}
{selected > 0 && (
<>
<span className="text-faint">·</span>
<span className="tabular-nums text-accent">{selected.toLocaleString()} selected</span>
</>
)}
{collectionName && ( {collectionName && (
<button <button
onClick={onChangeCollection} onClick={onChangeCollection}