// NPM import import React, { Component, PropTypes } from "react"; import CSSModules from "react-css-modules"; import { defineMessages, FormattedMessage, injectIntl, intlShape } from "react-intl"; import FontAwesome from "react-fontawesome"; import Immutable from "immutable"; // Local imports import { formatLength, messagesMap } from "../utils"; // Translations import commonMessages from "../locales/messagesDescriptors/common"; // Styles import css from "../styles/Album.scss"; // Set translations const albumMessages = defineMessages(messagesMap(Array.concat([], commonMessages))); /** * Track row in an album tracks table. */ class AlbumTrackRowCSSIntl extends Component { constructor(props) { super(props); // Bind this this.onPlayClick = this.onPlayClick.bind(this); this.onPlayNextClick = this.onPlayNextClick.bind(this); } /** * Handle click on play button. */ onPlayClick() { $(this.refs.play).blur(); this.props.playAction(this.props.track.get("id")); } /** * Handle click on play next button. */ onPlayNextClick() { $(this.refs.playNext).blur(); this.props.playNextAction(this.props.track.get("id")); } render() { const { formatMessage } = this.props.intl; const length = formatLength(this.props.track.get("time")); return (   {this.props.track.get("track")} {this.props.track.get("name")} {length} ); } } AlbumTrackRowCSSIntl.propTypes = { playAction: PropTypes.func.isRequired, playNextAction: PropTypes.func.isRequired, track: PropTypes.instanceOf(Immutable.Map).isRequired, intl: intlShape.isRequired, }; export let AlbumTrackRow = injectIntl(CSSModules(AlbumTrackRowCSSIntl, css)); /** * Tracks table of an album. */ class AlbumTracksTableCSS extends Component { render() { let rows = []; // Build rows for each track const { playAction, playNextAction } = this.props; this.props.tracks.forEach(function (item) { rows.push(); }); return ( {rows}
); } } AlbumTracksTableCSS.propTypes = { playAction: PropTypes.func.isRequired, playNextAction: PropTypes.func.isRequired, tracks: PropTypes.instanceOf(Immutable.List).isRequired, }; export let AlbumTracksTable = CSSModules(AlbumTracksTableCSS, css); /** * An entire album row containing art and tracks table. */ class AlbumRowCSS extends Component { render() { return (

{this.props.album.get("name")}

{this.props.album.get("name")}

{ this.props.songs.size > 0 ? : null }
); } } AlbumRowCSS.propTypes = { playAction: PropTypes.func.isRequired, playNextAction: PropTypes.func.isRequired, album: PropTypes.instanceOf(Immutable.Map).isRequired, songs: PropTypes.instanceOf(Immutable.List).isRequired, }; export let AlbumRow = CSSModules(AlbumRowCSS, css);