2016-07-07 23:23:18 +02:00
|
|
|
import React, { Component, PropTypes } from "react";
|
2016-07-29 23:57:21 +02:00
|
|
|
import CSSModules from "react-css-modules";
|
2016-07-07 23:23:18 +02:00
|
|
|
|
|
|
|
import { formatLength } from "../utils";
|
|
|
|
|
2016-07-29 23:57:21 +02:00
|
|
|
import css from "../styles/Album.scss";
|
|
|
|
|
2016-07-07 23:23:18 +02:00
|
|
|
export class AlbumTrackRow extends Component {
|
|
|
|
render () {
|
|
|
|
const length = formatLength(this.props.track.length);
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>{this.props.track.track}</td>
|
|
|
|
<td>{this.props.track.name}</td>
|
|
|
|
<td>{length}</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AlbumTrackRow.propTypes = {
|
|
|
|
track: PropTypes.object.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-07-30 01:05:25 +02:00
|
|
|
class AlbumTracksTableCSS extends Component {
|
2016-07-07 23:23:18 +02:00
|
|
|
render () {
|
|
|
|
var rows = [];
|
|
|
|
this.props.tracks.forEach(function (item) {
|
|
|
|
rows.push(<AlbumTrackRow track={item} key={item.id} />);
|
|
|
|
});
|
|
|
|
return (
|
2016-07-30 01:05:25 +02:00
|
|
|
<table className="table table-hover" styleName="songs">
|
2016-07-07 23:23:18 +02:00
|
|
|
<tbody>
|
|
|
|
{rows}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-30 01:05:25 +02:00
|
|
|
AlbumTracksTableCSS.propTypes = {
|
2016-07-07 23:23:18 +02:00
|
|
|
tracks: PropTypes.array.isRequired
|
|
|
|
};
|
|
|
|
|
2016-07-30 01:05:25 +02:00
|
|
|
export let AlbumTracksTable = CSSModules(AlbumTracksTableCSS, css);
|
|
|
|
|
2016-07-29 23:57:21 +02:00
|
|
|
class AlbumRowCSS extends Component {
|
2016-07-07 23:23:18 +02:00
|
|
|
render () {
|
|
|
|
return (
|
2016-07-29 23:57:21 +02:00
|
|
|
<div className="row" styleName="row">
|
|
|
|
<div className="col-sm-offset-2 col-xs-10" styleName="nameRow">
|
2016-07-27 13:51:30 +02:00
|
|
|
<h2>{this.props.album.name}</h2>
|
2016-07-07 23:23:18 +02:00
|
|
|
</div>
|
2016-07-29 23:57:21 +02:00
|
|
|
<div className="col-xs-2" styleName="artRow">
|
|
|
|
<p className="text-center"><img src={this.props.album.art} width="200" height="200" className="img-responsive img-circle" styleName="art" alt={this.props.album.name} /></p>
|
2016-07-27 13:51:30 +02:00
|
|
|
</div>
|
|
|
|
<div className="col-sm-10 table-responsive">
|
2016-07-29 23:57:21 +02:00
|
|
|
{
|
|
|
|
Array.isArray(this.props.album.tracks) ?
|
|
|
|
<AlbumTracksTable tracks={this.props.album.tracks} /> :
|
|
|
|
null
|
|
|
|
}
|
2016-07-07 23:23:18 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-29 23:57:21 +02:00
|
|
|
AlbumRowCSS.propTypes = {
|
2016-07-07 23:23:18 +02:00
|
|
|
album: PropTypes.object.isRequired
|
|
|
|
};
|
|
|
|
|
2016-07-29 23:57:21 +02:00
|
|
|
export let AlbumRow = CSSModules(AlbumRowCSS, css);
|
|
|
|
|
2016-07-07 23:23:18 +02:00
|
|
|
export default class Album extends Component {
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<AlbumRow album={this.props.album} />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Album.propTypes = {
|
|
|
|
album: PropTypes.object.isRequired
|
|
|
|
};
|