-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Grid track table - complete functionality
- Loading branch information
Showing
13 changed files
with
342 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/ui/lib/components/GridTrackTable/Cells/DeleteCell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { CellProps } from 'react-table'; | ||
import cx from 'classnames'; | ||
|
||
import styles from '../styles.scss'; | ||
import { Track } from '../../../types'; | ||
import { TrackTableExtraProps } from '../../TrackTable/types'; | ||
import Button from '../../Button'; | ||
|
||
export const DeleteCell: React.FC<CellProps<Track> & TrackTableExtraProps<Track>> = ({ | ||
cell, | ||
row, | ||
onDelete | ||
}) => <div | ||
{...cell.getCellProps()} | ||
className={cx(styles.delete_cell)} | ||
data-testid='delete-cell'> | ||
<Button | ||
data-testid='delete-button' | ||
basic | ||
borderless | ||
circular | ||
size='tiny' | ||
icon='times' | ||
onClick={() => onDelete(row.original, row.index)} | ||
/> | ||
</div>; |
28 changes: 28 additions & 0 deletions
28
packages/ui/lib/components/GridTrackTable/Cells/FavoriteCell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { CellProps } from 'react-table'; | ||
import cx from 'classnames'; | ||
|
||
import { TrackTableExtraProps } from '../../TrackTable/types'; | ||
import { Track } from '../../../types'; | ||
import Button from '../../Button'; | ||
import styles from '../styles.scss'; | ||
|
||
export const FavoriteCell: React.FC<CellProps<Track> & TrackTableExtraProps<Track>> = ({ | ||
cell, | ||
row, | ||
value, | ||
onAddToFavorites, | ||
onRemoveFromFavorites | ||
}) => <div | ||
{...cell.getCellProps()} | ||
className={cx(styles.grid_track_table_cell, styles.favorite_cell)} | ||
data-testid='favorite-cell'> | ||
<Button | ||
data-testid='favorite-button' | ||
basic | ||
borderless | ||
circular | ||
size='tiny' icon={value ? 'heart' : 'heart outline'} | ||
onClick={() => value ? onRemoveFromFavorites(row.original) : onAddToFavorites(row.original)} | ||
/> | ||
</div>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
packages/ui/lib/components/GridTrackTable/Cells/TitleCell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import React from 'react'; | ||
import { CellProps } from 'react-table'; | ||
import cx from 'classnames'; | ||
|
||
import { TrackTableColumn, TrackTableExtraProps } from '../../TrackTable/types'; | ||
import { Track } from '../../../types'; | ||
import Button from '../../Button'; | ||
import TrackPopup from '../../TrackPopup'; | ||
import styles from '../styles.scss'; | ||
|
||
export const TitleCell: React.FC<CellProps<Track> & TrackTableExtraProps<Track>> = ({ | ||
cell, | ||
row, | ||
value, | ||
|
||
onPlay, | ||
onPlayNext, | ||
onAddToQueue, | ||
onAddToFavorites, | ||
onAddToPlaylist, | ||
onCreatePlaylist, | ||
onAddToDownloads, | ||
playlists, | ||
popupActionStrings | ||
}) => <div | ||
{...cell.getCellProps()} | ||
data-testid='title-cell' | ||
className={cx(styles.grid_track_table_cell, styles.text_cell, styles.title_cell)} | ||
> | ||
<span className={styles.title_cell_content}> | ||
<span className={styles.title_cell_value}> | ||
{value} | ||
</span> | ||
<span className={styles.title_cell_buttons}> | ||
<Button | ||
className={styles.title_cell_button} | ||
basic | ||
borderless | ||
circular | ||
size='tiny' | ||
icon='plus' | ||
onClick={() => onAddToQueue(row.original)} | ||
data-testid='add-to-queue' | ||
/> | ||
|
||
<TrackPopup | ||
trigger={ | ||
<Button | ||
className={styles.title_cell_button} | ||
basic | ||
borderless | ||
circular | ||
size='tiny' | ||
icon='ellipsis horizontal' | ||
data-testid='track-popup-trigger' | ||
/> | ||
} | ||
thumb={row.values[TrackTableColumn.Thumbnail]} | ||
title={row.values[TrackTableColumn.Title]} | ||
artist={row.values[TrackTableColumn.Artist]} | ||
playlists={playlists} | ||
|
||
onPlayNow={() => onPlay(row.original)} | ||
onPlayNext={() => onPlayNext(row.original)} | ||
onAddToQueue={() => onAddToQueue(row.original)} | ||
onAddToFavorites={() => onAddToFavorites(row.original)} | ||
onAddToPlaylist={(playlist: { name: string }) => onAddToPlaylist(row.original, playlist)} | ||
onCreatePlaylist={(options: { name: string }) => onCreatePlaylist(row.original, options)} | ||
onAddToDownloads={() => onAddToDownloads(row.original)} | ||
|
||
withPlayNow={Boolean(onPlay)} | ||
withPlayNext={Boolean(onPlayNext)} | ||
withAddToQueue={Boolean(onAddToQueue)} | ||
withAddToFavorites={Boolean(onAddToFavorites)} | ||
withAddToPlaylist={Boolean(onAddToFavorites)} | ||
withAddToDownloads={Boolean(onAddToDownloads) && !row.original.local} | ||
|
||
strings={popupActionStrings} | ||
/> | ||
</span> | ||
</span> | ||
</div>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.