Files
Iris/src/js/components/ArtistSentence.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-10-25 21:36:33 +13:00
import React, { PropTypes } from 'react'
import FontAwesome from 'react-fontawesome'
import { Link } from 'react-router'
export default class ArtistSentence extends React.Component{
constructor(props) {
super(props);
}
render(){
if( !this.props.artists ) return <span>-</span>
2016-10-25 21:36:33 +13:00
return (
2016-11-25 16:08:19 +13:00
<span className={ this.props.className ? this.props.className+" artist-sentence" : "artist-sentence" }>
2016-10-25 21:36:33 +13:00
{
this.props.artists.map( (artist, index) => {
if (!artist) return <span>-</span>
2016-10-25 21:36:33 +13:00
var separator = null;
if( index == this.props.artists.length - 2 ){
separator = ' and ';
}else if( index < this.props.artists.length - 2 ){
separator = ', ';
}
if (!artist.name){
var content = <span>-</span>
} else if (artist.uri){
2016-12-21 15:24:07 +13:00
var content = <Link className="artist" to={global.baseURL+'artist/'+artist.uri}>{ artist.name }</Link>
}else{
var content = <span>{ artist.name }</span>
}
2016-10-25 21:36:33 +13:00
return (
<span key={'index_'+artist.uri}>
{ content }
{ separator }
2016-10-25 21:36:33 +13:00
</span>
);
})
}
</span>
);
}
}