@@ -7,9 +7,9 @@ import { combineStyles } from '../../helperFunctions/combineStyles';
7
7
import globalDefaultStyle from '../../public/styles/globalDefaultStyles' ;
8
8
import renderChildren from '../../helperFunctions/renderChildren' ;
9
9
import adjustComponentColor from '../../helperFunctions/adjustComponentColor' ;
10
- import Annotation from './Annotation'
11
- import validateNewParent from '../../helperFunctions/changePositionValidation'
12
- import componentNest from '../../helperFunctions/componentNestValidation'
10
+ import DeleteButton from './Annotation' ;
11
+ import validateNewParent from '../../helperFunctions/changePositionValidation' ;
12
+ import componentNest from '../../helperFunctions/componentNestValidation' ;
13
13
import AddRoute from './AddRoute' ;
14
14
import AddLink from './AddLink' ;
15
15
@@ -36,7 +36,9 @@ function DirectChildHTMLNestable({
36
36
const deepCopiedState = JSON . parse ( JSON . stringify ( state ) ) ;
37
37
const focusIndex = state . canvasFocus . componentId - 1 ;
38
38
//pushes the last user action on the canvas into the past array of Component
39
- state . components [ focusIndex ] . past . push ( deepCopiedState . components [ focusIndex ] . children ) ;
39
+ state . components [ focusIndex ] . past . push (
40
+ deepCopiedState . components [ focusIndex ] . children
41
+ ) ;
40
42
} ;
41
43
42
44
// find the HTML element corresponding with this instance of an HTML element
@@ -78,13 +80,20 @@ function DirectChildHTMLNestable({
78
80
// updates state with new instance
79
81
// if item dropped is going to be a new instance (i.e. it came from the left panel), then create a new child component
80
82
if ( item . newInstance ) {
81
- if ( ( item . instanceType === 'Component' && componentNest ( state . components [ item . instanceTypeId - 1 ] . children , childId ) ) || item . instanceType !== 'Component' ) {
83
+ if (
84
+ ( item . instanceType === 'Component' &&
85
+ componentNest (
86
+ state . components [ item . instanceTypeId - 1 ] . children ,
87
+ childId
88
+ ) ) ||
89
+ item . instanceType !== 'Component'
90
+ ) {
82
91
dispatch ( {
83
92
type : 'ADD CHILD' ,
84
93
payload : {
85
94
type : item . instanceType ,
86
95
typeId : item . instanceTypeId ,
87
- childId : childId ,
96
+ childId : childId
88
97
}
89
98
} ) ;
90
99
}
@@ -97,7 +106,7 @@ function DirectChildHTMLNestable({
97
106
type : 'CHANGE POSITION' ,
98
107
payload : {
99
108
currentChildId : item . childId ,
100
- newParentChildId : childId ,
109
+ newParentChildId : childId
101
110
}
102
111
} ) ;
103
112
}
@@ -128,7 +137,7 @@ function DirectChildHTMLNestable({
128
137
border :
129
138
state . canvasFocus . childId === childId
130
139
? '3px solid #186BB4'
131
- : '1px solid grey' ,
140
+ : '1px solid grey'
132
141
} ;
133
142
134
143
// incoporated this logic into my nesting check below caused i new error
@@ -138,28 +147,26 @@ function DirectChildHTMLNestable({
138
147
// if component is not in APP children array, it's a nested component, and should have a differend background color
139
148
// defaultNestableStyle['backgroundColor'] = state.components[0].children.includes(childId) ? 'blue' : globalDefaultStyle['backgroundColor'];
140
149
141
-
142
150
// console.log('APP DIRECT KIDS: ', state.components[0].children);
143
151
144
152
const combinedStyle = combineStyles (
145
153
combineStyles ( combineStyles ( defaultNestableStyle , HTMLType . style ) , style ) ,
146
154
interactiveStyle
147
155
) ;
148
156
149
- // WHAT THE CHILDREN ARRAY LOOKS LIKE - LW
150
- // ARRAY OF OBJS
151
- // {type: 'HTML Element', typeId: 1000, name: 'separator', childId: 1000, style: {…}, … }
152
- // tried adding a conditional to only run this reassignment if state.components[0]['name'] === 'App' DON'T WORK
153
-
154
- // state.components[0].children?.forEach(obj => {
155
- // // console.log('childId : ', obj['childId'], 'childId : ', childId);
156
- // if (obj['childId'] === childId) {
157
- // combinedStyle['backgroundColor'] = isOver ? 'yellow' : 'grey';
158
- // } else {
159
- // combinedStyle['backgroundColor'] = isOver ? 'yellow' : globalDefaultStyle['backgroundColor'];
160
- // }
161
- // });
157
+ // WHAT THE CHILDREN ARRAY LOOKS LIKE - LW
158
+ // ARRAY OF OBJS
159
+ // {type: 'HTML Element', typeId: 1000, name: 'separator', childId: 1000, style: {…}, … }
160
+ // tried adding a conditional to only run this reassignment if state.components[0]['name'] === 'App' DON'T WORK
162
161
162
+ // state.components[0].children?.forEach(obj => {
163
+ // // console.log('childId : ', obj['childId'], 'childId : ', childId);
164
+ // if (obj['childId'] === childId) {
165
+ // combinedStyle['backgroundColor'] = isOver ? 'yellow' : 'grey';
166
+ // } else {
167
+ // combinedStyle['backgroundColor'] = isOver ? 'yellow' : globalDefaultStyle['backgroundColor'];
168
+ // }
169
+ // });
163
170
164
171
// trying to render components with diff background colors based on how deeply nested they were - doesnt' work as on now
165
172
// state.components.forEach(component => {
@@ -177,7 +184,6 @@ function DirectChildHTMLNestable({
177
184
// })
178
185
// });
179
186
180
-
181
187
// console.log('state: ', state);
182
188
// helper func i created below does not work now because it cannot reference combined style from its file. - LW
183
189
// adjustComponentColor(children, childId, state);
@@ -191,20 +197,34 @@ function DirectChildHTMLNestable({
191
197
routeButton . push ( < AddRoute id = { childId } name = { name } /> ) ;
192
198
}
193
199
if ( typeId === 19 ) {
194
- routeButton . push ( < AddLink id = { childId } onClickHandler = { onClickHandler } name = { name } linkDisplayed = { attributes && attributes . compLink ? `${ attributes . compLink } ` : null } /> ) ;
200
+ routeButton . push (
201
+ < AddLink
202
+ id = { childId }
203
+ onClickHandler = { onClickHandler }
204
+ name = { name }
205
+ linkDisplayed = {
206
+ attributes && attributes . compLink ? `${ attributes . compLink } ` : null
207
+ }
208
+ />
209
+ ) ;
195
210
}
196
-
211
+
197
212
return (
198
- < div onClick = { onClickHandler } style = { combinedStyle } ref = { ref } id = { `canv${ childId } ` } >
213
+ < div
214
+ onClick = { onClickHandler }
215
+ style = { combinedStyle }
216
+ ref = { ref }
217
+ id = { `canv${ childId } ` }
218
+ >
199
219
< span >
200
- < strong style = { { color : isThemeLight ? 'black' : 'white' } } > { HTMLType . placeHolderShort + ' nestable' } </ strong >
201
- < strong style = { { color : "#0099E6" } } > { attributes && attributes . compLink ? ` ${ attributes . compLink } ` : '' } </ strong >
220
+ < strong style = { { color : isThemeLight ? 'black' : 'white' } } >
221
+ { HTMLType . placeHolderShort + ' nestable' }
222
+ </ strong >
223
+ < strong style = { { color : '#0099E6' } } >
224
+ { attributes && attributes . compLink ? ` ${ attributes . compLink } ` : '' }
225
+ </ strong >
202
226
{ routeButton }
203
- < Annotation
204
- id = { childId }
205
- name = { name }
206
- annotations = { annotations }
207
- />
227
+ < DeleteButton id = { childId } name = { name } annotations = { annotations } />
208
228
</ span >
209
229
{ renderChildren ( children ) }
210
230
</ div >
0 commit comments