Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat equalizer #296

Merged
merged 16 commits into from
Mar 31, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(equalizer): add equalizer view and component and store values in…
… redux
  • Loading branch information
Charles Jacquin committed Mar 31, 2019
commit e6d03a92992a089be2a201dcc61f1b7ec629a29a
3 changes: 2 additions & 1 deletion app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ class App extends React.Component {
{this.renderNavLink('plugins', 'flask', 'Plugins', settings)}
{this.renderNavLink('search', 'search', 'Search Results', settings)}
{this.renderNavLink('settings', 'cogs', 'Settings', settings)}

{this.renderNavLink('equalizer', 'cogs', 'Equalizer', settings)}

<SidebarMenuCategoryHeader>
Collection
</SidebarMenuCategoryHeader>
Expand Down
8 changes: 8 additions & 0 deletions app/actions/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const UPDATE_VOLUME = 'UPDATE_VOLUME';
export const MUTE = 'MUTE';
export const UNMUTE = 'UNMUTE';
export const UPDATE_PLAYBACK_STREAM_LOADING = 'UPDATE_PLAYBACK_STREAM_LOADING';
export const UPDATE_EQUALIZER = 'UPDATE_EQUALIZER';

export function startPlayback() {
sendPlay();
Expand Down Expand Up @@ -90,3 +91,10 @@ export function updateStreamLoading(state) {
payload: state
};
}

export function updateEqualizer(payload) {
return {
type: UPDATE_EQUALIZER,
payload
};
}
34 changes: 34 additions & 0 deletions app/components/Equalizer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import PropTypes from 'prop-types';

import styles from './styles.scss';

const Equalizer = ({ values, onChange }) => (
<div className={styles.equalizer_wrapper}>
<h1>Equalizer</h1>
<div className={styles.equalizer}>
{values.map((value, idx) => (
<div key={idx} className={styles.slider_container}>
<input
type='range'
className={styles.slider}
value={value}
onChange={evt => {
const updatedValues = [...values];

updatedValues[idx] = Number(evt.target.value);
onChange(updatedValues);
}}
/>
</div>
))}
</div>
</div>
);

Equalizer.propTypes = {
values: PropTypes.arrayOf(PropTypes.number),
onChange: PropTypes.func
};

export default Equalizer;
25 changes: 25 additions & 0 deletions app/components/Equalizer/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.equalizer_wrapper {
width: 100%;
padding: 30px 50px;
}

.equalizer {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
}

.slider_container {
margin-right: 10px;
display: flex;
flex-direction: column;
align-items: center;
}

.slider {
width: 8px;
height: 175px;
padding: 0 5px;
-webkit-appearance: slider-vertical !important;
}
30 changes: 30 additions & 0 deletions app/containers/EqualizerViewContainer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

import * as Player from '../../actions/player';
import Equalizer from '../../components/Equalizer';

const EqualizerViewContainer = ({ actions, values }) => (
<Equalizer
values={values}
onChange={actions.updateEqualizer}
/>
);

function mapStateToProps({ player }) {
return {
values: player.equalizer
};
}

function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators(Player, dispatch)
};
}

export default connect(
mapStateToProps,
mapDispatchToProps
)(EqualizerViewContainer);
13 changes: 9 additions & 4 deletions app/containers/MainContentContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import PluginsContainer from '../PluginsContainer';
import SearchResultsContainer from '../SearchResultsContainer';
import SettingsContainer from '../SettingsContainer';
import TagViewContainer from '../TagViewContainer';
<<<<<<< HEAD
=======
import LyricsContainer from '../LyricsContainer';
import EqualizerViewContainer from '../EqualizerViewContainer';
>>>>>>> feat(equalizer): add equalizer view and component and store values in redux

import Downloads from '../../components/Downloads';

Expand All @@ -31,7 +36,7 @@ class MainContentContainer extends React.Component {

render () {
return (
<Route render={({ location, history, match }) => {
<Route render={({ location }) => {
return (
<MainLayout>
<Switch key={location.key} location={location}>
Expand All @@ -47,6 +52,7 @@ class MainContentContainer extends React.Component {
<Route path='/tag/:tagName' component={TagViewContainer} />
<Route path='/search' component={SearchResultsContainer} />
<Route path='/lyrics' component={LyricsContainer} />
<Route path='/equalizer' component={EqualizerViewContainer} />
</Switch>
</MainLayout>
);
Expand All @@ -56,9 +62,8 @@ class MainContentContainer extends React.Component {
}
}

function mapStateToProps (state) {
return {
};
function mapStateToProps () {
return {};
}

function mapDispatchToProps (dispatch) {
Expand Down
11 changes: 9 additions & 2 deletions app/reducers/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
UPDATE_VOLUME,
MUTE,
UNMUTE,
UPDATE_PLAYBACK_STREAM_LOADING
UPDATE_PLAYBACK_STREAM_LOADING,
UPDATE_EQUALIZER
} from '../actions/player';

import {
Expand All @@ -23,7 +24,8 @@ const initialState = {
playbackProgress: 0,
seek: 0,
volume: 100,
muted: false
muted: false,
equalizer: [500, 1500, 2500, 4000, 6500, 8500, 12000, 16000]
};

export default function PlayerReducer(state=initialState, action) {
Expand Down Expand Up @@ -68,6 +70,11 @@ export default function PlayerReducer(state=initialState, action) {
return Object.assign({}, state, {
playbackStreamLoading: action.payload
});
case UPDATE_EQUALIZER:
return {
...state,
equalizer: action.payload
};
default:
return state;
}
Expand Down
Loading