1
- import {
2
- ComponentInt ,
3
- ChildInt ,
4
- ApplicationStateInt ,
5
- Action ,
6
- } from '../intefaces/Interfaces' ;
1
+ import { initialApplicationState } from './initialState' ;
2
+ import { Action } from '../intefaces/Interfaces' ;
7
3
8
4
import {
9
5
LOAD_INIT_DATA ,
@@ -33,7 +29,7 @@ import {
33
29
UNDO ,
34
30
REDO ,
35
31
EDIT_MODE ,
36
- EDIT_COMPONENT
32
+ EDIT_COMPONENT ,
37
33
} from '../actionTypes/index' ;
38
34
39
35
import {
@@ -61,66 +57,9 @@ import {
61
57
toggleEditMode ,
62
58
editComponent ,
63
59
undo ,
64
- redo
60
+ redo ,
65
61
} from '../utils/componentReducer.util' ;
66
- import cloneDeep from '../helperFunctions/cloneDeep' ;
67
-
68
- const appComponent : ComponentInt = {
69
- id : 1 ,
70
- stateful : false ,
71
- classBased : false ,
72
- title : 'App' ,
73
- color : '#FF6D00' ,
74
- props : [ ] ,
75
- nextPropId : 1 ,
76
- position : {
77
- x : 25 ,
78
- y : 25 ,
79
- width : 600 ,
80
- height : 400 ,
81
- } ,
82
- childrenArray : [ ] ,
83
- nextChildId : 1 ,
84
- focusChildId : 0 ,
85
- } ;
86
62
87
- const initialApplicationFocusChild : ChildInt = {
88
- childId : 0 ,
89
- componentName : null ,
90
- position : {
91
- x : 25 ,
92
- y : 25 ,
93
- width : 800 ,
94
- height : 550 ,
95
- } ,
96
- childType : null ,
97
- childSort : 0 ,
98
- childComponentId : 0 ,
99
- color : null ,
100
- htmlElement : null ,
101
- HTMLInfo : null ,
102
- } ;
103
-
104
- const initialApplicationState : ApplicationStateInt = {
105
- tutorial : 0 ,
106
- imageSource : '' ,
107
- totalComponents : 1 ,
108
- nextId : 2 ,
109
- successOpen : false ,
110
- errorOpen : false ,
111
- focusComponent : appComponent ,
112
- selectableChildren : [ ] ,
113
- ancestors : [ ] ,
114
- initialApplicationFocusChild,
115
- focusChild : cloneDeep ( initialApplicationFocusChild ) ,
116
- editMode : - 1 ,
117
- components : [ appComponent ] ,
118
- appDir : '' ,
119
- loading : false ,
120
- history : [ ] ,
121
- historyIndex : 0 ,
122
- future : [ ]
123
- } ;
124
63
125
64
const componentReducer = ( state = initialApplicationState , action : Action ) => {
126
65
switch ( action . type ) {
@@ -141,8 +80,8 @@ const componentReducer = (state = initialApplicationState, action: Action) => {
141
80
return deleteChild ( state , action . payload ) ;
142
81
case DELETE_COMPONENT :
143
82
return deleteComponent ( state , action . payload ) ;
144
- case EDIT_COMPONENT :
145
- return editComponent ( state , action . payload ) ;
83
+ case EDIT_COMPONENT :
84
+ return editComponent ( state , action . payload ) ;
146
85
case TOGGLE_STATE :
147
86
return toggleComponentState ( state , action . payload ) ;
148
87
case TOGGLE_CLASS :
@@ -178,16 +117,16 @@ const componentReducer = (state = initialApplicationState, action: Action) => {
178
117
return addProp ( state , action . payload ) ;
179
118
case DELETE_PROP :
180
119
return deleteProp ( state , action . payload ) ;
181
- case EDIT_MODE :
182
- return toggleEditMode ( state , action . payload ) ;
120
+ case EDIT_MODE :
121
+ return toggleEditMode ( state , action . payload ) ;
183
122
case UPDATE_HTML_ATTR :
184
123
return updateHtmlAttr ( state , action . payload ) ;
185
124
case UPDATE_CHILDREN_SORT :
186
125
return updateChildrenSort ( state , action . payload ) ;
187
- case UNDO :
188
- return undo ( state ) ;
189
- case REDO :
190
- return redo ( state ) ;
126
+ case UNDO :
127
+ return undo ( state ) ;
128
+ case REDO :
129
+ return redo ( state ) ;
191
130
default :
192
131
return state ;
193
132
}
0 commit comments