parent
9c9d1b6dd8
commit
ce2d814506
4 changed files with 186 additions and 18 deletions
@ -0,0 +1,49 @@ |
||||
import React from 'react'; |
||||
import { TableContainer, Table, TableHead, TableRow, TableCell, Paper, makeStyles, TableBody } from '@material-ui/core'; |
||||
|
||||
export interface SongGetters { |
||||
getTitle: (song: any) => string, |
||||
getArtist: (song: any) => string, |
||||
getAlbum: (song: any) => string, |
||||
} |
||||
|
||||
export interface IProps { |
||||
songs: any[], |
||||
songGetters: SongGetters, |
||||
} |
||||
|
||||
export function SongTable(props: IProps) { |
||||
const useTableStyles = makeStyles({ |
||||
table: { |
||||
minWidth: 650, |
||||
}, |
||||
}); |
||||
const classes = useTableStyles(); |
||||
|
||||
return ( |
||||
<TableContainer component={Paper}> |
||||
<Table className={classes.table} aria-label="a dense table"> |
||||
<TableHead> |
||||
<TableRow> |
||||
<TableCell align="left">Title</TableCell> |
||||
<TableCell align="left">Artist</TableCell> |
||||
<TableCell align="left">Album</TableCell> |
||||
</TableRow> |
||||
</TableHead> |
||||
<TableBody> |
||||
{props.songs.map((song:any) => { |
||||
const title = props.songGetters.getTitle(song); |
||||
const artist = props.songGetters.getArtist(song); |
||||
const album = props.songGetters.getAlbum(song); |
||||
|
||||
return <TableRow key={title}> |
||||
<TableCell align="left">{title}</TableCell> |
||||
<TableCell align="left">{artist}</TableCell> |
||||
<TableCell align="left">{album}</TableCell> |
||||
</TableRow> |
||||
})} |
||||
</TableBody> |
||||
</Table> |
||||
</TableContainer> |
||||
); |
||||
} |
Loading…
Reference in new issue