@@ -5,7 +5,7 @@ import React, {
5
5
useMemo ,
6
6
useCallback
7
7
} from 'react' ;
8
- import { DataGrid , GridEditRowsModel } from '@mui/x-data-grid' ;
8
+ import { DataGrid , GridEditRowsModel } from '@mui/x-data-grid' ;
9
9
import {
10
10
FormControl ,
11
11
TextField ,
@@ -56,13 +56,13 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
56
56
57
57
const currFocus = getFocus ( ) . child ;
58
58
59
- useEffect ( ( ) => {
59
+ useEffect ( ( ) => {
60
60
currFocus ?. attributes ?. compLink && setCompLink ( currFocus . attributes . compLink ) ;
61
61
setEventAll ( [ '' , '' ] ) ;
62
62
if ( currFocus ) {
63
63
const addedEvent : [ ] = [ ] ;
64
- for ( const [ event , funcName ] of Object . entries ( currFocus ?. events ) ) {
65
- addedEvent . push ( { id : event , funcName } )
64
+ for ( const [ event , funcName ] of Object . entries ( currFocus ?. events ) ) {
65
+ addedEvent . push ( { id : event , funcName } )
66
66
}
67
67
setEventRow ( addedEvent ) ;
68
68
}
@@ -71,10 +71,10 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
71
71
//this function allows properties to persist and appear in nested divs
72
72
function deepIterate ( arr ) {
73
73
const output = [ ] ;
74
- for ( let i = 0 ; i < arr . length ; i ++ ) {
75
- if ( arr [ i ] . typeId === 1000 ) continue ;
74
+ for ( let i = 0 ; i < arr . length ; i ++ ) {
75
+ if ( arr [ i ] . typeId === 1000 ) continue ;
76
76
output . push ( arr [ i ] ) ;
77
- if ( arr [ i ] . children . length ) {
77
+ if ( arr [ i ] . children . length ) {
78
78
output . push ( ...deepIterate ( arr [ i ] . children ) ) ;
79
79
}
80
80
}
@@ -186,19 +186,19 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
186
186
if ( currentChild . name !== 'input' && currentChild . name !== 'img' )
187
187
currentChild . children . forEach ( child => searchArray . push ( child ) ) ;
188
188
}
189
-
189
+
190
190
// if type is Component, use child's typeId to search through state components and find matching component's name
191
191
if ( focusChild . type === 'Component' ) {
192
192
focusTarget . child . type = 'component' ;
193
193
focusTarget . child . name = state . components . find (
194
- comp => comp . id === focusChild . typeId
195
- ) . name ;
196
- // if type is HTML Element, search through HTML types to find matching element's name
194
+ comp => comp . id === focusChild . typeId
195
+ ) . name ;
196
+ // if type is HTML Element, search through HTML types to find matching element's name
197
197
} else if ( focusChild . type === 'HTML Element' ) {
198
198
focusTarget . child . type = 'HTML element' ;
199
199
focusTarget . child . name = state . HTMLTypes . find (
200
- elem => elem . id === focusChild . typeId
201
- ) . name ;
200
+ elem => elem . id === focusChild . typeId
201
+ ) . name ;
202
202
}
203
203
}
204
204
return focusTarget ;
@@ -232,28 +232,28 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
232
232
return isLinked ;
233
233
} ;
234
234
235
- const updateAttributeWithState = ( attributeName , componentProviderId , statePropsId , statePropsRow , stateKey = '' ) => {
235
+ const updateAttributeWithState = ( attributeName , componentProviderId , statePropsId , statePropsRow , stateKey = '' ) => {
236
236
const newInput = statePropsRow . value ;
237
237
// get the stateProps of the componentProvider
238
238
const currentComponent = state . components [ state . canvasFocus . componentId - 1 ] ;
239
- let newContextObj = { ...currentComponent . useContext } ;
240
- if ( ! newContextObj ) {
239
+ let newContextObj = { ...currentComponent . useContext } ;
240
+ if ( ! newContextObj ) {
241
241
newContextObj = { } ;
242
242
}
243
243
if ( ! newContextObj [ componentProviderId ] ) {
244
- newContextObj [ componentProviderId ] = { statesFromProvider : new Set ( ) } ;
244
+ newContextObj [ componentProviderId ] = { statesFromProvider : new Set ( ) } ;
245
245
}
246
246
newContextObj [ componentProviderId ] . statesFromProvider . add ( statePropsId ) ;
247
247
if ( attributeName === 'compText' ) {
248
248
newContextObj [ componentProviderId ] . compText = statePropsId ;
249
- setStateUsedObj ( { ...stateUsedObj , compText : stateKey , compTextProviderId : componentProviderId , compTextPropsId : statePropsId } ) ;
249
+ setStateUsedObj ( { ...stateUsedObj , compText : stateKey , compTextProviderId : componentProviderId , compTextPropsId : statePropsId } ) ;
250
250
setCompText ( newInput ) ;
251
251
setUseContextObj ( newContextObj ) ;
252
252
}
253
253
254
254
if ( attributeName === 'compLink' ) {
255
255
newContextObj [ componentProviderId ] . compLink = statePropsId ;
256
- setStateUsedObj ( { ...stateUsedObj , compLink : stateKey , compLinkProviderId : componentProviderId , compLinkPropsId : statePropsId } ) ;
256
+ setStateUsedObj ( { ...stateUsedObj , compLink : stateKey , compLinkProviderId : componentProviderId , compLinkPropsId : statePropsId } ) ;
257
257
setCompLink ( newInput ) ;
258
258
setUseContextObj ( newContextObj ) ;
259
259
}
@@ -307,17 +307,22 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
307
307
} ;
308
308
309
309
310
- const handleSave = ( ) : Object => {
311
- console . log ( 'stateusedobj' , stateUsedObj )
310
+ const handleSave = ( tailwind ) : Object => {
311
+ if ( tailwind !== true ) {
312
+ dispatch ( {
313
+ type : 'CHANGE TAILWIND' ,
314
+ payload : false
315
+ } )
316
+ }
312
317
dispatch ( {
313
318
type : 'UPDATE STATE USED' ,
314
- payload : { stateUsedObj : stateUsedObj }
319
+ payload : { stateUsedObj : stateUsedObj }
315
320
} )
316
321
317
322
318
323
dispatch ( {
319
324
type : 'UPDATE USE CONTEXT' ,
320
- payload : { useContextObj : useContextObj }
325
+ payload : { useContextObj : useContextObj }
321
326
} )
322
327
323
328
const styleObj : any = { } ;
@@ -351,55 +356,12 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
351
356
return styleObj ;
352
357
} ;
353
358
const handleTailwind = ( ) : Object => {
354
- console . log ( 'stateusedobj' , stateUsedObj )
355
- dispatch ( { type : 'CHANGE TAILWIND' , payload : true } ) ;
356
-
357
-
358
- handleSave ( )
359
-
360
- // dispatch({
361
- // type: 'UPDATE STATE USED',
362
- // payload: {stateUsedObj: stateUsedObj}
363
- // })
364
-
365
-
366
- // dispatch({
367
- // type: 'UPDATE USE CONTEXT',
368
- // payload: { useContextObj: useContextObj}
369
- // })
370
-
371
- // const styleObj: any = {};
372
- // if (displayMode !== '') styleObj.display = displayMode;
373
- // if (flexDir !== '') styleObj.flexDirection = flexDir;
374
- // if (flexJustify !== '') styleObj.justifyContent = flexJustify;
375
- // if (flexAlign !== '') styleObj.alignItems = flexAlign;
376
- // if (compWidth !== '') styleObj.width = compWidth;
377
- // if (compHeight !== '') styleObj.height = compHeight;
378
- // if (BGColor !== '') styleObj.backgroundColor = BGColor;
379
- // dispatch({
380
- // type: 'UPDATE CSS',
381
- // payload: { style: styleObj }
382
- // });
383
-
384
- // const attributesObj: any = {};
385
- // if (compText !== '') attributesObj.compText = compText;
386
- // if (compLink !== '') attributesObj.compLink = compLink;
387
- // if (cssClasses !== '') attributesObj.cssClasses = cssClasses;
388
- // dispatch({
389
- // type: 'UPDATE ATTRIBUTES',
390
- // payload: { attributes: attributesObj }
391
- // });
392
-
393
- // const eventsObj: any = {};
394
- // if (eventAll[0] !== '') eventsObj[eventAll[0]] = eventAll[1];
395
- // dispatch({
396
- // type: 'UPDATE EVENTS',
397
- // payload: { events: eventsObj }
398
- // });
399
-
400
- // return styleObj;
401
-
402
359
360
+ dispatch ( {
361
+ type : 'CHANGE TAILWIND' ,
362
+ payload : true
363
+ } ) ;
364
+ handleSave ( true )
403
365
}
404
366
405
367
// UNDO/REDO functionality--onClick these functions will be invoked.
@@ -488,20 +450,20 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
488
450
// the || is for either Mac or Windows OS
489
451
// Undo
490
452
( e . key === 'z' && e . metaKey && ! e . shiftKey ) ||
491
- ( e . key === 'z' && e . ctrlKey && ! e . shiftKey )
453
+ ( e . key === 'z' && e . ctrlKey && ! e . shiftKey )
492
454
? handleUndo ( )
493
455
: // Redo
494
456
( e . shiftKey && e . metaKey && e . key === 'z' ) ||
495
457
( e . shiftKey && e . ctrlKey && e . key === 'z' )
496
- ? handleRedo ( )
497
- : // Delete HTML tag off canvas
498
- e . key === 'Backspace' && e . target . tagName !== "TEXTAREA" && e . target . tagName !== "INPUT"
499
- ? handleDelete ( )
500
- : // Save
501
- ( e . key === 's' && e . ctrlKey && e . shiftKey ) ||
502
- ( e . key === 's' && e . metaKey && e . shiftKey )
503
- ? handleSave ( )
504
- : '' ;
458
+ ? handleRedo ( )
459
+ : // Delete HTML tag off canvas
460
+ e . key === 'Backspace' && e . target . tagName !== "TEXTAREA" && e . target . tagName !== "INPUT"
461
+ ? handleDelete ( )
462
+ : // Save
463
+ ( e . key === 's' && e . ctrlKey && e . shiftKey ) ||
464
+ ( e . key === 's' && e . metaKey && e . shiftKey )
465
+ ? handleSave ( )
466
+ : '' ;
505
467
} , [ ] ) ;
506
468
507
469
useEffect ( ( ) => {
@@ -511,28 +473,28 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
511
473
} ;
512
474
} , [ ] ) ;
513
475
514
- if ( state . canvasFocus . childId === null ) {
476
+ if ( state . canvasFocus . childId === null ) {
515
477
return (
516
478
< div className = "column right" id = "rightContainer" style = { style } >
517
479
< ProjectManager />
518
- < div className = "rightPanelWrapper" >
519
- < div >
520
- < div className = { classes . rootConfigHeader } >
521
- < h4
522
- className = {
523
- isThemeLight
524
- ? classes . lightThemeFontColor
525
- : classes . darkThemeFontColor
526
- }
527
- >
528
- Parent Component:
529
- < br />
530
- < br />
531
- < span className = { classes . rootCompName } > { configTarget . name } </ span >
532
- </ h4 >
533
- </ div >
480
+ < div className = "rightPanelWrapper" >
481
+ < div >
482
+ < div className = { classes . rootConfigHeader } >
483
+ < h4
484
+ className = {
485
+ isThemeLight
486
+ ? classes . lightThemeFontColor
487
+ : classes . darkThemeFontColor
488
+ }
489
+ >
490
+ Parent Component:
491
+ < br />
492
+ < br />
493
+ < span className = { classes . rootCompName } > { configTarget . name } </ span >
494
+ </ h4 >
534
495
</ div >
535
496
</ div >
497
+ </ div >
536
498
< ProjectManager />
537
499
</ div >
538
500
)
@@ -638,7 +600,7 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
638
600
items = { [
639
601
{ value : '' , text : 'default' } ,
640
602
{ value : 'auto' , text : 'auto' } ,
641
- { value : '100%' , text : '100%' } ,
603
+ { value : '100%' , text : '100%' } ,
642
604
{ value : '50%' , text : '50%' } ,
643
605
{ value : '25%' , text : '25%' }
644
606
] }
@@ -717,9 +679,9 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
717
679
</ div >
718
680
< div >
719
681
< UseStateModal
720
- updateAttributeWithState = { updateAttributeWithState }
721
- attributeToChange = "compText"
722
- childId = { state . canvasFocus . childId } />
682
+ updateAttributeWithState = { updateAttributeWithState }
683
+ attributeToChange = "compText"
684
+ childId = { state . canvasFocus . childId } />
723
685
</ div >
724
686
</ div >
725
687
< div className = { classes . configRow } >
@@ -751,8 +713,8 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
751
713
</ div >
752
714
< div >
753
715
< UseStateModal
754
- updateAttributeWithState = { updateAttributeWithState } attributeToChange = "compLink"
755
- childId = { state . canvasFocus . childId } />
716
+ updateAttributeWithState = { updateAttributeWithState } attributeToChange = "compLink"
717
+ childId = { state . canvasFocus . childId } />
756
718
</ div >
757
719
</ div >
758
720
< div className = { classes . configRow } >
@@ -798,9 +760,9 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
798
760
{ value : 'onMouseOver' , text : 'onMouseOver' } ,
799
761
{ value : 'onKeyDown' , text : 'onKeyDown' }
800
762
] }
801
- />
763
+ />
802
764
</ div >
803
- { eventAll [ 0 ] && ( < div className = { classes . configRow } >
765
+ { eventAll [ 0 ] && ( < div className = { classes . configRow } >
804
766
< div
805
767
className = {
806
768
isThemeLight
@@ -824,8 +786,8 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
824
786
placeholder = "Function Name"
825
787
/>
826
788
</ FormControl >
827
- </ div > ) }
828
- { currFocus && Object . keys ( currFocus . events ) . length !== 0 && ( < div className = { 'event-table' } >
789
+ </ div > ) }
790
+ { currFocus && Object . keys ( currFocus . events ) . length !== 0 && ( < div className = { 'event-table' } >
829
791
< DataGrid
830
792
rows = { eventRow }
831
793
columns = { eventColumnTabs }
@@ -846,10 +808,25 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
846
808
onClick = { handleSave }
847
809
id = "saveButton"
848
810
>
849
- SAVE
811
+ CSS
812
+ </ Button >
813
+ </ div >
814
+ < div >
815
+
816
+ < Button
817
+ variant = 'contained'
818
+ color = "primary"
819
+ className = {
820
+ isThemeLight
821
+ ? `${ classes . button } ${ classes . saveButtonLight } `
822
+ : `${ classes . button } ${ classes . saveButtonDark } `
823
+ }
824
+ onClick = { handleTailwind }
825
+ id = "tailwind"
826
+ >
827
+ Tailwind
850
828
</ Button >
851
829
</ div >
852
- < div onClick = { handleTailwind } > tailwind</ div >
853
830
{ configTarget . child ? (
854
831
< div className = { classes . buttonRow } >
855
832
< Button
0 commit comments