Skip to content

Commit 13ec3ba

Browse files
dylanjeffersclaude
andcommitted
feat(web): highlight selected playlist rows while in edit mode
Builds on the row-click selection from this branch to give the user visible feedback for which tracks are currently selected. - `TracksTable` gains an optional `rowClassNameAddition(track, index)` prop that's composed with the table's existing per-row className (used internally for the locked/disabled states). The hook is ref-stable so external state changes don't force a full re-render of the table machinery. - `EditAwareTracksTable` passes a `rowClassNameAddition` that returns the new `selected` CSS class when the row's track id is in the selection set and the page is in edit mode. The class draws a surface-2 background fill and a 3px accent bar on the left edge so selected rows are immediately scannable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 503bdd1 commit 13ec3ba

3 files changed

Lines changed: 42 additions & 5 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.selected,
2+
.selected td {
3+
background-color: var(--harmony-bg-surface-2) !important;
4+
box-shadow: inset 3px 0 0 0 var(--harmony-secondary, var(--harmony-accent));
5+
}

packages/web/src/components/collection/desktop/edit-mode/tracks/EditAwareTracksTable.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { TracksTable } from 'components/tracks-table'
66

77
import { usePlaylistEditMode } from '../PlaylistEditModeContext'
88

9+
import styles from './EditAwareTracksTable.module.css'
910
import { useTrackSelection } from './TrackSelectionContext'
1011

1112
type TrackLike = { track_id?: number | null } & Record<string, unknown>
@@ -62,5 +63,21 @@ export const EditAwareTracksTable = (props: EditAwareTracksTableProps) => {
6263
[isEditingThis, onClickRow, selection]
6364
)
6465

65-
return <TracksTable {...rest} onClickRow={handleClickRow} />
66+
const rowClassNameAddition = useCallback(
67+
(track: TrackLike) => {
68+
if (!isEditingThis) return undefined
69+
const id = track.track_id
70+
if (typeof id !== 'number') return undefined
71+
return selection.isSelected(id) ? styles.selected : undefined
72+
},
73+
[isEditingThis, selection]
74+
)
75+
76+
return (
77+
<TracksTable
78+
{...rest}
79+
onClickRow={handleClickRow}
80+
rowClassNameAddition={rowClassNameAddition}
81+
/>
82+
)
6683
}

packages/web/src/components/tracks-table/TracksTable.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ type TracksTableProps = {
184184
showArtistInTrackNameColumn?: boolean
185185
onClickRow?: (track: any, index: number) => void
186186
trackActionsHeader?: ReactNode
187+
/**
188+
* Optional additional className applied per row. The result is appended
189+
* to the table's own per-row className. Use this for things like a
190+
* selected-row highlight while the page is in edit mode.
191+
*/
192+
rowClassNameAddition?: (track: any, rowIndex: number) => string | undefined
187193
} & Omit<TableProps, 'onClickRow' | 'columns'>
188194

189195
const defaultColumns: TracksTableColumn[] = [
@@ -214,6 +220,7 @@ export const TracksTable = ({
214220
data,
215221
activeIndex,
216222
trackActionsHeader,
223+
rowClassNameAddition,
217224
...tableProps
218225
}: TracksTableProps) => {
219226
const { isVirtualized, onClickRow } = tableProps
@@ -1046,6 +1053,9 @@ export const TracksTable = ({
10461053
[activateTrack]
10471054
)
10481055

1056+
const rowClassNameAdditionRef = useRef(rowClassNameAddition)
1057+
rowClassNameAdditionRef.current = rowClassNameAddition
1058+
10491059
const getRowClassName = useCallback((rowIndex: number) => {
10501060
const track = dataRef.current[rowIndex]
10511061
const { isFetchingNFTAccess, hasStreamAccess } = trackAccessMapRef.current[
@@ -1058,10 +1068,15 @@ export const TracksTable = ({
10581068
const deleted =
10591069
track.is_delete || track._marked_deleted || !!track.user?.is_deactivated
10601070
const isPremium = isContentUSDCPurchaseGated(track.stream_conditions)
1061-
return cn(styles.tableRow, {
1062-
[styles.disabled]: deleted,
1063-
[styles.lockedRow]: isLocked && !deleted && !isPremium
1064-
})
1071+
const extra = rowClassNameAdditionRef.current?.(track, rowIndex)
1072+
return cn(
1073+
styles.tableRow,
1074+
{
1075+
[styles.disabled]: deleted,
1076+
[styles.lockedRow]: isLocked && !deleted && !isPremium
1077+
},
1078+
extra
1079+
)
10651080
}, [])
10661081

10671082
return (

0 commit comments

Comments
 (0)