@@ -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
}
@@ -305,18 +305,24 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
305
305
payload : { event : selectedEvent }
306
306
} ) ;
307
307
} ;
308
- const handleTailwind = ( ) : Object => {
309
- console . log ( 'stateusedobj' , stateUsedObj )
310
- dispatch ( { type : 'CHANGE TAILWIND' , payload : true } ) ;
308
+
309
+
310
+ const handleSave = ( tailwind ) : Object => {
311
+ if ( tailwind !== true ) {
312
+ dispatch ( {
313
+ type : 'CHANGE TAILWIND' ,
314
+ payload : false
315
+ } )
316
+ }
311
317
dispatch ( {
312
318
type : 'UPDATE STATE USED' ,
313
- payload : { stateUsedObj : stateUsedObj }
319
+ payload : { stateUsedObj : stateUsedObj }
314
320
} )
315
321
316
322
317
323
dispatch ( {
318
324
type : 'UPDATE USE CONTEXT' ,
319
- payload : { useContextObj : useContextObj }
325
+ payload : { useContextObj : useContextObj }
320
326
} )
321
327
322
328
const styleObj : any = { } ;
@@ -347,55 +353,17 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
347
353
type : 'UPDATE EVENTS' ,
348
354
payload : { events : eventsObj }
349
355
} ) ;
350
-
351
356
return styleObj ;
357
+ } ;
358
+ const handleTailwind = ( ) : Object => {
352
359
353
-
354
- }
355
-
356
- const handleSave = ( ) : Object => {
357
- console . log ( 'stateusedobj' , stateUsedObj )
358
- dispatch ( {
359
- type : 'UPDATE STATE USED' ,
360
- payload : { stateUsedObj : stateUsedObj }
361
- } )
362
-
363
-
364
- dispatch ( {
365
- type : 'UPDATE USE CONTEXT' ,
366
- payload : { useContextObj : useContextObj }
367
- } )
368
-
369
- const styleObj : any = { } ;
370
- if ( displayMode !== '' ) styleObj . display = displayMode ;
371
- if ( flexDir !== '' ) styleObj . flexDirection = flexDir ;
372
- if ( flexJustify !== '' ) styleObj . justifyContent = flexJustify ;
373
- if ( flexAlign !== '' ) styleObj . alignItems = flexAlign ;
374
- if ( compWidth !== '' ) styleObj . width = compWidth ;
375
- if ( compHeight !== '' ) styleObj . height = compHeight ;
376
- if ( BGColor !== '' ) styleObj . backgroundColor = BGColor ;
377
- dispatch ( {
378
- type : 'UPDATE CSS' ,
379
- payload : { style : styleObj }
380
- } ) ;
381
-
382
- const attributesObj : any = { } ;
383
- if ( compText !== '' ) attributesObj . compText = compText ;
384
- if ( compLink !== '' ) attributesObj . compLink = compLink ;
385
- if ( cssClasses !== '' ) attributesObj . cssClasses = cssClasses ;
386
360
dispatch ( {
387
- type : 'UPDATE ATTRIBUTES ' ,
388
- payload : { attributes : attributesObj }
361
+ type : 'CHANGE TAILWIND ' ,
362
+ payload : true
389
363
} ) ;
364
+ handleSave ( true )
365
+ }
390
366
391
- const eventsObj : any = { } ;
392
- if ( eventAll [ 0 ] !== '' ) eventsObj [ eventAll [ 0 ] ] = eventAll [ 1 ] ;
393
- dispatch ( {
394
- type : 'UPDATE EVENTS' ,
395
- payload : { events : eventsObj }
396
- } ) ;
397
- return styleObj ;
398
- } ;
399
367
// UNDO/REDO functionality--onClick these functions will be invoked.
400
368
const handleUndo = ( ) => {
401
369
dispatch ( { type : 'UNDO' , payload : { } } ) ;
@@ -482,20 +450,20 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
482
450
// the || is for either Mac or Windows OS
483
451
// Undo
484
452
( e . key === 'z' && e . metaKey && ! e . shiftKey ) ||
485
- ( e . key === 'z' && e . ctrlKey && ! e . shiftKey )
453
+ ( e . key === 'z' && e . ctrlKey && ! e . shiftKey )
486
454
? handleUndo ( )
487
455
: // Redo
488
456
( e . shiftKey && e . metaKey && e . key === 'z' ) ||
489
457
( e . shiftKey && e . ctrlKey && e . key === 'z' )
490
- ? handleRedo ( )
491
- : // Delete HTML tag off canvas
492
- e . key === 'Backspace' && e . target . tagName !== "TEXTAREA" && e . target . tagName !== "INPUT"
493
- ? handleDelete ( )
494
- : // Save
495
- ( e . key === 's' && e . ctrlKey && e . shiftKey ) ||
496
- ( e . key === 's' && e . metaKey && e . shiftKey )
497
- ? handleSave ( )
498
- : '' ;
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
+ : '' ;
499
467
} , [ ] ) ;
500
468
501
469
useEffect ( ( ) => {
@@ -505,28 +473,28 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
505
473
} ;
506
474
} , [ ] ) ;
507
475
508
- if ( state . canvasFocus . childId === null ) {
476
+ if ( state . canvasFocus . childId === null ) {
509
477
return (
510
478
< div className = "column right" id = "rightContainer" style = { style } >
511
479
< ProjectManager />
512
- < div className = "rightPanelWrapper" >
513
- < div >
514
- < div className = { classes . rootConfigHeader } >
515
- < h4
516
- className = {
517
- isThemeLight
518
- ? classes . lightThemeFontColor
519
- : classes . darkThemeFontColor
520
- }
521
- >
522
- Parent Component:
523
- < br />
524
- < br />
525
- < span className = { classes . rootCompName } > { configTarget . name } </ span >
526
- </ h4 >
527
- </ 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 >
528
495
</ div >
529
496
</ div >
497
+ </ div >
530
498
< ProjectManager />
531
499
</ div >
532
500
)
@@ -632,7 +600,7 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
632
600
items = { [
633
601
{ value : '' , text : 'default' } ,
634
602
{ value : 'auto' , text : 'auto' } ,
635
- { value : '100%' , text : '100%' } ,
603
+ { value : '100%' , text : '100%' } ,
636
604
{ value : '50%' , text : '50%' } ,
637
605
{ value : '25%' , text : '25%' }
638
606
] }
@@ -711,9 +679,9 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
711
679
</ div >
712
680
< div >
713
681
< UseStateModal
714
- updateAttributeWithState = { updateAttributeWithState }
715
- attributeToChange = "compText"
716
- childId = { state . canvasFocus . childId } />
682
+ updateAttributeWithState = { updateAttributeWithState }
683
+ attributeToChange = "compText"
684
+ childId = { state . canvasFocus . childId } />
717
685
</ div >
718
686
</ div >
719
687
< div className = { classes . configRow } >
@@ -745,8 +713,8 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
745
713
</ div >
746
714
< div >
747
715
< UseStateModal
748
- updateAttributeWithState = { updateAttributeWithState } attributeToChange = "compLink"
749
- childId = { state . canvasFocus . childId } />
716
+ updateAttributeWithState = { updateAttributeWithState } attributeToChange = "compLink"
717
+ childId = { state . canvasFocus . childId } />
750
718
</ div >
751
719
</ div >
752
720
< div className = { classes . configRow } >
@@ -792,9 +760,9 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
792
760
{ value : 'onMouseOver' , text : 'onMouseOver' } ,
793
761
{ value : 'onKeyDown' , text : 'onKeyDown' }
794
762
] }
795
- />
763
+ />
796
764
</ div >
797
- { eventAll [ 0 ] && ( < div className = { classes . configRow } >
765
+ { eventAll [ 0 ] && ( < div className = { classes . configRow } >
798
766
< div
799
767
className = {
800
768
isThemeLight
@@ -818,8 +786,8 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
818
786
placeholder = "Function Name"
819
787
/>
820
788
</ FormControl >
821
- </ div > ) }
822
- { 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' } >
823
791
< DataGrid
824
792
rows = { eventRow }
825
793
columns = { eventColumnTabs }
@@ -840,10 +808,25 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
840
808
onClick = { handleSave }
841
809
id = "saveButton"
842
810
>
843
- 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
844
828
</ Button >
845
829
</ div >
846
- < div onClick = { handleTailwind } > tailwind</ div >
847
830
{ configTarget . child ? (
848
831
< div className = { classes . buttonRow } >
849
832
< Button
0 commit comments