From 5c765c4318a357d8663ab1e4885e07ce93af45ce Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Wed, 23 Nov 2016 13:17:07 +1300 Subject: [PATCH] Artist sub-views started --- src/js/components/Parallax.js | 20 ++++--- src/js/views/Artist.js | 101 +++++++++++++++++++++++++--------- src/scss/views/_artist.scss | 73 ++++++++++++++++++++---- 3 files changed, 149 insertions(+), 45 deletions(-) diff --git a/src/js/components/Parallax.js b/src/js/components/Parallax.js index 88bff46f..4d9913d6 100755 --- a/src/js/components/Parallax.js +++ b/src/js/components/Parallax.js @@ -45,15 +45,17 @@ export default class Parallax extends React.Component{ } componentWillReceiveProps( nextProps ){ - var url = helpers.sizedImages( nextProps.images ).huge; - this.setState({ url: url, image: false, loaded: false }) - this.loadImage( url ) - .then( - response => { - this.setState({ url: url, image: response, loaded: true }) - this.updateCanvas( response ) - } - ) + if( nextProps.images.length != this.props.images.length ){ + var url = helpers.sizedImages( nextProps.images ).huge; + this.setState({ url: url, image: false, loaded: false }) + this.loadImage( url ) + .then( + response => { + this.setState({ url: url, image: response, loaded: true }) + this.updateCanvas( response ) + } + ) + } } handleResize(e){ diff --git a/src/js/views/Artist.js b/src/js/views/Artist.js index 906f68a2..ec3cca48 100755 --- a/src/js/views/Artist.js +++ b/src/js/views/Artist.js @@ -11,6 +11,7 @@ import AlbumGrid from '../components/AlbumGrid' import Thumbnail from '../components/Thumbnail' import Parallax from '../components/Parallax' import ArtistList from '../components/ArtistList' +import ArtistGrid from '../components/ArtistGrid' import FollowButton from '../components/FollowButton' import * as helpers from '../helpers' @@ -21,7 +22,11 @@ import * as spotifyActions from '../services/spotify/actions' class Artist extends React.Component{ constructor(props) { - super(props); + super(props) + + this.state = { + sub_view: 'overview' + } } componentDidMount(){ @@ -56,35 +61,38 @@ class Artist extends React.Component{ alert('Yet to be implemented') } - render(){ - if( !this.props.artist ) return null - var scheme = helpers.uriSource( this.props.params.uri ); - + renderSubViewMenu(){ return ( -
- +
+ this.setState({ sub_view: 'overview' })}> + Overview + + this.setState({ sub_view: 'related_artists' })}> + Related artists + + this.setState({ sub_view: 'biography' })}> + Biography + +
+ ) + } -
- - - -

{ this.props.artist.name }

- -
- - { helpers.uriSource(this.props.params.uri) == 'spotify' ? : null } -
- -
    - { this.props.artist.followers ?
  • { this.props.artist.followers.total.toLocaleString() } followers
  • : null } - { this.props.artist.popularity ?
  • { this.props.artist.popularity }% popularity
  • : null } - { scheme == 'local' ?
  • { this.props.artist.albums.length.toLocaleString() } albums
  • : null } - { scheme == 'spotify' ?
  • Spotify artist
  • : null } - { scheme == 'local' ?
  • Local artist
  • : null } -
+ renderBody(){ + if( this.state.sub_view == 'related_artists' ){ + return ( +
+

Related artists

+
+ { this.props.artist.related_artists ? : null } +
+ ) + } + // default body + return ( +

Top tracks

{ this.props.artist.tracks ? : null } @@ -105,6 +113,49 @@ class Artist extends React.Component{ this.loadMore() }/>
+ ) + } + + render(){ + if( !this.props.artist ) return null + var scheme = helpers.uriSource( this.props.params.uri ); + + return ( +
+ +
+ + + + +
+
+

{ this.props.artist.name }

+ { this.renderSubViewMenu() } +
+
+ +
+ +
+ + { helpers.uriSource(this.props.params.uri) == 'spotify' ? : null } +
+ +
    + { this.props.artist.followers ?
  • { this.props.artist.followers.total.toLocaleString() } followers
  • : null } + { this.props.artist.popularity ?
  • { this.props.artist.popularity }% popularity
  • : null } + { scheme == 'local' ?
  • { this.props.artist.albums.length.toLocaleString() } albums
  • : null } + { scheme == 'spotify' ?
  • Spotify artist
  • : null } + { scheme == 'local' ?
  • Local artist
  • : null } +
+ +
+
+ + { this.renderBody() } + +
); } } diff --git a/src/scss/views/_artist.scss b/src/scss/views/_artist.scss index 018ce188..0285b83f 100755 --- a/src/scss/views/_artist.scss +++ b/src/scss/views/_artist.scss @@ -2,25 +2,76 @@ .artist-view { .intro { position: relative; - margin: -100px 0 20px 0; @include clearfix; + margin-bottom: 40px; + + .parallax { + position: absolute; + z-index: 0; + top: 0; + right: 0; + bottom: 0; + left: 0; + } .thumbnail { - max-width: 200px; - margin: 0 20px 0 40px; - float: left; + position: absolute; + z-index: 2; + max-width: 240px; + bottom: 0; + left: 40px; } - h1 { - color: #FFFFFF; - padding-top: 30px; - padding-bottom: 45px; + .heading-wrapper { + height: 50vh; + position: relative; + z-index: 2; + + .heading { + position: absolute; + bottom: 0; + left: 305px; + + h1 { + color: #FFFFFF; + padding-top: 30px; + padding-bottom: 10px; + } + + .sub-views { + color: #FFFFFF; + font-size: 16px; + font-weight: 400; + + .option { + display: inline-block; + padding: 8px 0; + margin-right: 20px; + border-bottom: 3px solid transparent; + cursor: pointer; + + &.active { + border-color: #FFFFFF; + } + + &:not(.active):hover { + border-color: rgba(255,255,255,0.2); + } + } + } + } } - .actions { - float: left; - margin-right: 20px; + .details-wrapper { + padding-left: 305px; + padding-top: 20px; + + .actions { + float: left; + margin-right: 20px; + } } + } .artist-list {