import React from 'react' import { GridList, GridListTile, GridListTileBar, useMediaQuery, } from '@material-ui/core' import { makeStyles } from '@material-ui/core/styles' import withWidth from '@material-ui/core/withWidth' import { Link } from 'react-router-dom' import { linkToRecord, Loading } from 'react-admin' import { withContentRect } from 'react-measure' import subsonic from '../subsonic' import { AlbumContextMenu, PlayButton } from '../common' const useStyles = makeStyles((theme) => ({ root: { margin: '20px', }, tileBar: { transition:'all 150ms ease-out', opacity:0, textAlign: 'left', marginBottom: '3px', background: 'linear-gradient(to top, rgba(0,0,0,0.7) 0%,rgba(0,0,0,0.4) 70%,rgba(0,0,0,0) 100%)', }, tileBarMobile: { textAlign: 'left', marginBottom: '3px', background: 'linear-gradient(to top, rgba(0,0,0,0.7) 0%,rgba(0,0,0,0.4) 70%,rgba(0,0,0,0) 100%)', }, albumArtistName: { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', textAlign: 'left', fontSize: '1em', }, artistLink: { color: theme.palette.primary.light, }, albumArtist: { fontSize:'12px', color:'#c5c5c5', overflow:'hidden', whiteSpace:'nowrap', textOverflow: 'ellipsis' }, albumName: { fontSize:'14px', color:'#eee', overflow:'hidden', whiteSpace:'nowrap', textOverflow: 'ellipsis' }, link: { position:'relative', display: 'block', textDecoration:'none', "&:hover $tileBar": { opacity:1, } }, albumLlink: { position:'relative', display: 'block', textDecoration:'none', }, })) const useCoverStyles = makeStyles({ cover: { display: 'inline-block', width: '100%', height: (props) => props.height, }, }) const getColsForWidth = (width) => { if (width === 'xs') return 2 if (width === 'sm') return 3 if (width === 'md') return 4 if (width === 'lg') return 6 return 9 } const Cover = withContentRect('bounds')( ({ album, measureRef, contentRect }) => { // Force height to be the same as the width determined by the GridList // noinspection JSSuspiciousNameCombination const classes = useCoverStyles({ height: contentRect.bounds.width }) return (