@@ -4,8 +4,8 @@ import React, {
4
4
useEffect ,
5
5
useMemo ,
6
6
useRef ,
7
+ useCallback ,
7
8
} from 'react' ;
8
- import initialState from '../context/initialState' ;
9
9
import { makeStyles } from '@material-ui/core/styles' ;
10
10
import FormControl from '@material-ui/core/FormControl' ;
11
11
import Select from '@material-ui/core/Select' ;
@@ -25,7 +25,8 @@ import List from '@material-ui/core/List';
25
25
import ListItem from '@material-ui/core/ListItem' ;
26
26
import ListItemText from '@material-ui/core/ListItemText' ;
27
27
import createModal from '../components/right/createModal' ;
28
- import ComponentPanel from '../components/right/ComponentPanel'
28
+ import ComponentPanel from '../components/right/ComponentPanel' ;
29
+ import { keys } from '@material-ui/core/styles/createBreakpoints' ;
29
30
30
31
// need to pass in props to use the useHistory feature of react router
31
32
const RightContainer = ( { isThemeLight} ) : JSX . Element => {
@@ -44,11 +45,11 @@ const RightContainer = ({isThemeLight}): JSX.Element => {
44
45
const { style } = useContext ( styleContext ) ;
45
46
const [ modal , setModal ] = useState ( null ) ;
46
47
47
-
48
48
const resetFields = ( ) => {
49
49
const style = configTarget . child
50
- ? configTarget . child . style
51
- : configTarget . style ;
50
+ ? configTarget . child . style
51
+ : configTarget . style ;
52
+ console . log ( 'styleContext style' , style )
52
53
setDisplayMode ( style . display ? style . display : '' ) ;
53
54
setFlexDir ( style . flexDirection ? style . flexDirection : '' ) ;
54
55
setFlexJustify ( style . justifyContent ? style . justifyContent : '' ) ;
@@ -67,7 +68,7 @@ const RightContainer = ({isThemeLight}): JSX.Element => {
67
68
// handles all input field changes, with specific updates called based on input's name
68
69
const handleChange = ( e : React . ChangeEvent < { value : any } > ) => {
69
70
let inputVal = e . target . value ;
70
-
71
+ console . log ( 'inputVal' , inputVal )
71
72
switch ( e . target . name ) {
72
73
case 'display' :
73
74
setDisplayMode ( inputVal ) ;
@@ -187,7 +188,7 @@ const RightContainer = ({isThemeLight}): JSX.Element => {
187
188
if ( compWidth !== '' ) styleObj . width = compWidth ;
188
189
if ( compHeight !== '' ) styleObj . height = compHeight ;
189
190
if ( BGColor !== '' ) styleObj . backgroundColor = BGColor ;
190
-
191
+
191
192
dispatch ( {
192
193
type : 'UPDATE CSS' ,
193
194
payload : { style : styleObj }
@@ -205,6 +206,18 @@ const redoAction = () => {
205
206
dispatch ( { type : 'REDO' , payload : { } } ) ;
206
207
} ;
207
208
209
+ const undoRedoKey = useCallback ( ( e ) => {
210
+ ( e . key === 'z' && e . metaKey && ! e . shiftKey ) ? undoAction ( ) :
211
+ ( e . shiftKey && e . metaKey && e . key === 'z' ) ? redoAction ( ) : '' ;
212
+ } , [ ] ) ;
213
+
214
+ useEffect ( ( ) => {
215
+ document . addEventListener ( "keydown" , undoRedoKey ) ;
216
+ return ( ) => {
217
+ document . removeEventListener ( "keydown" , undoRedoKey ) ;
218
+ } ;
219
+ } , [ ] ) ;
220
+
208
221
// placeholder for handling deleting instance
209
222
const handleDelete = ( ) => {
210
223
dispatch ( { type : 'DELETE CHILD' , payload : { } } ) ;
@@ -331,7 +344,7 @@ const redoAction = () => {
331
344
className = { classes . select }
332
345
inputProps = { { className : isThemeLight ? `${ classes . selectInput } ${ classes . lightThemeFontColor } ` : `${ classes . selectInput } ${ classes . darkThemeFontColor } ` } }
333
346
>
334
- < MenuItem value = "" > </ MenuItem >
347
+ < MenuItem value = "" > none </ MenuItem >
335
348
< MenuItem value = { 'block' } > block</ MenuItem >
336
349
< MenuItem value = { 'inline-block' } > inline-block</ MenuItem >
337
350
< MenuItem value = { 'flex' } > flex</ MenuItem >
@@ -427,7 +440,7 @@ const redoAction = () => {
427
440
className = { classes . select }
428
441
inputProps = { { className : isThemeLight ? `${ classes . selectInput } ${ classes . lightThemeFontColor } ` : `${ classes . selectInput } ${ classes . darkThemeFontColor } ` } }
429
442
>
430
- < MenuItem value = "" > </ MenuItem >
443
+ < MenuItem value = "" > none </ MenuItem >
431
444
< MenuItem value = { 'auto' } > auto</ MenuItem >
432
445
< MenuItem value = { '50%' } > 50%</ MenuItem >
433
446
< MenuItem value = { '25%' } > 25%</ MenuItem >
@@ -449,7 +462,7 @@ const redoAction = () => {
449
462
className = { classes . select }
450
463
inputProps = { { className : isThemeLight ? `${ classes . selectInput } ${ classes . lightThemeFontColor } ` : `${ classes . selectInput } ${ classes . darkThemeFontColor } ` } }
451
464
>
452
- < MenuItem value = "" > </ MenuItem >
465
+ < MenuItem value = "" > none </ MenuItem >
453
466
< MenuItem value = { 'auto' } > auto</ MenuItem >
454
467
< MenuItem value = { '100%' } > 100%</ MenuItem >
455
468
< MenuItem value = { '50%' } > 50%</ MenuItem >
@@ -470,6 +483,7 @@ const redoAction = () => {
470
483
inputProps = { { className : isThemeLight ? `${ classes . selectInput } ${ classes . lightThemeFontColor } ` : `${ classes . selectInput } ${ classes . darkThemeFontColor } ` } }
471
484
value = { BGColor }
472
485
onChange = { handleChange }
486
+ placeholder = "#B6B8B7"
473
487
/>
474
488
</ FormControl >
475
489
</ div >
@@ -515,20 +529,24 @@ const redoAction = () => {
515
529
</ div >
516
530
) }
517
531
< div className = { classes . buttonRow } >
532
+ { /* <HotKeys keyMap={undoKeyMap} handlers={undoHandlers}> */ }
518
533
< Button
519
534
color = "primary"
520
535
className = { classes . button }
521
536
onClick = { undoAction }
522
537
>
523
538
< i className = "fas fa-undo" > </ i >
524
539
</ Button >
540
+ { /* </HotKeys> */ }
541
+ { /* <HotKeys> */ }
525
542
< Button
526
543
color = "primary"
527
544
className = { classes . button }
528
545
onClick = { redoAction }
529
546
>
530
547
< i className = "fas fa-redo" > </ i >
531
548
</ Button >
549
+ { /* </HotKeys> */ }
532
550
</ div >
533
551
</ div >
534
552
0 commit comments