Skip to content

Commit 94e776b

Browse files
committed
Use the new grid track table in place of existing playlists
1 parent 7b8b200 commit 94e776b

File tree

11 files changed

+854
-22
lines changed

11 files changed

+854
-22
lines changed

packages/app/app/components/ArtistView/PopularTracks/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const PopularTracks: React.FC<PopularTracksProps> = ({
7171
const customColumns = useMemo(() => [{
7272
id: PlaycountColumnId,
7373
Header: t('count'),
74-
accessor: (track: ArtistTopTrack) => track.playcount,
74+
accessor: 'playcount',
7575
Cell: ({value, ...rest}: CellProps<Track, string>) => <TrackTableCell value={Number(value).toLocaleString()} {...rest} />
7676
}], []);
7777

packages/app/app/components/ListeningHistoryView/styles.scss

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
.listening_history_header_actions {
1515
display: flex;
1616
align-items: center;
17+
18+
button.nuclear.ui.button:not(:last-child) {
19+
margin-right: 1em;
20+
}
1721
}
1822

1923
.listening_history_pagination {

packages/app/app/components/PlaylistView/styles.scss

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
.playlist_view_container {
44
width: 100%;
55
height: 100%;
6-
margin: 1em 0em;
76

87
.playlist {
98
display: flex;
109
flex-flow: column;
11-
margin-right: 1em;
10+
height: 100%;
1211
}
1312

1413
.playlist_view_info {

packages/app/app/containers/TrackTableContainer/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Icon } from 'semantic-ui-react';
55
import _ from 'lodash';
66

77
import { Playlist } from '@nuclear/core';
8-
import { TrackTable, areTracksEqualByName } from '@nuclear/ui';
8+
import { GridTrackTable, areTracksEqualByName } from '@nuclear/ui';
99
import { TrackTableProps } from '@nuclear/ui/lib/components/TrackTable';
1010
import { TrackTableSettings } from '@nuclear/ui/lib/components/TrackTable/types';
1111
import { Track } from '@nuclear/ui/lib/types';
@@ -33,7 +33,7 @@ function TrackTableContainer<T extends Track> ({
3333
tracks,
3434
onDelete,
3535
onReorder,
36-
TrackTableComponent = TrackTable,
36+
TrackTableComponent = GridTrackTable,
3737
customColumns,
3838
displayAddToDownloads = true,
3939
displayAddToFavorites = true,

packages/ui/lib/components/ContextPopup/styles.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '../../common';
1+
@import "../../common";
22

33
.context_popup {
44
@include shadow;
@@ -80,7 +80,7 @@
8080
display: flex;
8181
flex-flow: column;
8282
flex: 0 0 auto;
83-
padding: 0.5rem 0;
83+
padding-top: 0.5rem;
8484
height: auto !important;
8585
}
8686
}

packages/ui/lib/components/GridTrackTable/index.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export type GridTrackTableProps<T extends Track> = {
3232
isTrackFavorite: (track: T) => boolean;
3333
onDragEnd?: DragDropContextProps['onDragEnd'];
3434
strings: TrackTableStrings;
35-
customColumns?: (Column<T> & { columnWidth: string; })[];
35+
customColumns?: (Column<T & { columnWidth: string; }>)[];
3636
} & TrackTableHeaders
3737
& TrackTableSettings
3838
& TrackTableExtraProps<T>;
@@ -137,7 +137,8 @@ export const GridTrackTable = <T extends Track>({
137137
return null;
138138
}
139139
},
140-
Cell: TextCell
140+
Cell: TextCell,
141+
columnWidth: '6em'
141142
},
142143
...customColumns,
143144
selectable && {
@@ -146,12 +147,12 @@ export const GridTrackTable = <T extends Track>({
146147
Cell: SelectionCell,
147148
columnWidth: '6em'
148149
}
149-
], [displayDeleteButton, displayPosition, displayThumbnail, displayFavorite, isTrackFavorite, titleHeader, displayArtist, artistHeader, displayAlbum, albumHeader, shouldDisplayDuration, durationHeader, selectable, positionHeader, thumbnailHeader]);
150+
].filter(Boolean), [displayDeleteButton, displayPosition, displayThumbnail, displayFavorite, isTrackFavorite, titleHeader, displayArtist, artistHeader, displayAlbum, albumHeader, shouldDisplayDuration, durationHeader, selectable, positionHeader, thumbnailHeader]);
150151

151152
const data = useMemo(() => tracks, [tracks]);
152153

153154
const initialState: Partial<TableState<T> & UseSortByState<T>> = {
154-
sortBy: [{ id: TrackTableColumn.Title, desc: false }]
155+
sortBy: [{ id: TrackTableColumn.Position, desc: false }]
155156
};
156157
const table = useTable<T>({ columns, data, initialState }, useGlobalFilter, useSortBy, useRowSelect) as (TableInstance<T> & UseSortByInstanceProps<T> & UseGlobalFiltersInstanceProps<T>);
157158
const [globalFilter, setGlobalFilterState] = useState(''); // Required, because useGlobalFilter does not provide a way to get the current filter value
@@ -225,7 +226,7 @@ export const GridTrackTable = <T extends Track>({
225226
</div>
226227
))}
227228
</div>
228-
<DragDropContext onDragEnd={() => {}}>
229+
<DragDropContext onDragEnd={onDragEnd}>
229230
<Droppable
230231
droppableId='track_table'
231232
mode='virtual'

packages/ui/lib/components/GridTrackTable/styles.scss

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
flex-flow: column;
77
overflow: hidden;
88
height: 100%;
9+
flex: 1 1 auto;
910
}
1011

1112
.track_table_wrapper .track_table_filter_row {
@@ -75,13 +76,12 @@
7576
}
7677

7778
.track_table_header_spacer {
78-
width: 10px;
79+
width: 0.5rem;
7980
}
8081

8182
.track_table_body {
8283
display: block;
8384
gap: 0.25em;
84-
overflow-y: auto;
8585
flex: 1 1 auto;
8686

8787
&.body_dragged_over {
@@ -106,6 +106,10 @@
106106
user-select: none;
107107
outline: none;
108108

109+
&:not(:last-child) {
110+
border-bottom: 1px solid $bgdefault;
111+
}
112+
109113
&:hover {
110114
background: rgba($bgdefault, 0.25);
111115

@@ -146,6 +150,11 @@
146150
}
147151

148152
.text_header {
153+
display: flex;
154+
flex-flow: row;
155+
justify-content: space-between;
156+
align-items: center;
157+
149158
&.centered {
150159
display: flex;
151160
justify-content: center;

packages/ui/lib/components/TrackTable/HistoryTable.tsx

+12-6
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,28 @@ import TrackTable, { TrackTableProps } from '.';
55
import { Track } from '../../types';
66
import DateCell from './Cells/DateCell';
77
import { TrackTableColumn } from './types';
8+
import { GridTrackTable } from '../GridTrackTable';
9+
import { Column } from 'react-table';
10+
import { TextHeader } from '../GridTrackTable/Headers/TextHeader';
811

912
export type HistoryTableTrack = Track & {
1013
createdAt: Date;
1114
}
1215

13-
type HistoryTableProps = TrackTableProps<HistoryTableTrack>;
16+
type HistoryTableProps = TrackTableProps<HistoryTableTrack> & {
17+
dateHeader?: string;
18+
};
1419

15-
const HistoryTable: React.FC<HistoryTableProps> = ({ tracks, ...props }) => {
20+
const HistoryTable: React.FC<HistoryTableProps> = ({ tracks, dateHeader, ...props }) => {
1621
const customColumns = useMemo(() => [{
1722
id: TrackTableColumn.Date,
18-
Header: 'Date',
23+
Header: ({ column }) => <TextHeader column={column} header={dateHeader} />,
1924
accessor: (track: HistoryTableTrack) => track.createdAt.toLocaleString(),
20-
Cell: DateCell
21-
}], []);
25+
Cell: DateCell,
26+
columnnWidth: '3em'
27+
} as Column<HistoryTableTrack>], []);
2228

23-
return <TrackTable
29+
return <GridTrackTable
2430
className={styles.history_table}
2531
tracks={tracks}
2632
customColumns={customColumns}

0 commit comments

Comments
 (0)