forked from processing/p5.js-web-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreferences.js
55 lines (52 loc) · 1.85 KB
/
preferences.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import * as ActionTypes from '../../../constants';
export const initialState = {
fontSize: 18,
autosave: true,
linewrap: true,
lineNumbers: true,
lintWarning: false,
textOutput: false,
gridOutput: false,
theme: 'light',
autorefresh: false,
language: 'en-US',
autocloseBracketsQuotes: true,
autocompleteHinter: false
};
const preferences = (state = initialState, action) => {
switch (action.type) {
case ActionTypes.SET_FONT_SIZE:
return Object.assign({}, state, { fontSize: action.value });
case ActionTypes.SET_AUTOSAVE:
return Object.assign({}, state, { autosave: action.value });
case ActionTypes.SET_LINEWRAP:
return Object.assign({}, state, { linewrap: action.value });
case ActionTypes.SET_LINT_WARNING:
return Object.assign({}, state, { lintWarning: action.value });
case ActionTypes.SET_TEXT_OUTPUT:
return Object.assign({}, state, { textOutput: action.value });
case ActionTypes.SET_GRID_OUTPUT:
return Object.assign({}, state, { gridOutput: action.value });
case ActionTypes.SET_PREFERENCES:
return action.preferences;
case ActionTypes.SET_THEME:
return Object.assign({}, state, { theme: action.value });
case ActionTypes.SET_AUTOREFRESH:
return Object.assign({}, state, { autorefresh: action.value });
case ActionTypes.SET_LINE_NUMBERS:
return Object.assign({}, state, { lineNumbers: action.value });
case ActionTypes.SET_LANGUAGE:
return Object.assign({}, state, { language: action.language });
case ActionTypes.SET_AUTOCLOSE_BRACKETS_QUOTES:
return Object.assign({}, state, {
autocloseBracketsQuotes: action.value
});
case ActionTypes.SET_AUTOCOMPLETE_HINTER:
return Object.assign({}, state, {
autocompleteHinter: action.value
});
default:
return state;
}
};
export default preferences;