1
- import React , { useContext } from 'react' ;
1
+ import React from 'react' ;
2
2
import Grid from '@mui/material/Grid' ;
3
3
import HTMLItem from './HTMLItem' ;
4
4
import { RootState } from '../../redux/store' ;
@@ -19,70 +19,87 @@ Hook state:
19
19
*/
20
20
// Extracted the drag and drop functionality from HTMLPanel to make a modular component that can hang wherever the future designers may choose.
21
21
const DragDropPanel = ( props ) : JSX . Element => {
22
- const isDarkMode = useSelector ( ( store :RootState ) => store . darkMode . isDarkMode ) ;
23
- const dispatch = useDispatch ( ) ;
24
- const { state, contextParam } = useSelector ( ( store :RootState ) => ( {
25
- state : store . appState ,
26
- contextParam : store . contextSlice ,
27
- } ) ) ;
22
+ const isDarkMode = useSelector (
23
+ ( store : RootState ) => store . darkMode . isDarkMode
24
+ ) ;
25
+ const dispatch = useDispatch ( ) ;
26
+ const { state, contextParam } = useSelector ( ( store : RootState ) => ( {
27
+ state : store . appState ,
28
+ contextParam : store . contextSlice
29
+ } ) ) ;
28
30
const handleDelete = ( id : number ) : void => {
29
- dispatch ( deleteElement ( { id :id , contextParam : contextParam } ) )
30
-
31
+ dispatch ( deleteElement ( { id : id , contextParam : contextParam } ) ) ;
31
32
} ;
32
33
// filter out separator so that it will not appear on the html panel
33
- const htmlTypesToRender = state . HTMLTypes . filter ( type => type . name !== 'separator' ) ;
34
+ const htmlTypesToRender = state . HTMLTypes . filter (
35
+ ( type ) => type . name !== 'separator'
36
+ ) ;
34
37
return (
35
38
< div className = { `${ ! isDarkMode ? 'HTMLItems' : 'HTMLItemsDark' } ` } >
36
39
< div id = "HTMLItemsTopHalf" >
37
- < Grid
38
- id = "HTMLItemsGrid"
39
- >
40
- < h3 style = { { color : ! isDarkMode ? '#000' : '#fff' } } > HTML ELEMENTS</ h3 >
41
- { htmlTypesToRender . map ( option => {
42
- if ( ! [ 'Switch' , 'LinkTo' , 'LinkHref' , 'Image' , 'Route' ] . includes ( option . name ) ) {
40
+ < Grid id = "HTMLItemsGrid" >
41
+ < h3 style = { { color : ! isDarkMode ? '#000' : '#fff' } } >
42
+ HTML ELEMENTS
43
+ </ h3 >
44
+ { htmlTypesToRender . map ( ( option ) => {
45
+ if (
46
+ ! [ 'Switch' , 'LinkTo' , 'LinkHref' , 'Image' , 'Route' ] . includes (
47
+ option . name
48
+ )
49
+ ) {
43
50
return (
44
51
< HTMLItem
45
52
name = { option . name }
46
53
key = { `html-${ option . name } ` }
47
54
id = { option . id }
48
55
Icon = { option . icon }
49
56
handleDelete = { handleDelete }
50
-
51
57
/>
52
58
) ;
53
59
}
54
-
55
60
} ) }
56
- { state . projectType === "Classic React" ? < h3 style = { { color : ! isDarkMode ? '#000' : '#fff' } } > REACT ROUTER</ h3 > : null }
57
- { htmlTypesToRender . map ( option => {
58
- if ( ( option . name === 'Switch' || option . name === 'LinkTo' || option . name === 'Route' ) && state . projectType === "Classic React" ) {
61
+ { state . projectType === 'Classic React' ? (
62
+ < h3 style = { { color : ! isDarkMode ? '#000' : '#fff' } } >
63
+ REACT ROUTER
64
+ </ h3 >
65
+ ) : null }
66
+ { htmlTypesToRender . map ( ( option ) => {
67
+ if (
68
+ ( option . name === 'Switch' ||
69
+ option . name === 'LinkTo' ||
70
+ option . name === 'Route' ) &&
71
+ state . projectType === 'Classic React'
72
+ ) {
59
73
return (
60
74
< HTMLItem
61
75
name = { option . name }
62
76
key = { `html-${ option . name } ` }
63
77
id = { option . id }
64
78
Icon = { option . icon }
65
79
handleDelete = { handleDelete }
66
-
67
80
/>
68
81
) ;
69
82
}
70
83
} ) }
71
84
72
- { state . projectType === "Next.js" ? < h3 style = { { color : ! isDarkMode ? '#000' : "#fff" } } > Next.js</ h3 > : null }
73
- { htmlTypesToRender . map ( option => {
74
- if ( ( option . framework === 'nextjs' ) && state . projectType === "Next.js" ) {
75
- return (
76
- < HTMLItem
77
- name = { option . name }
78
- key = { `html-${ option . name } ` }
79
- id = { option . id }
80
- Icon = { option . icon }
81
- handleDelete = { handleDelete }
82
-
83
- />
84
- ) ;
85
- }
85
+ { state . projectType === 'Next.js' ? (
86
+ < h3 style = { { color : ! isDarkMode ? '#000' : '#fff' } } > Next.js</ h3 >
87
+ ) : null }
88
+ { htmlTypesToRender . map ( ( option ) => {
89
+ if (
90
+ option . framework === 'nextjs' &&
91
+ state . projectType === 'Next.js'
92
+ ) {
93
+ return (
94
+ < HTMLItem
95
+ name = { option . name }
96
+ key = { `html-${ option . name } ` }
97
+ id = { option . id }
98
+ Icon = { option . icon }
99
+ handleDelete = { handleDelete }
100
+ />
101
+ ) ;
102
+ }
86
103
} ) }
87
104
</ Grid >
88
105
</ div >
0 commit comments