import React, { PropTypes } from 'react'
import { Router, Link, hashHistory } from 'react-router'
import FontAwesome from 'react-fontawesome'
import Thumbnail from './Thumbnail'
import ArtistSentence from './ArtistSentence'
export default class GridItem extends React.Component{
constructor(props) {
super(props);
}
handleClick(e){
if( e.target.tagName.toLowerCase() !== 'a' ){
hashHistory.push(this.props.link)
}
}
renderThumbnail(){
if( this.props.item.images ) return
if( this.props.item.icons ) return
return
}
renderSecondary(item){
var output = ''
switch (item.type){
case 'playlist':
return (
{ item.tracks_total ? item.tracks_total+' tracks' : null }
{ item.can_edit ? : null }
)
break
default:
return (
{ item.artists ? : null }
{ item.followers ? item.followers.total.toLocaleString()+' followers' : null }
)
}
return output
}
render(){
if( !this.props.item ) return null
var item = this.props.item;
if( typeof(item.album) !== 'undefined' ){
item.album.added_at = item.added_at;
item = item.album;
}
return (
this.handleClick(e) }>
{ this.renderThumbnail() }
{ item.name }
{ this.renderSecondary(item) }
);
}
}