Discover sections

This commit is contained in:
James Barnsley
2016-10-26 16:55:47 +13:00
parent 737ed9d09d
commit 47b6009ec3
26 changed files with 500 additions and 64 deletions

View File

@ -30,7 +30,7 @@ class Album extends React.Component{
render(){
if( this.props.spotify.album ){
return (
<div>
<div className="view album-view">
<Header
icon="cd"
title={ this.props.spotify.album.name }

View File

@ -33,7 +33,7 @@ class Artist extends React.Component{
render(){
if( this.props.spotify.artist ){
return (
<div>
<div className="view artist-view">
<Parallax images={ this.props.spotify.artist.images } />
<div className="intro">
@ -49,11 +49,13 @@ class Artist extends React.Component{
<div className="col w5"></div>
<div className="col w25 cf">
<div className="col w25">
<h3>Related artists</h3>
{ this.props.spotify.artist.related_artists ? <ArtistList artists={ this.props.spotify.artist.related_artists.slice(0,6) } /> : null }
</div>
<div className="cf"></div>
<h3 className="left-padding">Albums</h3>
{ this.props.spotify.artist_albums ? <AlbumGrid className="no-top-padding" albums={ this.props.spotify.artist_albums.items } /> : null }
</div>

View File

@ -30,7 +30,7 @@ class Playlist extends React.Component{
render(){
if( this.props.spotify.playlist ){
return (
<div>
<div className="view playlist-view">
<Header icon="playlist" title={ this.props.spotify.playlist.name } />
<TrackList tracks={this.props.spotify.playlist.tracks.items} />
</div>

View File

@ -61,7 +61,7 @@ class Queue extends React.Component{
render(){
return (
<div>
<div className="view queue-view">
<Header
icon="play"
title="Now playing"

View File

@ -40,7 +40,7 @@ class Settings extends React.Component{
render(){
return (
<div>
<div className="view settings-view">
<Header
icon="cog"
title="Settings"

View File

@ -0,0 +1,58 @@
import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import Header from '../../components/Header'
import * as spotifyActions from '../../services/spotify/actions'
class Discover extends React.Component{
constructor(props) {
super(props);
}
// on render
componentDidMount(){
this.props.spotifyActions.getPlaylist( this.props.params.uri );
}
// when props changed
componentWillReceiveProps( nextProps ){
if( nextProps.params.uri != this.props.params.uri ){
this.props.spotifyActions.getPlaylist( nextProps.params.uri );
}
}
render(){
if( this.props.spotify.playlist ){
return (
<div className="view discover-view">
<Header icon="compass" title="Discover" />
<h1>To come</h1>
</div>
);
}
return null;
}
}
/**
* Export our component
*
* We also integrate our global store, using connect()
**/
const mapStateToProps = (state, ownProps) => {
return state;
}
const mapDispatchToProps = (dispatch) => {
return {
spotifyActions: bindActionCreators(spotifyActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(Discover)

View File

@ -0,0 +1,49 @@
import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import Header from '../../components/Header'
import CategoryGrid from '../../components/CategoryGrid'
import * as spotifyActions from '../../services/spotify/actions'
class DiscoverCategories extends React.Component{
constructor(props) {
super(props);
}
// on render
componentDidMount(){
this.props.spotifyActions.getCategories();
}
render(){
return (
<div className="view discover-categories-view">
<Header icon="grid" title="Genre / Mood" />
{ this.props.spotify.categories ? <CategoryGrid categories={this.props.spotify.categories.items} /> : null }
</div>
);
}
}
/**
* Export our component
*
* We also integrate our global store, using connect()
**/
const mapStateToProps = (state, ownProps) => {
return state;
}
const mapDispatchToProps = (dispatch) => {
return {
spotifyActions: bindActionCreators(spotifyActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverCategories)

View File

@ -0,0 +1,58 @@
import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import Header from '../../components/Header'
import PlaylistGrid from '../../components/PlaylistGrid'
import * as spotifyActions from '../../services/spotify/actions'
class DiscoverCategory extends React.Component{
constructor(props) {
super(props);
}
componentDidMount(){
this.props.spotifyActions.getCategory( this.props.params.id );
this.props.spotifyActions.getCategoryPlaylists( this.props.params.id );
}
componentWillReceiveProps( nextProps ){
if( nextProps.params.id != this.props.params.id ){
this.props.spotifyActions.getCategory( nextProps.params.id );
this.props.spotifyActions.getCategoryPlaylists( nextProps.params.id );
}
}
render(){
if( !this.props.spotify.category ) return null;
return (
<div className="view discover-categories-view">
<Header icon="grid" title={this.props.spotify.category.name} />
{ this.props.spotify.category_playlists ? <PlaylistGrid playlists={this.props.spotify.category_playlists.items} /> : null }
</div>
);
}
}
/**
* Export our component
*
* We also integrate our global store, using connect()
**/
const mapStateToProps = (state, ownProps) => {
return state;
}
const mapDispatchToProps = (dispatch) => {
return {
spotifyActions: bindActionCreators(spotifyActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverCategory)

View File

@ -0,0 +1,49 @@
import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import Header from '../../components/Header'
import PlaylistGrid from '../../components/PlaylistGrid'
import * as spotifyActions from '../../services/spotify/actions'
class DiscoverFeatured extends React.Component{
constructor(props) {
super(props);
}
// on render
componentDidMount(){
this.props.spotifyActions.getFeaturedPlaylists();
}
render(){
return (
<div className="view discover-featured-view">
<Header icon="star" title="Featured playlists" />
{ this.props.spotify.featuredPlaylists ? <PlaylistGrid playlists={this.props.spotify.featuredPlaylists.playlists.items} /> : null }
</div>
);
}
}
/**
* Export our component
*
* We also integrate our global store, using connect()
**/
const mapStateToProps = (state, ownProps) => {
return state;
}
const mapDispatchToProps = (dispatch) => {
return {
spotifyActions: bindActionCreators(spotifyActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverFeatured)

View File

@ -22,18 +22,15 @@ class LibraryAlbums extends React.Component{
}
render(){
if( this.props.spotify.libraryAlbums ){
return (
<div>
<Header
icon="cd"
title="My albums"
/>
<AlbumGrid albums={this.props.spotify.libraryAlbums.items} />
</div>
);
}
return null;
return (
<div className="view library-albums-view">
<Header
icon="cd"
title="My albums"
/>
{ this.props.spotify.library_albums ? <AlbumGrid albums={this.props.spotify.library_albums.items} /> : null }
</div>
);
}
}

View File

@ -22,18 +22,15 @@ class LibraryArtists extends React.Component{
}
render(){
if( this.props.spotify.libraryArtists ){
return (
<div>
<Header
icon="mic"
title="My artists"
/>
<ArtistGrid artists={this.props.spotify.libraryArtists.artists.items} />
</div>
);
}
return null;
return (
<div className="view library-artists-view">
<Header
icon="mic"
title="My artists"
/>
{ this.props.spotify.library_artists ? <ArtistGrid artists={this.props.spotify.library_artists.artists.items} /> : null }
</div>
);
}
}

View File

@ -37,8 +37,8 @@ class LibraryPlaylists extends React.Component{
Object.assign(playlists, this.props.mopidy.playlists)
}
if( this.props.spotify.libraryPlaylists ){
Object.assign(playlists, this.props.spotify.libraryPlaylists.items)
if( this.props.spotify.library_playlists ){
Object.assign(playlists, this.props.spotify.library_playlists.items)
}
return playlists;
@ -67,7 +67,7 @@ class LibraryPlaylists extends React.Component{
render(){
return (
<div>
<div className="view library-playlists-view">
<Header
icon="playlist"
title="My playlists"

View File

@ -22,15 +22,12 @@ class LibraryTracks extends React.Component{
}
render(){
if( this.props.spotify.libraryTracks ){
return (
<div>
<Header icon="music" title="My tracks" />
<TrackList tracks={this.props.spotify.libraryTracks.items} />
</div>
);
}
return null;
return (
<div className="view library-tracks-view">
<Header icon="music" title="My tracks" />
{ this.props.spotify.library_tracks ? <TrackList tracks={this.props.spotify.library_tracks.items} /> : null }
</div>
);
}
}