2016-10-25 14:09:53 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
|
|
|
|
import { Link, browserHistory } from 'react-router'
|
|
|
|
|
|
|
|
|
|
import Thumbnail from './Thumbnail'
|
2016-10-25 21:36:33 +13:00
|
|
|
import ArtistSentence from './ArtistSentence'
|
2016-10-25 14:09:53 +13:00
|
|
|
|
|
|
|
|
export default class GridItem extends React.Component{
|
|
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleClick(e){
|
|
|
|
|
if( e.target.tagName.toLowerCase() !== 'a' ){
|
|
|
|
|
browserHistory.push( this.props.link );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
var item = this.props.item;
|
|
|
|
|
if( typeof(item.album) !== 'undefined' ){
|
|
|
|
|
item.album.added_at = item.added_at;
|
|
|
|
|
item = item.album;
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<div className="grid-item" onClick={ (e) => this.handleClick(e) }>
|
2016-10-26 16:55:47 +13:00
|
|
|
{ item.images ? <Thumbnail size="medium" images={item.images} /> : null }
|
|
|
|
|
{ item.icons ? <Thumbnail size="medium" images={item.icons} /> : null }
|
2016-10-25 14:09:53 +13:00
|
|
|
<div className="name">{ item.name }</div>
|
|
|
|
|
<div className="secondary">
|
2016-10-25 21:36:33 +13:00
|
|
|
{ item.artists ? <ArtistSentence artists={ item.artists } /> : null }
|
2016-10-26 16:55:47 +13:00
|
|
|
{ item.type == 'playlist' ? item.tracks.total+' tracks' : null }
|
2016-10-25 14:09:53 +13:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|