From 3bdd02e859b2e7adf2fdfd110740c21dc1029a20 Mon Sep 17 00:00:00 2001 From: mathuramg Date: Sun, 10 Jul 2016 20:13:37 -0400 Subject: [PATCH] make preference value input tag --- client/constants.js | 2 ++ client/modules/IDE/actions/preferences.js | 16 ++++++++++++++++ client/modules/IDE/components/Preferences.js | 8 +++++--- client/modules/IDE/pages/IDEView.js | 4 ++++ client/modules/IDE/reducers/preferences.js | 8 ++++++++ client/styles/components/_preferences.scss | 2 +- 6 files changed, 36 insertions(+), 4 deletions(-) diff --git a/client/constants.js b/client/constants.js index 90453065..0a817cd6 100644 --- a/client/constants.js +++ b/client/constants.js @@ -8,8 +8,10 @@ export const OPEN_PREFERENCES = 'OPEN_PREFERENCES'; export const CLOSE_PREFERENCES = 'CLOSE_PREFERENCES'; export const INCREASE_FONTSIZE = 'INCREASE_FONTSIZE'; export const DECREASE_FONTSIZE = 'DECREASE_FONTSIZE'; +export const UPDATE_FONTSIZE = 'UPDATE_FONTSIZE'; export const INCREASE_INDENTATION = 'INCREASE_INDENTATION'; export const DECREASE_INDENTATION = 'DECREASE_INDENTATION'; +export const UPDATE_INDENTATION = 'UPDATE_INDENTATION'; export const AUTH_USER = 'AUTH_USER'; export const UNAUTH_USER = 'UNAUTH_USER'; diff --git a/client/modules/IDE/actions/preferences.js b/client/modules/IDE/actions/preferences.js index 5d1e0a81..331e33b6 100644 --- a/client/modules/IDE/actions/preferences.js +++ b/client/modules/IDE/actions/preferences.js @@ -24,6 +24,14 @@ export function decreaseFont() { }; } +export function updateFont(event) { + const value = event.target.value; + return { + type: ActionTypes.UPDATE_FONTSIZE, + value + }; +} + export function increaseIndentation() { return { type: ActionTypes.INCREASE_INDENTATION @@ -35,3 +43,11 @@ export function decreaseIndentation() { type: ActionTypes.DECREASE_INDENTATION }; } + +export function updateIndentation() { + const value = event.target.value; + return { + type: ActionTypes.UPDATE_INDENTATION, + value + }; +} diff --git a/client/modules/IDE/components/Preferences.js b/client/modules/IDE/components/Preferences.js index a8adf80a..17137554 100644 --- a/client/modules/IDE/components/Preferences.js +++ b/client/modules/IDE/components/Preferences.js @@ -25,7 +25,7 @@ function Preferences(props) { -

{props.fontSize}

+ @@ -36,7 +36,7 @@ function Preferences(props) { -

{props.indentationAmount}

+ @@ -50,11 +50,13 @@ Preferences.propTypes = { isVisible: PropTypes.bool.isRequired, closePreferences: PropTypes.func.isRequired, decreaseFont: PropTypes.func.isRequired, + updateFont: PropTypes.func.isRequired, fontSize: PropTypes.number.isRequired, increaseFont: PropTypes.func.isRequired, indentationAmount: PropTypes.number.isRequired, decreaseIndentation: PropTypes.func.isRequired, - increaseIndentation: PropTypes.func.isRequired + increaseIndentation: PropTypes.func.isRequired, + updateIndentation: PropTypes.func.isRequired }; export default Preferences; diff --git a/client/modules/IDE/pages/IDEView.js b/client/modules/IDE/pages/IDEView.js index 620b828b..bc98f378 100644 --- a/client/modules/IDE/pages/IDEView.js +++ b/client/modules/IDE/pages/IDEView.js @@ -42,9 +42,11 @@ class IDEView extends React.Component { closePreferences={this.props.closePreferences} increaseFont={this.props.increaseFont} decreaseFont={this.props.decreaseFont} + updateFont={this.props.updateFont} fontSize={this.props.preferences.fontSize} increaseIndentation={this.props.increaseIndentation} decreaseIndentation={this.props.decreaseIndentation} + updateIndentation={this.props.updateIndentation} indentationAmount={this.props.preferences.indentationAmount} /> { return Object.assign({}, state, { fontSize: state.fontSize - 2 }); + case ActionTypes.UPDATE_FONTSIZE: + return Object.assign({}, state, { + fontSize: action.value + }); case ActionTypes.INCREASE_INDENTATION: return Object.assign({}, state, { indentationAmount: state.indentationAmount + 2 @@ -32,6 +36,10 @@ const preferences = (state = initialState, action) => { return Object.assign({}, state, { indentationAmount: state.indentationAmount - 2 }); + case ActionTypes.UPDATE_INDENTATION: + return Object.assign({}, state, { + indentationAmount: action.value + }); default: return state; } diff --git a/client/styles/components/_preferences.scss b/client/styles/components/_preferences.scss index b979f9d2..e8aeca3a 100644 --- a/client/styles/components/_preferences.scss +++ b/client/styles/components/_preferences.scss @@ -48,6 +48,6 @@ .preference__value { border: 1px solid $light-button-border-color; text-align: center; - line-height: #{48 / $base-font-size}rem; width: #{48 / $base-font-size}rem; + background-color: $light-button-background-color; }