Skip to content

Commit

Permalink
format components
Browse files Browse the repository at this point in the history
  • Loading branch information
Pau1fitz committed Jan 31, 2020
1 parent 2d914df commit 442baea
Show file tree
Hide file tree
Showing 17 changed files with 336 additions and 277 deletions.
8 changes: 4 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@ class App extends Component {
pauseSong={this.pauseSong}
resumeSong={this.resumeSong}
audioControl={this.audioControl}
/>{" "}
</div>{" "}
/>
</div>
</div>
<Footer
stopSong={this.stopSong}
pauseSong={this.pauseSong}
resumeSong={this.resumeSong}
audioControl={this.audioControl}
/>{" "}
</div>{" "}
/>
</div>
</div>
);
}
Expand Down
4 changes: 1 addition & 3 deletions src/components/AlbumList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import uniqBy from "lodash/uniqBy";

const mapStateToProps = state => {
const albumSongs = state.songsReducer.songs
? uniqBy(state.songsReducer.songs, item => {
return item.track.album.name;
})
? uniqBy(state.songsReducer.songs, item => item.track.album.name)
: "";

return {
Expand Down
8 changes: 4 additions & 4 deletions src/components/ArtWork/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import SongControls from "./component";
import { connect } from "react-redux";

const mapStateToProps = (state) => {

const mapStateToProps = state => {
return {
albumImage: state.songsReducer.songDetails ? state.songsReducer.songDetails.album.images[0].url : ''
albumImage: state.songsReducer.songDetails
? state.songsReducer.songDetails.album.images[0].url
: ""
};

};

export default connect(mapStateToProps)(SongControls);
29 changes: 15 additions & 14 deletions src/components/ArtistList/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import AlbumList from "./component";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import { fetchArtistSongs } from '../../actions/artistActions';
import { updateHeaderTitle } from '../../actions/uiActions';

const mapStateToProps = (state) => {
import { fetchArtistSongs } from "../../actions/artistActions";
import { updateHeaderTitle } from "../../actions/uiActions";

const mapStateToProps = state => {
return {
token: state.tokenReducer.token ? state.tokenReducer.token : '',
artists: state.artistsReducer.artistList ? state.artistsReducer.artistList.artists : ''
token: state.tokenReducer.token ? state.tokenReducer.token : "",
artists: state.artistsReducer.artistList
? state.artistsReducer.artistList.artists
: ""
};

};

const mapDispatchToProps = (dispatch) => {

return bindActionCreators({
fetchArtistSongs,
updateHeaderTitle
}, dispatch);

const mapDispatchToProps = dispatch => {
return bindActionCreators(
{
fetchArtistSongs,
updateHeaderTitle
},
dispatch
);
};

export default connect(mapStateToProps, mapDispatchToProps)(AlbumList);
28 changes: 15 additions & 13 deletions src/components/BrowseView/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
import BrowseView from "./component";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import { fetchPlaylistSongs, addPlaylistItem } from '../../actions/playlistActions';
import { updateHeaderTitle } from '../../actions/uiActions';

const mapStateToProps = (state) => {
import {
fetchPlaylistSongs,
addPlaylistItem
} from "../../actions/playlistActions";
import { updateHeaderTitle } from "../../actions/uiActions";

const mapStateToProps = state => {
return {
view: state.browseReducer.view,
viewType: state.songsReducer.viewType,
token: state.tokenReducer.token
};

};

const mapDispatchToProps = (dispatch) => {

return bindActionCreators({
fetchPlaylistSongs,
updateHeaderTitle,
addPlaylistItem
}, dispatch);

const mapDispatchToProps = dispatch => {
return bindActionCreators(
{
fetchPlaylistSongs,
updateHeaderTitle,
addPlaylistItem
},
dispatch
);
};

export default connect(mapStateToProps, mapDispatchToProps)(BrowseView);
24 changes: 12 additions & 12 deletions src/components/Footer/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import SongControls from '../SongControls';
import VolumeControls from '../VolumeControls';
import './Footer.css';
import React from "react";
import PropTypes from "prop-types";
import SongControls from "../SongControls";
import VolumeControls from "../VolumeControls";
import "./Footer.css";

const Footer = ({ stopSong, pauseSong, resumeSong, audioControl}) => {
return(
<div className='footer'>
const Footer = ({ stopSong, pauseSong, resumeSong, audioControl }) => {
return (
<div className="footer">
<SongControls
stopSong={ stopSong }
pauseSong={ pauseSong }
resumeSong={ resumeSong }
audioControl={ audioControl }
stopSong={stopSong}
pauseSong={pauseSong}
resumeSong={resumeSong}
audioControl={audioControl}
/>
<VolumeControls />
</div>
Expand Down
14 changes: 7 additions & 7 deletions src/components/Header/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react';
import UserDetails from '../UserDetails';
import TrackSearch from '../TrackSearch';
import './Header.css';
import React from "react";
import UserDetails from "../UserDetails";
import TrackSearch from "../TrackSearch";
import "./Header.css";

const Header = () => {
return(
<div className='header'>
return (
<div className="header">
<TrackSearch />
<UserDetails />
</div>
);
};

export default Header ;
export default Header;
39 changes: 22 additions & 17 deletions src/components/MainHeader/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
import MainHeader from "./component";
import { bindActionCreators } from "redux";
import { connect } from "react-redux";
import { fetchCategories, fetchNewReleases, fetchFeatured } from '../../actions/browseActions';
import { updateHeaderTitle } from '../../actions/uiActions';
import { updateViewType } from '../../actions/songActions';

const mapStateToProps = (state) => {
import {
fetchCategories,
fetchNewReleases,
fetchFeatured
} from "../../actions/browseActions";
import { updateHeaderTitle } from "../../actions/uiActions";
import { updateViewType } from "../../actions/songActions";

const mapStateToProps = state => {
return {
songPaused: state.songsReducer.songPaused,
headerTitle: state.uiReducer.title,
viewType: state.songsReducer.viewType,
playlists: state.playlistReducer.playlists,
artists: state.artistsReducer.artistList ? state.artistsReducer.artistList.artists : [],
artists: state.artistsReducer.artistList
? state.artistsReducer.artistList.artists
: [],
token: state.tokenReducer.token
};

};

const mapDispatchToProps = (dispatch) => {

return bindActionCreators({
fetchCategories,
fetchNewReleases,
updateHeaderTitle,
updateViewType,
fetchFeatured
}, dispatch);

const mapDispatchToProps = dispatch => {
return bindActionCreators(
{
fetchCategories,
fetchNewReleases,
updateHeaderTitle,
updateViewType,
fetchFeatured
},
dispatch
);
};

export default connect(mapStateToProps, mapDispatchToProps)(MainHeader);
44 changes: 23 additions & 21 deletions src/components/MainView/component.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import React from 'react';
import PropTypes from 'prop-types';
import SongList from '../SongList';
import AlbumList from '../AlbumList';
import ArtistList from '../ArtistList';
import BrowseView from '../BrowseView';
import './MainView.css';
import React from "react";
import PropTypes from "prop-types";
import SongList from "../SongList";
import AlbumList from "../AlbumList";
import ArtistList from "../ArtistList";
import BrowseView from "../BrowseView";
import "./MainView.css";

const MainView = ({ headerTitle, audioControl, resumeSong, pauseSong }) => {

return (
<div>
{
headerTitle === 'Albums' ?
(<AlbumList audioControl={ audioControl } />) :
headerTitle === 'Artists' ?
(<ArtistList />) :
(headerTitle === 'Browse') ?
( <BrowseView />) :
//anything else show SongList
( <SongList resumeSong={ resumeSong } pauseSong={ pauseSong } audioControl={ audioControl } />)
}
</div>
<React.Fragment>
{headerTitle === "Albums" ? (
<AlbumList audioControl={audioControl} />
) : headerTitle === "Artists" ? (
<ArtistList />
) : headerTitle === "Browse" ? (
<BrowseView />
) : (
//anything else show SongList
<SongList
resumeSong={resumeSong}
pauseSong={pauseSong}
audioControl={audioControl}
/>
)}
</React.Fragment>
);

};

MainView.propTypes = {
Expand Down
Loading

0 comments on commit 442baea

Please sign in to comment.