1
1
import React from 'react' ;
2
2
import Grid from '@mui/material/Grid' ;
3
- import ComponentPanelItem from './ComponentPanelItem' ;
3
+ import ComponentPanelItem from '../right /ComponentPanelItem' ;
4
4
import makeStyles from '@mui/styles/makeStyles' ;
5
5
import { useSelector } from 'react-redux' ;
6
6
import { RootState } from '../../redux/store' ;
7
7
// The component panel section of the left panel displays all components and has the ability to add new components
8
8
const ComponentDrag = ( { isThemeLight } ) : JSX . Element => {
9
9
const classes = useStyles ( ) ;
10
- const state = useSelector ( ( store :RootState ) => store . appState )
11
- const isDarkMode = useSelector ( ( store :RootState ) => store . darkMode . isDarkMode ) ;
10
+ const state = useSelector ( ( store : RootState ) => store . appState ) ;
11
+ const isDarkMode = useSelector (
12
+ ( store : RootState ) => store . darkMode . isDarkMode
13
+ ) ;
12
14
const isFocus = ( targetId : Number ) => {
13
15
return state . canvasFocus . componentId === targetId ? true : false ;
14
16
} ;
@@ -19,11 +21,26 @@ const ComponentDrag = ({ isThemeLight }): JSX.Element => {
19
21
{ /* Font size for 'index' in root components in .compPanelItem h3 style.css */ }
20
22
< div className = { classes . panelWrapperList } >
21
23
{ /* Heading just below ADD button */ }
22
- < h4 className = { ! isDarkMode ? classes . lightThemeFontColor : classes . darkThemeFontColor } > { state . projectType === 'Next.js' || state . projectType === 'Gatsby.js' ? 'Pages' : 'Root Components' } </ h4 >
23
- < Grid container direction = "row" justifyContent = "center" alignItems = "center" >
24
+ < h4
25
+ className = {
26
+ ! isDarkMode
27
+ ? classes . lightThemeFontColor
28
+ : classes . darkThemeFontColor
29
+ }
30
+ >
31
+ { state . projectType === 'Next.js' || state . projectType === 'Gatsby.js'
32
+ ? 'Pages'
33
+ : 'Root Components' }
34
+ </ h4 >
35
+ < Grid
36
+ container
37
+ direction = "row"
38
+ justifyContent = "center"
39
+ alignItems = "center"
40
+ >
24
41
{ state . components
25
- . filter ( comp => state . rootComponents . includes ( comp . id ) )
26
- . map ( comp => {
42
+ . filter ( ( comp ) => state . rootComponents . includes ( comp . id ) )
43
+ . map ( ( comp ) => {
27
44
return (
28
45
< ComponentPanelItem
29
46
isFocus = { isFocus ( comp . id ) }
@@ -33,16 +50,28 @@ const ComponentDrag = ({ isThemeLight }): JSX.Element => {
33
50
root = { true }
34
51
isThemeLight = { isThemeLight }
35
52
/>
36
-
37
53
) ;
38
54
} ) }
39
55
</ Grid >
40
56
{ /* Display all reusable components */ }
41
- < h4 className = { ! isDarkMode ? classes . lightThemeFontColor : classes . darkThemeFontColor } > Reusable Components</ h4 >
42
- < Grid container direction = "row" justifyContent = "center" alignItems = "center" >
57
+ < h4
58
+ className = {
59
+ ! isDarkMode
60
+ ? classes . lightThemeFontColor
61
+ : classes . darkThemeFontColor
62
+ }
63
+ >
64
+ Reusable Components
65
+ </ h4 >
66
+ < Grid
67
+ container
68
+ direction = "row"
69
+ justifyContent = "center"
70
+ alignItems = "center"
71
+ >
43
72
{ state . components
44
- . filter ( comp => ! state . rootComponents . includes ( comp . id ) )
45
- . map ( comp => {
73
+ . filter ( ( comp ) => ! state . rootComponents . includes ( comp . id ) )
74
+ . map ( ( comp ) => {
46
75
return (
47
76
< ComponentPanelItem
48
77
isFocus = { isFocus ( comp . id ) }
@@ -55,7 +84,6 @@ const ComponentDrag = ({ isThemeLight }): JSX.Element => {
55
84
) ;
56
85
} ) }
57
86
</ Grid >
58
-
59
87
</ div >
60
88
</ div >
61
89
) ;
@@ -67,7 +95,7 @@ const useStyles = makeStyles({
67
95
flexDirection : 'column' ,
68
96
alignItems : 'center' ,
69
97
flexGrow : 1 ,
70
- overflow : 'auto' ,
98
+ overflow : 'auto'
71
99
} ,
72
100
panelWrapperList : {
73
101
minHeight : '120px' ,
@@ -77,7 +105,7 @@ const useStyles = makeStyles({
77
105
display : 'flex' ,
78
106
flexDirection : 'column' ,
79
107
alignItems : 'center' ,
80
- wordWrap : 'break-word' ,
108
+ wordWrap : 'break-word'
81
109
} ,
82
110
lightThemeFontColor : {
83
111
color : '#155084'
0 commit comments