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

41 lines
1.0 KiB
JavaScript
Raw Normal View History

2016-06-22 21:58:23 +02:00
import * as ActionTypes from '../../../constants';
2016-06-17 19:37:29 +02:00
const initialState = {
2016-06-24 00:29:55 +02:00
isVisible: false,
2016-07-06 17:27:39 +02:00
fontSize: 18,
indentationAmount: 4
2016-06-24 00:29:55 +02:00
};
2016-06-17 19:37:29 +02:00
const preferences = (state = initialState, action) => {
2016-06-24 00:29:55 +02:00
switch (action.type) {
case ActionTypes.OPEN_PREFERENCES:
2016-07-06 17:27:39 +02:00
return Object.assign({}, state, {
isVisible: true
});
2016-06-24 00:29:55 +02:00
case ActionTypes.CLOSE_PREFERENCES:
2016-07-06 17:27:39 +02:00
return Object.assign({}, state, {
isVisible: false
});
2016-06-24 00:29:55 +02:00
case ActionTypes.INCREASE_FONTSIZE:
2016-07-06 17:27:39 +02:00
return Object.assign({}, state, {
2016-06-24 00:29:55 +02:00
fontSize: state.fontSize + 2
2016-07-06 17:27:39 +02:00
});
2016-06-24 00:29:55 +02:00
case ActionTypes.DECREASE_FONTSIZE:
2016-07-06 17:27:39 +02:00
return Object.assign({}, state, {
2016-06-24 00:29:55 +02:00
fontSize: state.fontSize - 2
2016-07-06 17:27:39 +02: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-06-24 00:29:55 +02:00
default:
return state;
}
};
2016-06-17 19:37:29 +02:00
2016-06-24 00:29:55 +02:00
export default preferences;