Placeholder mientras coverart carga
This commit is contained in:
@@ -9,6 +9,37 @@ import {Tab, TabList, TabPanel, Tabs} from "react-tabs";
|
|||||||
|
|
||||||
import {ReactComponent as DiscSVG} from "../svg/disc.svg";
|
import {ReactComponent as DiscSVG} from "../svg/disc.svg";
|
||||||
|
|
||||||
|
class CoverArt extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
loading: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleLoad = () => {
|
||||||
|
this.setState({loading: false})
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if(this.props.cover_art){
|
||||||
|
if(this.state.loading){
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
<img src={this.props.cover_art.image} className={'coverart loading'} alt={this.props.alt} onLoad={this.handleLoad}/>
|
||||||
|
<DiscSVG className='coverart'/>
|
||||||
|
</Fragment>
|
||||||
|
)
|
||||||
|
}else {
|
||||||
|
return <img src={this.props.cover_art.image} className={'coverart'} alt={this.props.alt}/>
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return <DiscSVG className='coverart'/>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const SearchPlaceholder = (props) => {
|
const SearchPlaceholder = (props) => {
|
||||||
const className = props.className + ' pulsating';
|
const className = props.className + ' pulsating';
|
||||||
return (
|
return (
|
||||||
@@ -111,7 +142,7 @@ class SearchDisc extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<li className='disc'>
|
<li className='disc'>
|
||||||
<Link to={`/disc/${disc.id}`}>
|
<Link to={`/disc/${disc.id}`}>
|
||||||
{disc.cover_art ? <img src={disc.cover_art.image} className='coverart' alt={`Cover del disco: ${disc.title}`}/> : <DiscSVG className='coverart'/>}
|
<CoverArt cover_art={disc.cover_art} alt={`Cover del disco: ${disc.title}`}/>
|
||||||
<div class='description'>
|
<div class='description'>
|
||||||
<span>{disc.title} {disc.date && this.getReleaseYear(disc.date)}</span>
|
<span>{disc.title} {disc.date && this.getReleaseYear(disc.date)}</span>
|
||||||
<span className='small'>{disc.artist[0].name}</span>
|
<span className='small'>{disc.artist[0].name}</span>
|
||||||
|
|||||||
@@ -175,7 +175,11 @@ ul.entity_list {
|
|||||||
width: 200px;
|
width: 200px;
|
||||||
height: 200px;
|
height: 200px;
|
||||||
margin: 1rem;
|
margin: 1rem;
|
||||||
border: 1px solid var(--gray-2)
|
border: 1px solid var(--gray-2);
|
||||||
|
|
||||||
|
&.loading {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.release-date {
|
.release-date {
|
||||||
|
|||||||
Reference in New Issue
Block a user