Links for grid items, may need to add more context options
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
|
||||
import React, { PropTypes } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import React, { PropTypes } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { Redirect } from 'react-router';
|
||||
import { Route, Switch } from 'react-router-dom';
|
||||
|
||||
import Link from '../components/Link';
|
||||
import LazyLoadListener from '../components/LazyLoadListener'
|
||||
@ -105,18 +107,7 @@ class Artist extends React.Component{
|
||||
this.props.uiActions.set({artist_albums_filter: value});
|
||||
}
|
||||
|
||||
renderSubViewMenu(){
|
||||
return (
|
||||
<div className="sub-views" id="sub-views-menu">
|
||||
<Link className="option" activeClassName="active" to={global.baseURL+'artist/'+this.props.uri} scrollTo="sub-views-menu"><h4>Overview</h4></Link>
|
||||
{this.props.artist.related_artists_uris ? <Link className="option" activeClassName="active" to={global.baseURL+'artist/'+this.props.uri+'/related-artists'} scrollTo="sub-views-menu"><h4>Related artists</h4></Link> : null}
|
||||
<Link className="option" activeClassName="active" to={global.baseURL+'artist/'+this.props.uri+'/about'} scrollTo="sub-views-menu"><h4>About</h4></Link>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
renderBody(){
|
||||
var scheme = helpers.uriSource(this.props.uri);
|
||||
renderOverview(){
|
||||
var artist = helpers.collate(
|
||||
this.props.artist,
|
||||
{
|
||||
@ -134,144 +125,154 @@ class Artist extends React.Component{
|
||||
artist.albums = helpers.applyFilter('type', this.props.filter, artist.albums);
|
||||
}
|
||||
|
||||
switch (this.props.match.params.sub_view){
|
||||
var sort_options = [
|
||||
{
|
||||
value: null,
|
||||
label: 'Default'
|
||||
},
|
||||
{
|
||||
value: 'name',
|
||||
label: 'Name'
|
||||
},
|
||||
{
|
||||
value: 'date',
|
||||
label: 'Date'
|
||||
},
|
||||
{
|
||||
value: 'tracks_total',
|
||||
label: 'Tracks'
|
||||
}
|
||||
];
|
||||
|
||||
case 'related-artists':
|
||||
return (
|
||||
<div className="body related-artists">
|
||||
<section className="grid-wrapper no-top-padding">
|
||||
<ArtistGrid artists={artist.related_artists} />
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
var filter_options = [
|
||||
{
|
||||
value: null,
|
||||
label: 'All'
|
||||
},
|
||||
{
|
||||
value: 'album',
|
||||
label: 'Albums'
|
||||
},
|
||||
{
|
||||
value: 'single',
|
||||
label: 'Singles'
|
||||
},
|
||||
{
|
||||
value: 'compilation',
|
||||
label: 'Compilations'
|
||||
}
|
||||
];
|
||||
|
||||
case 'about':
|
||||
|
||||
var thumbnails = [];
|
||||
if (artist.images && artist.images.length > 0){
|
||||
for (var i = 0; i < artist.images.length; i++){
|
||||
thumbnails.push(
|
||||
<div className="tile thumbnail-wrapper" key={i}>
|
||||
<Thumbnail size="huge" canZoom images={artist.images[i]} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="body about">
|
||||
|
||||
<div className="col col--w40 tiles artist-stats">
|
||||
{thumbnails}
|
||||
{artist.followers ? <div className="tile"><span className="content"><Icon type="fontawesome" name="users" />{artist.followers.toLocaleString()} followers</span></div> : null}
|
||||
{artist.popularity ? <div className="tile"><span className="content"><Icon type="fontawesome" name="fire" />{artist.popularity }% popularity</span></div> : null}
|
||||
{artist.listeners ? <div className="tile"><span className="content"><Icon type="fontawesome" name="headphones" />{ artist.listeners.toLocaleString() } listeners</span></div> : null }
|
||||
</div>
|
||||
|
||||
<div className="col col--w60 biography">
|
||||
<section>
|
||||
{ artist.biography ? <div className="biography-text"><p>{artist.biography}</p><br />
|
||||
<div className="mid_grey-text">Published: { artist.biography_publish_date }</div>
|
||||
<div className="mid_grey-text">Origin: <a href={ artist.biography_link } target="_blank">{ artist.biography_link }</a></div></div> : null }
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
default:
|
||||
|
||||
var sort_options = [
|
||||
{
|
||||
value: null,
|
||||
label: 'Default'
|
||||
},
|
||||
{
|
||||
value: 'name',
|
||||
label: 'Name'
|
||||
},
|
||||
{
|
||||
value: 'date',
|
||||
label: 'Date'
|
||||
},
|
||||
{
|
||||
value: 'tracks_total',
|
||||
label: 'Tracks'
|
||||
}
|
||||
];
|
||||
|
||||
var filter_options = [
|
||||
{
|
||||
value: null,
|
||||
label: 'All'
|
||||
},
|
||||
{
|
||||
value: 'album',
|
||||
label: 'Albums'
|
||||
},
|
||||
{
|
||||
value: 'single',
|
||||
label: 'Singles'
|
||||
},
|
||||
{
|
||||
value: 'compilation',
|
||||
label: 'Compilations'
|
||||
}
|
||||
];
|
||||
|
||||
if (!artist.tracks_uris || (artist.tracks_uris && !artist.tracks) || (artist.tracks_uris.length !== artist.tracks.length)){
|
||||
var is_loading_tracks = true;
|
||||
} else {
|
||||
var is_loading_tracks = false;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="body overview">
|
||||
<div className={"top-tracks col col--w"+(artist.related_artists && artist.related_artists.length > 0 ? "70" : "100")}>
|
||||
{artist.tracks ? <h4>Top tracks</h4> : null}
|
||||
<div className="list-wrapper">
|
||||
<TrackList className="artist-track-list" uri={artist.uri} tracks={artist.tracks} />
|
||||
<LazyLoadListener showLoader={is_loading_tracks} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="col col--w5"></div>
|
||||
|
||||
{artist.related_artists && artist.related_artists.length > 0 ? <div className="col col--w25 related-artists"><h4>Related artists</h4><div className="list-wrapper"><RelatedArtists artists={artist.related_artists.slice(0,6)} /></div><Link to={global.baseURL+'artist/'+artist.uri+'/related-artists'} scrollTo="sub-views-menu" className="button button--default">All related artists</Link></div> : null}
|
||||
|
||||
<div className="cf"></div>
|
||||
|
||||
{artist.albums ? <div className="albums">
|
||||
<h4>
|
||||
Albums
|
||||
<DropdownField
|
||||
icon="sort"
|
||||
name="Sort"
|
||||
value={this.props.sort}
|
||||
options={sort_options}
|
||||
selected_icon={this.props.sort ? (this.props.sort_reverse ? 'keyboard_arrow_up' : 'keyboard_arrow_down') : null}
|
||||
handleChange={value => {this.setSort(value); this.props.uiActions.hideContextMenu() }}
|
||||
/>
|
||||
<DropdownField
|
||||
icon="filter_list"
|
||||
name="Filter"
|
||||
value={this.props.filter}
|
||||
options={filter_options}
|
||||
handleChange={value => {this.setFilter(value); this.props.uiActions.hideContextMenu() }}
|
||||
/>
|
||||
</h4>
|
||||
|
||||
<section className="grid-wrapper no-top-padding">
|
||||
<AlbumGrid albums={artist.albums} />
|
||||
<LazyLoadListener
|
||||
loadKey={artist.albums_more}
|
||||
showLoader={artist.albums_more}
|
||||
loadMore={() => this.loadMore()}
|
||||
/>
|
||||
</section>
|
||||
</div> : null}
|
||||
</div>
|
||||
)
|
||||
if (!artist.tracks_uris || (artist.tracks_uris && !artist.tracks) || (artist.tracks_uris.length !== artist.tracks.length)){
|
||||
var is_loading_tracks = true;
|
||||
} else {
|
||||
var is_loading_tracks = false;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="body overview">
|
||||
<div className={"top-tracks col col--w"+(artist.related_artists && artist.related_artists.length > 0 ? "70" : "100")}>
|
||||
{artist.tracks ? <h4>Top tracks</h4> : null}
|
||||
<div className="list-wrapper">
|
||||
<TrackList className="artist-track-list" uri={artist.uri} tracks={artist.tracks} />
|
||||
<LazyLoadListener showLoader={is_loading_tracks} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="col col--w5"></div>
|
||||
|
||||
{artist.related_artists && artist.related_artists.length > 0 ? <div className="col col--w25 related-artists"><h4>Related artists</h4><div className="list-wrapper"><RelatedArtists artists={artist.related_artists.slice(0,6)} /></div><Link to={global.baseURL+'artist/'+artist.uri+'/related-artists'} scrollTo="sub-views-menu" className="button button--default">All related artists</Link></div> : null}
|
||||
|
||||
<div className="cf"></div>
|
||||
|
||||
{artist.albums ? <div className="albums">
|
||||
<h4>
|
||||
Albums
|
||||
<DropdownField
|
||||
icon="sort"
|
||||
name="Sort"
|
||||
value={this.props.sort}
|
||||
options={sort_options}
|
||||
selected_icon={this.props.sort ? (this.props.sort_reverse ? 'keyboard_arrow_up' : 'keyboard_arrow_down') : null}
|
||||
handleChange={value => {this.setSort(value); this.props.uiActions.hideContextMenu() }}
|
||||
/>
|
||||
<DropdownField
|
||||
icon="filter_list"
|
||||
name="Filter"
|
||||
value={this.props.filter}
|
||||
options={filter_options}
|
||||
handleChange={value => {this.setFilter(value); this.props.uiActions.hideContextMenu() }}
|
||||
/>
|
||||
</h4>
|
||||
|
||||
<section className="grid-wrapper no-top-padding">
|
||||
<AlbumGrid albums={artist.albums} />
|
||||
<LazyLoadListener
|
||||
loadKey={artist.albums_more}
|
||||
showLoader={artist.albums_more}
|
||||
loadMore={() => this.loadMore()}
|
||||
/>
|
||||
</section>
|
||||
</div> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
renderRelatedArtists(){
|
||||
var artist = helpers.collate(
|
||||
this.props.artist,
|
||||
{
|
||||
artists: this.props.artists
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="body related-artists">
|
||||
<section className="grid-wrapper no-top-padding">
|
||||
<ArtistGrid artists={artist.related_artists} />
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
renderAbout(){
|
||||
var artist = helpers.collate(
|
||||
this.props.artist,
|
||||
{
|
||||
artists: this.props.artists
|
||||
}
|
||||
);
|
||||
|
||||
var thumbnails = [];
|
||||
if (artist.images && artist.images.length > 0){
|
||||
for (var i = 0; i < artist.images.length; i++){
|
||||
thumbnails.push(
|
||||
<div className="tile thumbnail-wrapper" key={i}>
|
||||
<Thumbnail size="huge" canZoom images={artist.images[i]} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="body about">
|
||||
|
||||
<div className="col col--w40 tiles artist-stats">
|
||||
{thumbnails}
|
||||
{artist.followers ? <div className="tile"><span className="content"><Icon type="fontawesome" name="users" />{artist.followers.toLocaleString()} followers</span></div> : null}
|
||||
{artist.popularity ? <div className="tile"><span className="content"><Icon type="fontawesome" name="fire" />{artist.popularity }% popularity</span></div> : null}
|
||||
{artist.listeners ? <div className="tile"><span className="content"><Icon type="fontawesome" name="headphones" />{ artist.listeners.toLocaleString() } listeners</span></div> : null }
|
||||
</div>
|
||||
|
||||
<div className="col col--w60 biography">
|
||||
<section>
|
||||
{ artist.biography ? <div className="biography-text"><p>{artist.biography}</p><br />
|
||||
<div className="mid_grey-text">Published: { artist.biography_publish_date }</div>
|
||||
<div className="mid_grey-text">Origin: <a href={ artist.biography_link } target="_blank">{ artist.biography_link }</a></div></div> : null }
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
render(){
|
||||
@ -316,11 +317,49 @@ class Artist extends React.Component{
|
||||
{is_spotify ? <FollowButton uri={this.props.uri} removeText="Remove from library" addText="Add to library" is_following={this.inLibrary()} /> : null}
|
||||
<ContextMenuTrigger className="white" onTrigger={e => this.handleContextMenu(e)} />
|
||||
</div>
|
||||
{ this.renderSubViewMenu() }
|
||||
<div className="sub-views" id="sub-views-menu">
|
||||
<Link
|
||||
nav
|
||||
className="option"
|
||||
activeClassName="active"
|
||||
to={global.baseURL+'artist/'+this.props.uri+'/overview'}
|
||||
scrollTo="sub-views-menu">
|
||||
<h4>Overview</h4>
|
||||
</Link>
|
||||
{this.props.artist.related_artists_uris ? <Link
|
||||
nav
|
||||
className="option"
|
||||
activeClassName="active"
|
||||
to={global.baseURL+'artist/'+this.props.uri+'/related-artists'}
|
||||
scrollTo="sub-views-menu">
|
||||
<h4>Related artists</h4>
|
||||
</Link> : null}
|
||||
<Link
|
||||
nav
|
||||
className="option"
|
||||
activeClassName="active"
|
||||
to={global.baseURL+'artist/'+this.props.uri+'/about'}
|
||||
scrollTo="sub-views-menu">
|
||||
<h4>About</h4>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="content-wrapper">
|
||||
{this.renderBody()}
|
||||
<Switch>
|
||||
<Route exact path="/artist/:id/related-artists">
|
||||
{this.renderRelatedArtists()}
|
||||
</Route>
|
||||
<Route exact path="/artist/:id/about">
|
||||
{this.renderAbout()}
|
||||
</Route>
|
||||
<Route exact path="/artist/:id/overview">
|
||||
{this.renderOverview()}
|
||||
</Route>
|
||||
<Route>
|
||||
{this.renderOverview()}
|
||||
</Route>
|
||||
</Switch>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user