CoverFlow.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import React, { Component } from 'react';
  2. import '../css/CoverFlow.css'
  3. import CoverFlowItem from './CoverFlowItem'
  4. import Coverflow from 'react-coverflow'
  5. import PropTypes from 'prop-types'
  6. import { connect } from 'react-redux'
  7. import { fetchNew } from '../actions/songListActions'
  8. class CoverFlow extends Component {
  9. componentWillMount() {
  10. this.props.fetchNew()
  11. }
  12. render() {
  13. return (
  14. <Coverflow width="985" height="500"
  15. displayQuantityOfSide={ 2 }
  16. navigation={ true }
  17. enableScroll={ true }
  18. clickable={ true }
  19. active="middle"
  20. >
  21. {this.props.songs.map((song, index) => {
  22. return <CoverFlowItem key={ index } title={ song.songName } artist={ song.authorName } uploader={ song.uploader } coverImage={ song.coverUrl } />
  23. })}
  24. </Coverflow>
  25. )
  26. }
  27. }
  28. CoverFlow.propTypes = {
  29. songs: PropTypes.array.isRequired,
  30. fetchNew: PropTypes.func.isRequired
  31. }
  32. const mapStateToProps = state => ({
  33. songs: state.songs
  34. })
  35. export default connect(mapStateToProps, { fetchNew })(CoverFlow)