make preference value input tag

This commit is contained in:
mathuramg 2016-07-10 20:13:37 -04:00
parent 1b56f8ce54
commit 3bdd02e859
6 changed files with 36 additions and 4 deletions

View file

@ -8,8 +8,10 @@ export const OPEN_PREFERENCES = 'OPEN_PREFERENCES';
export const CLOSE_PREFERENCES = 'CLOSE_PREFERENCES'; export const CLOSE_PREFERENCES = 'CLOSE_PREFERENCES';
export const INCREASE_FONTSIZE = 'INCREASE_FONTSIZE'; export const INCREASE_FONTSIZE = 'INCREASE_FONTSIZE';
export const DECREASE_FONTSIZE = 'DECREASE_FONTSIZE'; export const DECREASE_FONTSIZE = 'DECREASE_FONTSIZE';
export const UPDATE_FONTSIZE = 'UPDATE_FONTSIZE';
export const INCREASE_INDENTATION = 'INCREASE_INDENTATION'; export const INCREASE_INDENTATION = 'INCREASE_INDENTATION';
export const DECREASE_INDENTATION = 'DECREASE_INDENTATION'; export const DECREASE_INDENTATION = 'DECREASE_INDENTATION';
export const UPDATE_INDENTATION = 'UPDATE_INDENTATION';
export const AUTH_USER = 'AUTH_USER'; export const AUTH_USER = 'AUTH_USER';
export const UNAUTH_USER = 'UNAUTH_USER'; export const UNAUTH_USER = 'UNAUTH_USER';

View file

@ -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() { export function increaseIndentation() {
return { return {
type: ActionTypes.INCREASE_INDENTATION type: ActionTypes.INCREASE_INDENTATION
@ -35,3 +43,11 @@ export function decreaseIndentation() {
type: ActionTypes.DECREASE_INDENTATION type: ActionTypes.DECREASE_INDENTATION
}; };
} }
export function updateIndentation() {
const value = event.target.value;
return {
type: ActionTypes.UPDATE_INDENTATION,
value
};
}

View file

@ -25,7 +25,7 @@ function Preferences(props) {
<button className="preference__plus-button" onClick={props.decreaseFont}> <button className="preference__plus-button" onClick={props.decreaseFont}>
<Isvg src={minusUrl} alt="Decrease Font Size" /> <Isvg src={minusUrl} alt="Decrease Font Size" />
</button> </button>
<p className="preference__value">{props.fontSize}</p> <input className="preference__value" defaultValue={props.fontSize} value={props.fontSize} onChange={props.updateFont}></input>
<button className="preference__minus-button" onClick={props.increaseFont}> <button className="preference__minus-button" onClick={props.increaseFont}>
<Isvg src={plusUrl} alt="Increase Font Size" /> <Isvg src={plusUrl} alt="Increase Font Size" />
</button> </button>
@ -36,7 +36,7 @@ function Preferences(props) {
<button className="preference__plus-button" onClick={props.decreaseIndentation}> <button className="preference__plus-button" onClick={props.decreaseIndentation}>
<Isvg src={minusUrl} alt="DecreaseIndentation Amount" /> <Isvg src={minusUrl} alt="DecreaseIndentation Amount" />
</button> </button>
<p className="preference__value">{props.indentationAmount}</p> <input className="preference__value" defaultValue={props.indentationAmount} value={props.indentationAmount} onChange={props.updateIndentation}></input>
<button className="preference__minus-button" onClick={props.increaseIndentation}> <button className="preference__minus-button" onClick={props.increaseIndentation}>
<Isvg src={plusUrl} alt="IncreaseIndentation Amount" /> <Isvg src={plusUrl} alt="IncreaseIndentation Amount" />
</button> </button>
@ -50,11 +50,13 @@ Preferences.propTypes = {
isVisible: PropTypes.bool.isRequired, isVisible: PropTypes.bool.isRequired,
closePreferences: PropTypes.func.isRequired, closePreferences: PropTypes.func.isRequired,
decreaseFont: PropTypes.func.isRequired, decreaseFont: PropTypes.func.isRequired,
updateFont: PropTypes.func.isRequired,
fontSize: PropTypes.number.isRequired, fontSize: PropTypes.number.isRequired,
increaseFont: PropTypes.func.isRequired, increaseFont: PropTypes.func.isRequired,
indentationAmount: PropTypes.number.isRequired, indentationAmount: PropTypes.number.isRequired,
decreaseIndentation: PropTypes.func.isRequired, decreaseIndentation: PropTypes.func.isRequired,
increaseIndentation: PropTypes.func.isRequired increaseIndentation: PropTypes.func.isRequired,
updateIndentation: PropTypes.func.isRequired
}; };
export default Preferences; export default Preferences;

View file

@ -42,9 +42,11 @@ class IDEView extends React.Component {
closePreferences={this.props.closePreferences} closePreferences={this.props.closePreferences}
increaseFont={this.props.increaseFont} increaseFont={this.props.increaseFont}
decreaseFont={this.props.decreaseFont} decreaseFont={this.props.decreaseFont}
updateFont={this.props.updateFont}
fontSize={this.props.preferences.fontSize} fontSize={this.props.preferences.fontSize}
increaseIndentation={this.props.increaseIndentation} increaseIndentation={this.props.increaseIndentation}
decreaseIndentation={this.props.decreaseIndentation} decreaseIndentation={this.props.decreaseIndentation}
updateIndentation={this.props.updateIndentation}
indentationAmount={this.props.preferences.indentationAmount} indentationAmount={this.props.preferences.indentationAmount}
/> />
<Editor <Editor
@ -91,8 +93,10 @@ IDEView.propTypes = {
closePreferences: PropTypes.func.isRequired, closePreferences: PropTypes.func.isRequired,
increaseFont: PropTypes.func.isRequired, increaseFont: PropTypes.func.isRequired,
decreaseFont: PropTypes.func.isRequired, decreaseFont: PropTypes.func.isRequired,
updateFont: PropTypes.func.isRequired,
increaseIndentation: PropTypes.func.isRequired, increaseIndentation: PropTypes.func.isRequired,
decreaseIndentation: PropTypes.func.isRequired, decreaseIndentation: PropTypes.func.isRequired,
updateIndentation: PropTypes.func.isRequired,
file: PropTypes.shape({ file: PropTypes.shape({
content: PropTypes.string.isRequired content: PropTypes.string.isRequired
}).isRequired, }).isRequired,

View file

@ -24,6 +24,10 @@ const preferences = (state = initialState, action) => {
return Object.assign({}, state, { return Object.assign({}, state, {
fontSize: state.fontSize - 2 fontSize: state.fontSize - 2
}); });
case ActionTypes.UPDATE_FONTSIZE:
return Object.assign({}, state, {
fontSize: action.value
});
case ActionTypes.INCREASE_INDENTATION: case ActionTypes.INCREASE_INDENTATION:
return Object.assign({}, state, { return Object.assign({}, state, {
indentationAmount: state.indentationAmount + 2 indentationAmount: state.indentationAmount + 2
@ -32,6 +36,10 @@ const preferences = (state = initialState, action) => {
return Object.assign({}, state, { return Object.assign({}, state, {
indentationAmount: state.indentationAmount - 2 indentationAmount: state.indentationAmount - 2
}); });
case ActionTypes.UPDATE_INDENTATION:
return Object.assign({}, state, {
indentationAmount: action.value
});
default: default:
return state; return state;
} }

View file

@ -48,6 +48,6 @@
.preference__value { .preference__value {
border: 1px solid $light-button-border-color; border: 1px solid $light-button-border-color;
text-align: center; text-align: center;
line-height: #{48 / $base-font-size}rem;
width: #{48 / $base-font-size}rem; width: #{48 / $base-font-size}rem;
background-color: $light-button-background-color;
} }