p5.js-web-editor/client/modules/IDE/reducers/preferences.js

49 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-06-22 19:58:23 +00:00
import * as ActionTypes from '../../../constants';
2016-06-17 17:37:29 +00:00
const initialState = {
2016-07-06 15:27:39 +00:00
fontSize: 18,
2016-07-11 13:00:44 +00:00
indentationAmount: 2,
2016-07-11 02:52:48 +00:00
isTabIndent: true
2016-06-23 22:29:55 +00:00
};
2016-06-17 17:37:29 +00:00
const preferences = (state = initialState, action) => {
2016-06-23 22:29:55 +00:00
switch (action.type) {
case ActionTypes.INCREASE_FONTSIZE:
2016-07-06 15:27:39 +00:00
return Object.assign({}, state, {
2016-06-23 22:29:55 +00:00
fontSize: state.fontSize + 2
2016-07-06 15:27:39 +00:00
});
2016-06-23 22:29:55 +00:00
case ActionTypes.DECREASE_FONTSIZE:
2016-07-06 15:27:39 +00:00
return Object.assign({}, state, {
2016-06-23 22:29:55 +00:00
fontSize: state.fontSize - 2
2016-07-06 15:27:39 +00:00
});
2016-07-11 00:13:37 +00:00
case ActionTypes.UPDATE_FONTSIZE:
return Object.assign({}, state, {
2016-07-13 16:59:58 +00:00
fontSize: parseInt(action.value, 10)
2016-07-11 00:13:37 +00:00
});
2016-07-06 15:27:39 +00:00
case ActionTypes.INCREASE_INDENTATION:
return Object.assign({}, state, {
indentationAmount: state.indentationAmount + 2
});
case ActionTypes.DECREASE_INDENTATION:
return Object.assign({}, state, {
indentationAmount: state.indentationAmount - 2
});
2016-07-11 00:13:37 +00:00
case ActionTypes.UPDATE_INDENTATION:
return Object.assign({}, state, {
2016-07-13 16:59:58 +00:00
indentationAmount: parseInt(action.value, 10)
2016-07-11 00:13:37 +00:00
});
2016-07-11 02:52:48 +00:00
case ActionTypes.INDENT_WITH_TAB:
return Object.assign({}, state, {
isTabIndent: true
});
case ActionTypes.INDENT_WITH_SPACE:
return Object.assign({}, state, {
isTabIndent: false
});
2016-06-23 22:29:55 +00:00
default:
return state;
}
};
2016-06-17 17:37:29 +00:00
2016-06-23 22:29:55 +00:00
export default preferences;