From 4869bfdf1f36882f62c5ad388ce8a6f362dc6c37 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Fri, 2 Sep 2016 21:40:04 -0700 Subject: [PATCH] Add minimal db buttons --- css/equalizer-window.css | 24 ++++++++++++++++++++++++ js/components/EqualizerWindow.jsx | 19 ++++++++++++------- js/reducers.js | 18 ++++++++++++++++++ 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/css/equalizer-window.css b/css/equalizer-window.css index 2b1a92bf..52421e80 100644 --- a/css/equalizer-window.css +++ b/css/equalizer-window.css @@ -47,6 +47,30 @@ top: 38px; } +#winamp2-js #plus12db { + position: absolute; + left: 45px; + top: 36px; + width: 22px; + height: 8px; +} + +#winamp2-js #zerodb { + position: absolute; + left: 45px; + top: 64px; + width: 22px; + height: 8px; +} + +#winamp2-js #minus12db { + position: absolute; + left: 45px; + top: 95px; + width: 22px; + height: 8px; +} + #winamp2-js #band-60 { position: absolute; left: 79px; diff --git a/js/components/EqualizerWindow.jsx b/js/components/EqualizerWindow.jsx index f1f7ea1a..4ba8457b 100644 --- a/js/components/EqualizerWindow.jsx +++ b/js/components/EqualizerWindow.jsx @@ -20,15 +20,10 @@ const bandClassName = (band) => { class EqualizerWindow extends React.Component { constructor(props) { super(props); - this.handleClick = this.handleClick.bind(this); this.setHertzValue = this.setHertzValue.bind(this); this.setPreampValue = this.setPreampValue.bind(this); } - handleClick() { - this.props.dispatch({type: 'SET_FOCUSED_WINDOW', window: WINDOWS.EQUALIZER}); - } - setHertzValue(hertz) { return (e) => { this.props.dispatch( @@ -53,13 +48,16 @@ class EqualizerWindow extends React.Component { doubled }); return -
+
+
+
+
{BANDS.map((hertz) => ( state)(EqualizerWindow); +const mapDispatchToProps = (dispatch) => ({ + setEqToMax: () => dispatch({type: 'SET_EQ_TO_MAX'}), + setEqToMid: () => dispatch({type: 'SET_EQ_TO_MID'}), + setEqToMin: () => dispatch({type: 'SET_EQ_TO_MIN'}), + focusWindow: () => dispatch({type: 'SET_FOCUSED_WINDOW', window: WINDOWS.EQUALIZER}) +}); + +module.exports = connect((state) => state, mapDispatchToProps)(EqualizerWindow); diff --git a/js/reducers.js b/js/reducers.js index ccf77d80..e1ad5486 100644 --- a/js/reducers.js +++ b/js/reducers.js @@ -129,6 +129,24 @@ const equalizer = (state, action) => { return {...state, on: !state.on}; case 'TOGGLE_EQ_AUTO': return {...state, auto: !state.auto}; + case 'SET_EQ_TO_MAX': + const maxSliders = {}; + Object.keys(state.sliders).forEach((key) => { + maxSliders[key] = 100; + }); + return {...state, sliders: maxSliders}; + case 'SET_EQ_TO_MID': + const midSliders = {}; + Object.keys(state.sliders).forEach((key) => { + midSliders[key] = 50; + }); + return {...state, sliders: midSliders}; + case 'SET_EQ_TO_MIN': + const minSliders = {}; + Object.keys(state.sliders).forEach((key) => { + minSliders[key] = 0; + }); + return {...state, sliders: minSliders}; default: return state; }