1
1
import React , { Fragment } from 'react' ;
2
2
import { withStyles } from '@material-ui/core/styles' ;
3
3
import Typography from '@material-ui/core/Typography' ;
4
+ import KeyboardArrowRightRoundedIcon from '@material-ui/icons/KeyboardArrowRightRounded' ;
5
+ import KeyboardArrowDownRoundedIcon from '@material-ui/icons/KeyboardArrowDownRounded' ;
4
6
import List from '@material-ui/core/List' ;
5
7
import ListItem from '@material-ui/core/ListItem' ;
6
8
import ListItemText from '@material-ui/core/ListItemText' ;
@@ -16,7 +18,7 @@ import Button from '@material-ui/core/Button';
16
18
import Tooltip from '@material-ui/core/Tooltip' ;
17
19
import { ComponentInt , ComponentsInt , ChildInt } from '../utils/interfaces.ts' ;
18
20
19
- const LeftColExpansionPanel = ( props : any ) => {
21
+ const LeftColExpansionPanel : React . FC < Props > = ( props ) => {
20
22
const {
21
23
classes,
22
24
focusComponent,
@@ -32,126 +34,124 @@ const LeftColExpansionPanel = (props: any) => {
32
34
const { title, id, color, expanded, stateful, children } = component ;
33
35
34
36
return (
35
- < Grid container spacing = { 16 } direction = "row" justify = "flex-start" alignItems = "center" >
36
- < Grid item xs = { 9 } >
37
- < div
38
- className = { classes . root }
39
- style = { ! expanded ? { } : { boxShadow : '0 10px 10px rgba(0,0,0,0.25)' } }
40
- >
41
- < Grid item xs = { 12 } style = { { color : 'red' } } >
42
- < List style = { { color : 'red' } } >
43
- < ListItem
44
- button
45
- style = { { color : 'red' } }
46
- onClick = { ( ) => {
47
- // changeFocusComponent({ title });
48
- toggleExpansionPanel ( id ) ;
49
- } }
50
- >
51
- < ListItemText
52
- disableTypography
53
- className = { classes . light }
54
- primary = {
55
- < Typography type = "body2" style = { { color, fontSize : '20px' , paddingBottom : '0px' } } >
56
- { title }
57
- </ Typography >
58
- }
59
- style = { { color } }
60
- />
61
- </ ListItem >
62
- </ List >
63
- </ Grid >
64
- { ! expanded ? (
65
- < div />
66
- ) : (
67
- < Fragment >
68
- < div className = { classes . margin } >
69
- < InputLabel
70
- className = { classes . light }
71
- htmlFor = 'stateful'
72
- style = { {
73
- color : '#D3D3D3' ,
74
- marginBottom : '10px' ,
75
- marginTop : '0px' ,
76
- marginLeft : '11px' ,
77
- padding : '0px' ,
78
- fontSize : '18px' ,
79
- } }
80
- > State?</ InputLabel >
81
- < Switch
82
- checked = { stateful }
83
- onChange = { ( e ) => updateComponent ( id , { stateful : e . target . checked } ) }
84
- value = 'stateful'
85
- color = 'primary'
86
- id = 'stateful'
87
- />
88
- </ div >
89
- < div className = { classes . margin } >
90
- < InputLabel
91
- id = "label"
92
- className = { classes . light }
93
- style = { {
94
- color : '#D3D3D3' ,
95
- marginBottom : '10px' ,
96
- marginTop : '0px' ,
97
- marginLeft : '11px' ,
98
- padding : '0px' ,
99
- fontSize : '18px' ,
100
- } } >
101
- Component Type</ InputLabel >
102
- < Select
103
- id = "select"
104
- value = "class"
105
- className = { classes . light }
106
- style = { {
107
- color : '#D3D3D3' ,
108
- marginBottom : '10px' ,
109
- marginTop : '0px' ,
110
- marginLeft : '11px' ,
111
- padding : '0px' ,
112
- fontSize : '18px' ,
113
- } } >
114
- < MenuItem value = "class" > Class</ MenuItem >
115
- < MenuItem value = "functional" > Functional</ MenuItem >
116
- </ Select >
117
- </ div >
118
- < Button
119
- variant = "text"
120
- size = "small"
121
- color = "default"
122
- aria-label = "Delete"
123
- className = { classes . margin }
124
- onClick = { ( ) => deleteComponent ( id )
37
+ < Grid container spacing = { 16 } direction = "row" justify = "flex-start" alignItems = "center" style = { { position : 'relative' , margin : '5px 0' , width : '100%' , backgroundColor : '#303147' , borderRadius : '6px' } } >
38
+ < Grid
39
+ item xs = { 12 }
40
+ style = { ! expanded ? { padding : '0' } : { backgroundColor : color , borderRadius : '6px' , color : '#fff' , padding : '0 10px 20px' } }
41
+ >
42
+ < Grid item xs = { 12 } >
43
+ < List >
44
+ < ListItem
45
+ button
46
+ onClick = { ( ) => {
47
+ // changeFocusComponent({ title });
48
+ toggleExpansionPanel ( id ) ;
49
+ } }
50
+ style = { { padding : '10px' } }
51
+ >
52
+ < ListItemText
53
+ disableTypography
54
+ className = { classes . light }
55
+ primary = {
56
+ < Typography type = "body2" style = { ! expanded ? { display :'flex' , alignItems : 'center' , fontSize : '16px' , color } : { display :'flex' , alignItems : 'center' , fontSize : '16px' , color : '#fff' } } >
57
+ { ! expanded ? < KeyboardArrowRightRoundedIcon style = { { fontSize : '24px' , marginRight : '5px' , color } } /> : < KeyboardArrowDownRoundedIcon style = { { fontSize : '24px' , marginRight : '5px' , color : '#fff' } } /> }
58
+ { title }
59
+ </ Typography >
125
60
}
61
+ style = { { color } }
62
+ />
63
+ </ ListItem >
64
+ </ List >
65
+ </ Grid >
66
+ { ! expanded ? (
67
+ < div />
68
+ ) : (
69
+ < Fragment >
70
+ < div className = { classes . margin } >
71
+ < InputLabel
72
+ htmlFor = 'stateful'
126
73
style = { {
127
- color : '#D3D3D3 ' ,
74
+ color : '#fff ' ,
128
75
marginBottom : '10px' ,
129
76
marginTop : '0px' ,
130
77
marginLeft : '11px' ,
131
78
padding : '0px' ,
79
+ fontSize : '18px' ,
132
80
} }
133
- >
134
- < DeleteIcon style = { { color : '#D3D3D3' } } />
135
- Delete Component
136
- </ Button >
137
- </ Fragment >
138
- ) }
139
- </ div >
140
- </ Grid >
141
-
142
- < Grid item xs = { 3 } >
81
+ > State?</ InputLabel >
82
+ < Switch
83
+ checked = { stateful }
84
+ onChange = { ( e ) => updateComponent ( id , { stateful : e . target . checked } ) }
85
+ value = 'stateful'
86
+ color = 'primary'
87
+ id = 'stateful'
88
+ />
89
+ </ div >
90
+ < div className = { classes . margin } >
91
+ < InputLabel
92
+ id = "label"
93
+ style = { {
94
+ color : '#fff' ,
95
+ marginBottom : '10px' ,
96
+ marginTop : '0px' ,
97
+ marginLeft : '11px' ,
98
+ padding : '0px' ,
99
+ fontSize : '18px' ,
100
+ } } >
101
+ Component Type</ InputLabel >
102
+ < Select
103
+ id = "select"
104
+ value = "class"
105
+ style = { {
106
+ color : '#fff' ,
107
+ marginBottom : '10px' ,
108
+ marginTop : '0px' ,
109
+ marginLeft : '11px' ,
110
+ padding : '0px' ,
111
+ fontSize : '18px' ,
112
+ } } >
113
+ < MenuItem value = "class" > Class</ MenuItem >
114
+ < MenuItem value = "functional" > Functional</ MenuItem >
115
+ </ Select >
116
+ </ div >
117
+ < Button
118
+ variant = "text"
119
+ size = "small"
120
+ color = "default"
121
+ aria-label = "Delete"
122
+ className = { classes . margin }
123
+ onClick = { ( ) => deleteComponent ( id )
124
+ }
125
+ style = { {
126
+ color : '#fff' ,
127
+ marginBottom : '10px' ,
128
+ marginTop : '0px' ,
129
+ marginLeft : '11px' ,
130
+ padding : '0px' ,
131
+ } }
132
+ >
133
+ < DeleteIcon style = { { color : '#fff' } } />
134
+ Delete Component
135
+ </ Button >
136
+ </ Fragment >
137
+ ) }
143
138
{ /* checks to see if the current component pane is expanded, if the children of the current component has the id of any of the current components or if every component is currently not expanded */ }
144
139
{ expanded || children . find ( ( childId : number ) => childId === id ) || components . every ( ( comp ) => ! comp . expanded ) ? (
145
140
< div />
146
141
) : (
147
- < Tooltip title = "Add Child" aria-label = "Add Child" placement = "left" >
142
+ < Tooltip
143
+ title = "Add Child"
144
+ aria-label = "Add Child"
145
+ placement = "left"
146
+ style = { { position : 'absolute' , right : '0' , top : '0' , bottom : '0' } }
147
+ >
148
148
< IconButton
149
149
aria-label = "Add"
150
150
onClick = { ( ) => {
151
151
addChild ( { title, childType : 'COMP' } ) ;
152
152
} }
153
153
>
154
- < AddIcon style = { { color, float : 'right' } } />
154
+ < AddIcon style = { { color } } />
155
155
</ IconButton >
156
156
</ Tooltip >
157
157
) }
0 commit comments