@@ -5,10 +5,16 @@ import ParagraphIcon from '@material-ui/icons/LocalParking';
5
5
import FormIcon from '@material-ui/icons/Description' ;
6
6
import Grid from '@material-ui/core/Grid' ;
7
7
import ComponentPanelItem from './ComponentPanelItem' ;
8
+ import ComponentPanelRoutingItem from './ComponentPanelRoutingItem' ;
8
9
import TextField from '@material-ui/core/TextField' ;
9
10
import Button from '@material-ui/core/Button' ;
10
11
import FormControlLabel from '@material-ui/core/FormControlLabel' ;
12
+ import FormControl from '@material-ui/core/FormControl' ;
13
+ import Checkbox from '@material-ui/core/Checkbox' ;
11
14
import Switch from '@material-ui/core/Switch' ;
15
+ import InputLabel from '@material-ui/core/InputLabel' ;
16
+ import MenuItem from '@material-ui/core/MenuItem' ;
17
+ import Select from '@material-ui/core/Select' ;
12
18
13
19
import { makeStyles } from '@material-ui/core/styles' ;
14
20
@@ -17,16 +23,37 @@ const useStyles = makeStyles({
17
23
marginTop : '15px'
18
24
} ,
19
25
inputWrapper : {
20
- height : '115px' ,
26
+ // height: '115px',
21
27
textAlign : 'center' ,
22
28
display : 'flex' ,
23
- justifyContent : 'center' ,
24
- paddingLeft : '35px' ,
29
+ alignItems : 'center' ,
30
+ justifyContent : 'space-between' ,
31
+ // paddingLeft: '35px',
25
32
marginBottom : '15px'
26
33
} ,
34
+ addComponentWrapper : {
35
+ border : '1px solid rgba(70,131,83)' ,
36
+ padding : '20px' ,
37
+ margin : '20px'
38
+ } ,
39
+ rootCheckBox : { } ,
40
+ rootCheckBoxLabel : {
41
+ color : 'white'
42
+ } ,
43
+ projectTypeWrapper : {
44
+ paddingLeft : '20px' ,
45
+ paddingRight : '20px' ,
46
+ marginBottom : '15px' ,
47
+ width : '100%'
48
+ } ,
49
+ projectSelector : {
50
+ backgroundColor : 'rgba(255,255,255,0.15)' ,
51
+ width : '317px' ,
52
+ color : '#fff'
53
+ } ,
27
54
panelWrapper : {
28
55
width : '100%' ,
29
- marginTop : '15px' ,
56
+ marginTop : '15px'
30
57
} ,
31
58
panelWrapperList : {
32
59
maxHeight : '675px' ,
@@ -35,6 +62,10 @@ const useStyles = makeStyles({
35
62
marginLeft : '-15px' ,
36
63
marginRight : '-15px'
37
64
} ,
65
+ panelSubheader : {
66
+ textAlign : 'center' ,
67
+ color : '#fff'
68
+ } ,
38
69
input : {
39
70
color : '#fff' ,
40
71
borderRadius : '5px' ,
@@ -59,16 +90,19 @@ const useStyles = makeStyles({
59
90
marginLeft : '10px'
60
91
} ,
61
92
button : {
62
- fontSize : '1rem'
93
+ fontSize : '1rem' ,
94
+ height : '40px' ,
95
+ maginTop : '10px' ,
96
+ width : '100%' ,
97
+ // border: '1px solid rgba(70,131,83)',
98
+ backgroundColor : 'rgba(1,212,109,0.1)'
63
99
} ,
64
100
rootToggle : {
65
101
color : '#01d46d' ,
66
102
fontSize : '0.85rem'
67
- } ,
68
-
103
+ }
69
104
} ) ;
70
105
71
-
72
106
const ComponentPanel = ( ) : JSX . Element => {
73
107
const classes = useStyles ( ) ;
74
108
const [ state , dispatch ] = useContext ( stateContext ) ;
@@ -144,9 +178,14 @@ const ComponentPanel = (): JSX.Element => {
144
178
resetError ( ) ;
145
179
} ;
146
180
181
+ const handleProjectChange = event => {
182
+ const projectType = event . target . value ;
183
+ dispatch ( { type : 'CHANGE PROJECT TYPE' , payload : { projectType } } ) ;
184
+ } ;
185
+
147
186
const isFocus = ( targetId : Number ) => {
148
187
return state . canvasFocus . componentId === targetId ? true : false ;
149
- }
188
+ } ;
150
189
151
190
const setFocus = ( targetId : Number ) => {
152
191
const focusTarget = state . components . filter ( comp => {
@@ -159,53 +198,107 @@ const ComponentPanel = (): JSX.Element => {
159
198
160
199
return (
161
200
< div className = { classes . panelWrapper } >
162
- < div className = { classes . inputWrapper } >
163
- < TextField
164
- color = { 'primary' }
165
- label = "Component Name"
166
- variant = "outlined"
167
- className = { classes . inputField }
168
- InputProps = { { className : classes . input } }
169
- InputLabelProps = { { className : classes . inputLabel } }
170
- value = { compName }
171
- error = { errorStatus }
172
- helperText = { errorStatus ? errorMsg : '' }
173
- onChange = { handleNameInput }
174
- />
175
- < div className = { classes . btnGroup } >
201
+ < div className = { classes . projectTypeWrapper } >
202
+ < FormControl >
203
+ { /* <InputLabel id="project-type-label" className={classes.inputLabel}>
204
+ Project Type
205
+ </InputLabel> */ }
206
+ < Select
207
+ variant = "outlined"
208
+ labelId = "project-type-label"
209
+ id = "demo-simple-select"
210
+ className = { classes . projectSelector }
211
+ value = { state . projectType }
212
+ onChange = { handleProjectChange }
213
+ >
214
+ < MenuItem value = { 'Next.js' } > Next.js</ MenuItem >
215
+ < MenuItem value = { 'Classic React' } > Classic React</ MenuItem >
216
+ </ Select >
217
+ </ FormControl >
218
+ </ div >
219
+
220
+ < div className = { classes . addComponentWrapper } >
221
+ < div >
222
+ < div className = { classes . inputWrapper } >
223
+ < TextField
224
+ color = { 'primary' }
225
+ label = "Component Name"
226
+ variant = "outlined"
227
+ className = { classes . inputField }
228
+ InputProps = { { className : classes . input } }
229
+ InputLabelProps = { { className : classes . inputLabel } }
230
+ value = { compName }
231
+ error = { errorStatus }
232
+ helperText = { errorStatus ? errorMsg : '' }
233
+ onChange = { handleNameInput }
234
+ />
235
+ < div className = { classes . btnGroup } >
236
+ < FormControlLabel
237
+ value = "top"
238
+ control = {
239
+ < Checkbox color = "primary" onChange = { toggleRootStatus } />
240
+ }
241
+ label = { state . projectType === 'Next.js' ? 'Page' : 'Root' }
242
+ className = { classes . rootCheckBoxLabel }
243
+ labelPlacement = "top"
244
+ />
245
+ </ div >
246
+ </ div >
176
247
< Button
177
248
className = { classes . button }
178
249
color = "primary"
179
250
onClick = { handleNameSubmit }
180
251
>
181
252
ADD
182
253
</ Button >
183
- < FormControlLabel
184
- control = {
185
- < Switch
186
- checked = { isRoot }
187
- onChange = { toggleRootStatus }
188
- color = "primary"
189
- />
190
- }
191
- className = { classes . rootToggle }
192
- label = "ROOT"
193
- />
194
254
</ div >
195
255
</ div >
196
256
< div className = { classes . panelWrapperList } >
257
+ < h4 > { state . projectType === 'Next.js' ? 'Pages' : 'Root components' } </ h4 >
197
258
< Grid container direction = "row" justify = "center" alignItems = "center" >
198
- { state . components . map ( comp => (
199
- < ComponentPanelItem
200
- isFocus = { isFocus ( comp . id ) }
201
- key = { `comp-${ comp . id } ` }
202
- name = { comp . name }
203
- id = { comp . id }
204
- root = { state . rootComponents . includes ( comp . id ) }
205
- focusClick = { ( ) => setFocus ( comp . id ) }
206
- />
207
- ) ) }
259
+ { state . components
260
+ . filter ( comp => state . rootComponents . includes ( comp . id ) )
261
+ . map ( comp => (
262
+ < ComponentPanelItem
263
+ isFocus = { isFocus ( comp . id ) }
264
+ key = { `comp-${ comp . id } ` }
265
+ name = { comp . name }
266
+ id = { comp . id }
267
+ root = { true }
268
+ focusClick = { ( ) => setFocus ( comp . id ) }
269
+ />
270
+ ) ) }
271
+ </ Grid >
272
+ < h4 > Reusable components</ h4 >
273
+ < Grid container direction = "row" justify = "center" alignItems = "center" >
274
+ { state . components
275
+ . filter ( comp => ! state . rootComponents . includes ( comp . id ) )
276
+ . map ( comp => (
277
+ < ComponentPanelItem
278
+ isFocus = { isFocus ( comp . id ) }
279
+ key = { `comp-${ comp . id } ` }
280
+ name = { comp . name }
281
+ id = { comp . id }
282
+ root = { false }
283
+ focusClick = { ( ) => setFocus ( comp . id ) }
284
+ />
285
+ ) ) }
208
286
</ Grid >
287
+ { state . projectType === 'Next.js' ? (
288
+ < React . Fragment >
289
+ < h4 > Next.js components</ h4 >
290
+ < Grid
291
+ container
292
+ direction = "row"
293
+ justify = "center"
294
+ alignItems = "center"
295
+ >
296
+ < ComponentPanelRoutingItem key = { 'premadecomp-1' } />
297
+ </ Grid >
298
+ </ React . Fragment >
299
+ ) : (
300
+ ''
301
+ ) }
209
302
</ div >
210
303
</ div >
211
304
) ;
0 commit comments