Cleaning up header and filter alignment

This commit is contained in:
James Barnsley
2019-10-09 09:42:20 +13:00
parent fe6ace5c62
commit 61d2939372
21 changed files with 7758 additions and 149 deletions

View File

@ -193,7 +193,7 @@ class Artist extends React.Component {
{artist.albums ? (
<div className="albums">
<h4>
Albums
<div>Albums</div>
<DropdownField
icon="sort"
name="Sort"
@ -209,12 +209,12 @@ class Artist extends React.Component {
options={filter_options}
handleChange={(value) => { this.setFilter(value); this.props.uiActions.hideContextMenu(); }}
/>
{this.props.sort || this.props.filter ? (
{(this.props.sort || this.props.filter) && (
<a className="button button--discrete button--small" onClick={(e) => { this.setFilter(null); this.setSort(null); }}>
<Icon name="clear" />
Reset
Reset
</a>
) : null}
)}
</h4>
<section className="grid-wrapper no-top-padding">
@ -301,53 +301,54 @@ Reset
<div className="col col--w40 tiles artist-stats">
{thumbnails}
{artist.followers ? (
<div className="tile">
<span className="content">
<Icon type="fontawesome" name={helpers.sourceIcon(artist.uri)} />
{`${helpers.titleCase(helpers.uriSource(artist.uri))} artist`}
</span>
</div>
{artist.followers && (
<div className="tile">
<span className="content">
<Icon type="fontawesome" name="users" />
{artist.followers.toLocaleString()}
{' '}
followers
{`${artist.followers.toLocaleString()} followers`}
</span>
</div>
) : null}
{artist.popularity ? (
)}
{artist.popularity && (
<div className="tile">
<span className="content">
<Icon type="fontawesome" name="fire" />
{artist.popularity }
% popularity
{`${artist.popularity} % popularity`}
</span>
</div>
) : null}
{artist.listeners ? (
)}
{artist.listeners && (
<div className="tile">
<span className="content">
<Icon type="fontawesome" name="headphones" />
{ artist.listeners.toLocaleString() }
{' '}
listeners
{`${artist.listeners.toLocaleString()} listeners`}
</span>
</div>
) : null }
)}
</div>
<div className="col col--w60 biography">
<section>
{ artist.biography ? (
<br />
{artist.biography && (
<div className="biography-text">
<p>{artist.biography}</p>
<br />
<div className="mid_grey-text">
Published:
{ artist.biography_publish_date }
{`Published: ${artist.biography_publish_date}`}
</div>
<div className="mid_grey-text">
Origin:
{`Origin: `}
<a href={artist.biography_link} target="_blank">{ artist.biography_link }</a>
</div>
</div>
) : null }
)}
</section>
</div>
</div>
@ -364,9 +365,7 @@ Origin:
return (
<ErrorMessage type="not-found" title="Not found">
<p>
Could not find artist with URI "
{encodeURIComponent(this.props.uri)}
"
{`Could not find artist with URI "${encodeURIComponent(this.props.uri)}"`}
</p>
</ErrorMessage>
);
@ -419,7 +418,7 @@ Could not find artist with URI "
>
<h4>Overview</h4>
</Link>
{this.props.artist.tracks_uris && this.props.artist.tracks_uris.length > 10 ? (
{this.props.artist.tracks_uris && this.props.artist.tracks_uris.length > 10 && (
<Link
exact
history={this.props.history}
@ -430,8 +429,8 @@ Could not find artist with URI "
>
<h4>Tracks</h4>
</Link>
) : null}
{this.props.artist.related_artists_uris ? (
)}
{this.props.artist.related_artists_uris && (
<Link
exact
history={this.props.history}
@ -442,7 +441,7 @@ Could not find artist with URI "
>
<h4>Related artists</h4>
</Link>
) : null}
)}
<Link
exact
history={this.props.history}

View File

@ -18,7 +18,7 @@ import * as mopidyActions from '../../services/mopidy/actions';
import * as googleActions from '../../services/google/actions';
import * as spotifyActions from '../../services/spotify/actions';
class LibraryAlbums extends React.Component {
class LibraryAlbums extends React.Component {
constructor(props) {
super(props);
@ -29,7 +29,7 @@ class LibraryAlbums extends React.Component {
};
}
componentWillMount() {
componentWillMount() {
// Before we mount, restore any limit defined in our location state
const state = (this.props.location.state ? this.props.location.state : {});
if (state.limit) {
@ -56,7 +56,7 @@ class LibraryAlbums extends React.Component {
}
componentWillReceiveProps(newProps) {
if (newProps.mopidy_connected && (newProps.source == 'all' || newProps.source == 'local')) {
if (newProps.mopidy_connected && (newProps.source == 'all' || newProps.source == 'local')) {
// We've just connected
if (!this.props.mopidy_connected) {
this.props.mopidyActions.getLibraryAlbums();
@ -68,7 +68,7 @@ class LibraryAlbums extends React.Component {
}
}
if (newProps.google_enabled && (newProps.source == 'all' || newProps.source == 'google')) {
if (newProps.google_enabled && (newProps.source == 'all' || newProps.source == 'google')) {
// We've just been enabled (or detected as such)
if (!this.props.google_enabled) {
this.props.googleActions.getLibraryAlbums();
@ -80,7 +80,7 @@ class LibraryAlbums extends React.Component {
}
}
if (newProps.spotify_enabled && (newProps.source == 'all' || newProps.source == 'spotify')) {
if (newProps.spotify_enabled && (newProps.source == 'all' || newProps.source == 'spotify')) {
// Filter changed, but we haven't got this provider's library yet
if (newProps.spotify_library_albums_status != 'finished' && newProps.spotify_library_albums_status != 'started') {
this.props.spotifyActions.getLibraryAlbums();
@ -151,7 +151,7 @@ class LibraryAlbums extends React.Component {
// Mopidy library items
if (this.props.mopidy_library_albums && (this.props.source == 'all' || this.props.source == 'local')) {
for (var uri of this.props.mopidy_library_albums) {
for (var uri of this.props.mopidy_library_albums) {
// Construct item placeholder. This is used as Mopidy needs to
// lookup ref objects to get the full object which can take some time
var source = helpers.uriSource(uri);
@ -162,13 +162,13 @@ class LibraryAlbums extends React.Component {
if (this.props.albums.hasOwnProperty(uri)) {
albums.push(this.props.albums[uri]);
}
}
}
}
// Google library items
if (this.props.google_library_albums && (this.props.source == 'all' || this.props.source == 'google')) {
for (var uri of this.props.google_library_albums) {
for (var uri of this.props.google_library_albums) {
// Construct item placeholder. This is used as Mopidy needs to
// lookup ref objects to get the full object which can take some time
var source = helpers.uriSource(uri);
@ -212,12 +212,12 @@ class LibraryAlbums extends React.Component {
details={['artists', 'tracks_uris.length']}
right_column={['added_at']}
className="albums"
link_prefix="/album/"
link_prefix="/album/"
/>
<LazyLoadListener
loadKey={total_albums > this.state.limit ? this.state.limit : total_albums}
showLoader={this.state.limit < total_albums}
loadMore={() => this.loadMore()}
loadMore={() => this.loadMore()}
/>
</section>
);
@ -226,15 +226,15 @@ class LibraryAlbums extends React.Component {
<section className="content-wrapper">
<AlbumGrid
handleContextMenu={(e, item) => this.handleContextMenu(e, item)}
albums={albums}
albums={albums}
/>
<LazyLoadListener
loadKey={total_albums > this.state.limit ? this.state.limit : total_albums}
showLoader={this.state.limit < total_albums}
loadMore={() => this.loadMore()}
loadMore={() => this.loadMore()}
/>
</section>
);
);
}
render() {
@ -305,7 +305,8 @@ class LibraryAlbums extends React.Component {
<span>
<FilterField
initialValue={this.state.filter}
handleChange={(value) => this.setState({ filter: value, limit: this.state.per_page })}
handleChange={(value) => this.setState({ filter: value, limit: this.state.per_page })}
onSubmit={e => this.props.uiActions.hideContextMenu()}
/>
<DropdownField
icon="sort"
@ -313,21 +314,21 @@ class LibraryAlbums extends React.Component {
value={this.props.sort}
options={sort_options}
selected_icon={this.props.sort ? (this.props.sort_reverse ? 'keyboard_arrow_up' : 'keyboard_arrow_down') : null}
handleChange={(val) => { this.setSort(val); this.props.uiActions.hideContextMenu(); }}
handleChange={(val) => { this.setSort(val); this.props.uiActions.hideContextMenu(); }}
/>
<DropdownField
icon="visibility"
name="View"
value={this.props.view}
options={view_options}
handleChange={(val) => { this.props.uiActions.set({ library_albums_view: val }); this.props.uiActions.hideContextMenu(); }}
handleChange={(val) => { this.props.uiActions.set({ library_albums_view: val }); this.props.uiActions.hideContextMenu(); }}
/>
<DropdownField
icon="cloud"
name="Source"
value={this.props.source}
options={source_options}
handleChange={(val) => { this.props.uiActions.set({ library_albums_source: val }); this.props.uiActions.hideContextMenu(); }}
handleChange={(val) => { this.props.uiActions.set({ library_albums_source: val }); this.props.uiActions.hideContextMenu(); }}
/>
</span>
);
@ -372,4 +373,4 @@ const mapDispatchToProps = (dispatch) => ({
spotifyActions: bindActionCreators(spotifyActions, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(LibraryAlbums);
export default connect(mapStateToProps, mapDispatchToProps)(LibraryAlbums);

View File

@ -18,7 +18,7 @@ import * as mopidyActions from '../../services/mopidy/actions';
import * as spotifyActions from '../../services/spotify/actions';
import * as googleActions from '../../services/google/actions';
class LibraryArtists extends React.Component {
class LibraryArtists extends React.Component {
constructor(props) {
super(props);
@ -29,7 +29,7 @@ class LibraryArtists extends React.Component {
};
}
componentWillMount() {
componentWillMount() {
// Before we mount, restore any limit defined in our location state
const state = (this.props.location.state ? this.props.location.state : {});
if (state.limit) {
@ -56,7 +56,7 @@ class LibraryArtists extends React.Component {
}
componentWillReceiveProps(newProps) {
if (newProps.mopidy_connected && (newProps.source == 'all' || newProps.source == 'local')) {
if (newProps.mopidy_connected && (newProps.source == 'all' || newProps.source == 'local')) {
// We've just connected
if (!this.props.mopidy_connected) {
this.props.mopidyActions.getLibraryArtists();
@ -68,7 +68,7 @@ class LibraryArtists extends React.Component {
}
}
if (newProps.mopidy_connected && newProps.google_enabled && (newProps.source == 'all' || newProps.source == 'google')) {
if (newProps.mopidy_connected && newProps.google_enabled && (newProps.source == 'all' || newProps.source == 'google')) {
// We've just been enabled (or detected as such)
if (!this.props.google_enabled) {
this.props.googleActions.getLibraryArtists();
@ -80,7 +80,7 @@ class LibraryArtists extends React.Component {
}
}
if (newProps.spotify_enabled && (newProps.source == 'all' || newProps.source == 'spotify')) {
if (newProps.spotify_enabled && (newProps.source == 'all' || newProps.source == 'spotify')) {
// Filter changed, but we haven't got this provider's library yet
if (newProps.spotify_library_artists_status != 'finished' && newProps.spotify_library_artists_status != 'started') {
this.props.spotifyActions.getLibraryArtists();
@ -125,7 +125,7 @@ class LibraryArtists extends React.Component {
// Mopidy library items
if (this.props.mopidy_library_artists && (this.props.source == 'all' || this.props.source == 'local')) {
for (uri of this.props.mopidy_library_artists) {
for (uri of this.props.mopidy_library_artists) {
// Construct item placeholder. This is used as Mopidy needs to
// lookup ref objects to get the full object which can take some time
var source = helpers.uriSource(uri);
@ -144,7 +144,7 @@ class LibraryArtists extends React.Component {
// Google library items
if (this.props.google_library_artists && (this.props.source == 'all' || this.props.source == 'google')) {
for (uri of this.props.google_library_artists) {
for (uri of this.props.google_library_artists) {
// Construct item placeholder. This is used as Mopidy needs to
// lookup ref objects to get the full object which can take some time
var source = helpers.uriSource(uri);
@ -193,12 +193,12 @@ class LibraryArtists extends React.Component {
details={['followers']}
middle_column={['source']}
className="artists"
link_prefix="/artist/"
link_prefix="/artist/"
/>
<LazyLoadListener
loadKey={total_artists > this.state.limit ? this.state.limit : total_artists}
showLoader={this.state.limit < total_artists}
loadMore={() => this.loadMore()}
loadMore={() => this.loadMore()}
/>
</section>
);
@ -207,15 +207,15 @@ class LibraryArtists extends React.Component {
<section className="content-wrapper">
<ArtistGrid
handleContextMenu={(e, item) => this.handleContextMenu(e, item)}
artists={artists}
artists={artists}
/>
<LazyLoadListener
loadKey={total_artists > this.state.limit ? this.state.limit : total_artists}
showLoader={this.state.limit < total_artists}
loadMore={() => this.loadMore()}
loadMore={() => this.loadMore()}
/>
</section>
);
);
}
render() {
@ -278,7 +278,8 @@ class LibraryArtists extends React.Component {
<span>
<FilterField
initialValue={this.state.filter}
handleChange={(value) => this.setState({ filter: value, limit: this.state.per_page })}
handleChange={(value) => this.setState({ filter: value, limit: this.state.per_page })}
onSubmit={e => this.props.uiActions.hideContextMenu()}
/>
<DropdownField
icon="sort"
@ -286,21 +287,21 @@ class LibraryArtists extends React.Component {
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(); }}
handleChange={(value) => { this.setSort(value); this.props.uiActions.hideContextMenu(); }}
/>
<DropdownField
icon="visibility"
name="View"
value={this.props.view}
options={view_options}
handleChange={(value) => { this.props.uiActions.set({ library_artists_view: value }); this.props.uiActions.hideContextMenu(); }}
handleChange={(value) => { this.props.uiActions.set({ library_artists_view: value }); this.props.uiActions.hideContextMenu(); }}
/>
<DropdownField
icon="cloud"
name="Source"
value={this.props.source}
options={source_options}
handleChange={(value) => { this.props.uiActions.set({ library_artists_source: value }); this.props.uiActions.hideContextMenu(); }}
handleChange={(value) => { this.props.uiActions.set({ library_artists_source: value }); this.props.uiActions.hideContextMenu(); }}
/>
</span>
);
@ -347,4 +348,4 @@ const mapDispatchToProps = (dispatch) => ({
googleActions: bindActionCreators(googleActions, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(LibraryArtists);
export default connect(mapStateToProps, mapDispatchToProps)(LibraryArtists);

View File

@ -18,7 +18,7 @@ import * as uiActions from '../../services/ui/actions';
import * as mopidyActions from '../../services/mopidy/actions';
import * as spotifyActions from '../../services/spotify/actions';
class LibraryPlaylists extends React.Component {
class LibraryPlaylists extends React.Component {
constructor(props) {
super(props);
@ -29,7 +29,7 @@ class LibraryPlaylists extends React.Component {
};
}
componentWillMount() {
componentWillMount() {
// Before we mount, restore any limit defined in our location state
const state = (this.props.location.state ? this.props.location.state : {});
if (state.limit) {
@ -51,8 +51,8 @@ class LibraryPlaylists extends React.Component {
}
}
componentWillReceiveProps(newProps) {
if (newProps.mopidy_connected && (newProps.source == 'all' || newProps.source == 'local')) {
componentWillReceiveProps(newProps) {
if (newProps.mopidy_connected && (newProps.source == 'all' || newProps.source == 'local')) {
// We've just connected
if (!this.props.mopidy_connected) {
this.props.mopidyActions.getLibraryPlaylists();
@ -64,7 +64,7 @@ class LibraryPlaylists extends React.Component {
}
}
if (newProps.spotify_enabled && (newProps.source == 'all' || newProps.source == 'spotify')) {
if (newProps.spotify_enabled && (newProps.source == 'all' || newProps.source == 'spotify')) {
// Filter changed, but we haven't got this provider's library yet
if (newProps.spotify_library_playlists_status != 'finished' && newProps.spotify_library_playlists_status != 'started') {
this.props.spotifyActions.getLibraryPlaylists();
@ -150,12 +150,12 @@ class LibraryPlaylists extends React.Component {
details={['owner', 'tracks_total']}
right_column={['source']}
className="playlists"
link_prefix="/playlist/"
link_prefix="/playlist/"
/>
<LazyLoadListener
loadKey={total_playlists > this.state.limit ? this.state.limit : total_playlists}
loading={this.state.limit < total_playlists}
loadMore={() => this.loadMore()}
loadMore={() => this.loadMore()}
/>
</section>
);
@ -164,15 +164,15 @@ class LibraryPlaylists extends React.Component {
<section className="content-wrapper">
<PlaylistGrid
handleContextMenu={(e, item) => this.handleContextMenu(e, item)}
playlists={playlists}
playlists={playlists}
/>
<LazyLoadListener
loadKey={total_playlists > this.state.limit ? this.state.limit : total_playlists}
loading={this.state.limit < total_playlists}
loadMore={() => this.loadMore()}
loadMore={() => this.loadMore()}
/>
</section>
);
);
}
render() {
@ -236,7 +236,8 @@ class LibraryPlaylists extends React.Component {
<span>
<FilterField
initialValue={this.state.filter}
handleChange={(value) => this.setState({ filter: value })}
handleChange={(value) => this.setState({ filter: value })}
onSubmit={e => this.props.uiActions.hideContextMenu()}
/>
<DropdownField
icon="sort"
@ -244,25 +245,25 @@ class LibraryPlaylists extends React.Component {
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(); }}
handleChange={(value) => { this.setSort(value); this.props.uiActions.hideContextMenu(); }}
/>
<DropdownField
icon="visibility"
name="View"
value={this.props.view}
options={view_options}
handleChange={(value) => { this.props.uiActions.set({ library_playlists_view: value }); this.props.uiActions.hideContextMenu(); }}
handleChange={(value) => { this.props.uiActions.set({ library_playlists_view: value }); this.props.uiActions.hideContextMenu(); }}
/>
<DropdownField
icon="cloud"
name="Source"
value={this.props.source}
options={source_options}
handleChange={(value) => { this.props.uiActions.set({ library_playlists_source: value }); this.props.uiActions.hideContextMenu(); }}
handleChange={(value) => { this.props.uiActions.set({ library_playlists_source: value }); this.props.uiActions.hideContextMenu(); }}
/>
<Link className="button button--no-hover" to="/playlist/create">
<Icon name="add_box" />
New
<Icon name="add_box" />
New
</Link>
</span>
);
@ -304,4 +305,4 @@ const mapDispatchToProps = (dispatch) => ({
spotifyActions: bindActionCreators(spotifyActions, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(LibraryPlaylists);
export default connect(mapStateToProps, mapDispatchToProps)(LibraryPlaylists);