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

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-10-25 21:36:33 +13:00
import React, { PropTypes } from 'react'
import URILink from './URILink'
2016-10-25 21:36:33 +13:00
export default class ArtistSentence extends React.Component{
2017-10-10 13:05:28 +13:00
constructor(props){
2016-10-25 21:36:33 +13:00
super(props);
}
render(){
if (!this.props.artists){
return <span className={this.props.className ? this.props.className+" artist-sentence" : "artist-sentence" }>-</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
{
2017-10-10 13:05:28 +13:00
this.props.artists.map((artist, index) => {
if (!artist){
return <span>-</span>;
}
2016-10-25 21:36:33 +13:00
var separator = null;
2017-10-10 13:05:28 +13:00
if (index == this.props.artists.length - 2){
2016-10-25 21:36:33 +13:00
separator = ' and ';
} else if (index < this.props.artists.length - 2){
2016-10-25 21:36:33 +13:00
separator = ', ';
}
if (!artist.name){
var content = <span>-</span>
2017-05-12 05:22:57 +12:00
} else if (!artist.uri || this.props.nolinks){
var content = <span>{ artist.name }</span>
} else {
var content = <URILink className="artist" type="artist" uri={artist.uri}>{ artist.name }</URILink>
}
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>
);
}
}