diff --git a/songs-redux/src/components/App.js b/songs-redux/src/components/App.js index d97371e..83d45f2 100644 --- a/songs-redux/src/components/App.js +++ b/songs-redux/src/components/App.js @@ -1,9 +1,19 @@ import React from 'react'; +import SongsList from './SongsList'; +import SongDetail from './SongDetails'; + const App = () => { return ( -
- App +
+
+
+ +
+
+ +
+
) } diff --git a/songs-redux/src/components/SongDetails.js b/songs-redux/src/components/SongDetails.js new file mode 100644 index 0000000..5d08702 --- /dev/null +++ b/songs-redux/src/components/SongDetails.js @@ -0,0 +1,34 @@ +import React from 'react'; +import { connect } from 'react-redux'; + +const SongDetail = (props) => { + if (props.selected) { + return ( +
+
+
Song Details:
+
+
+

Title : {props.selected.title}

+
+
+
+
+ An Umm-Kalthoum Song with A duration of { props.selected.duration } +
+
+
+
+
+
+ ); + } + + return
Select A song to get its details.
+} + +const mapStateToProps = state => { + return { selected: state.selectedSong } +} + +export default connect(mapStateToProps)(SongDetail); \ No newline at end of file diff --git a/songs-redux/src/components/SongsList.js b/songs-redux/src/components/SongsList.js new file mode 100644 index 0000000..70e9e44 --- /dev/null +++ b/songs-redux/src/components/SongsList.js @@ -0,0 +1,37 @@ +import React from 'react'; +import { connect } from 'react-redux'; +import { selectSong } from '../actions'; +class SongsList extends React.Component { + + render () { + console.log(" > render") + const renderedList = this.props.songs.map(s => { + return ( +
+
+ +
+
+ {s.title} +
+
+ ) + }) + return ( +
+ {renderedList} +
+ ) + } +} + +const mapStateToProps = state => { + return { songs: state.songs }; +} + +export default connect(mapStateToProps, { selectSong })(SongsList); \ No newline at end of file