Popularity component

This commit is contained in:
James Barnsley
2018-06-15 19:58:17 +12:00
parent b72c77f4f8
commit 801b132f48
11 changed files with 211 additions and 20 deletions

27
src/js/components/Popularity.js Executable file
View File

@ -0,0 +1,27 @@
import React from 'react'
import Icon from './Icon'
import * as helpers from '../helpers'
export default class Popularity extends React.Component{
constructor(props){
super(props)
}
render(){
if (this.props.popularity === undefined || this.props.popularity === null){
return null;
}
return (
<span className="popularity-diagram">
<span className={"bar"+(this.props.popularity > 10 ? " filled" : "")}></span>
<span className={"bar"+(this.props.popularity > 30 ? " filled" : "")}></span>
<span className={"bar"+(this.props.popularity > 50 ? " filled" : "")}></span>
<span className={"bar"+(this.props.popularity > 70 ? " filled" : "")}></span>
<span className={"bar"+(this.props.popularity > 90 ? " filled" : "")}></span>
</span>
);
}
}

View File

@ -7,6 +7,7 @@ import ArtistSentence from './ArtistSentence'
import Dater from './Dater'
import URILink from './URILink'
import ContextMenuTrigger from './ContextMenuTrigger'
import Popularity from './Popularity'
import * as helpers from '../helpers'
@ -311,6 +312,11 @@ export default class Track extends React.Component{
{track.duration ? <Dater type="length" data={track.duration} /> : '-'}
</span>
)
track_columns.push(
<span className="col popularity" key="popularity">
<Popularity popularity={track.popularity} />
</span>
)
}
track_actions.push(
@ -338,10 +344,8 @@ export default class Track extends React.Component{
onMouseDown={e => this.handleMouseDown(e)}
onMouseUp={e => this.handleMouseUp(e)}
onMouseMove={e => this.handleMouseMove(e)}
onDoubleClick={e => this.handleDoubleClick(e)}
onContextMenu={e => this.props.handleContextMenu(e)}
onTouchStart={e => this.handleTouchStart(e)}
onTouchEnd={e => this.handleTouchEnd(e)}>
{track_actions}

View File

@ -423,6 +423,7 @@ class TrackList extends React.Component{
<span className="col artists">Artists</span>
<span className="col album">Album</span>
<span className="col duration">Duration</span>
<span className="col popularity"></span>
</div>
</div>
)