1
- import React , { Component } from ' react' ;
2
- import { connect } from ' react-redux' ;
3
- import { compose } from ' redux' ;
1
+ import React , { Component } from " react" ;
2
+ import { connect } from " react-redux" ;
3
+ import { compose } from " redux" ;
4
4
// import PropTypes from 'prop-types';
5
- import FormControl from '@material-ui/core/FormControl' ;
6
- import TextField from '@material-ui/core/TextField' ;
7
- import Button from '@material-ui/core/Button' ;
8
- import AddIcon from '@material-ui/icons/Add' ;
9
- import Grid from '@material-ui/core/Grid' ;
10
- import { withStyles } from '@material-ui/core/styles' ;
11
- import LeftColExpansionPanel from '../components/LeftColExpansionPanel.jsx' ;
5
+ import FormControl from "@material-ui/core/FormControl" ;
6
+ import TextField from "@material-ui/core/TextField" ;
7
+ import Button from "@material-ui/core/Button" ;
8
+ import AddIcon from "@material-ui/icons/Add" ;
9
+ import Grid from "@material-ui/core/Grid" ;
10
+ import { withStyles } from "@material-ui/core/styles" ;
11
+ import LeftColExpansionPanel from "../components/LeftColExpansionPanel.jsx" ;
12
+ import HTMLComponentPanel from "../components/HTMLComponentPanel.jsx" ;
13
+
12
14
// import createModal from '../utils/createModal.util';
13
- import * as actions from '../actions/components' ;
15
+ import * as actions from "../actions/components" ;
16
+
17
+ function styles ( ) {
18
+ return {
19
+ cssLabel : {
20
+ color : "white" ,
21
+
22
+ "&$cssFocused" : {
23
+ color : "green"
24
+ }
25
+ } ,
26
+ cssFocused : { } ,
27
+ input : {
28
+ color : "#fff" ,
29
+ opacity : "0.7" ,
30
+ marginBottom : "10px"
31
+ } ,
32
+ underline : {
33
+ color : "white" ,
34
+ "&::before" : {
35
+ color : "white"
36
+ }
37
+ } ,
38
+ button : {
39
+ color : "#fff" ,
40
+
41
+ "&:disabled" : {
42
+ color : "grey"
43
+ }
44
+ } ,
45
+ clearButton : {
46
+ top : "96%" ,
47
+ position : "sticky!important" ,
48
+ zIndex : "1" ,
49
+
50
+ "&:disabled" : {
51
+ color : "grey" ,
52
+ backgroundColor : "#424242"
53
+ }
54
+ }
55
+ } ;
56
+ }
14
57
15
58
const mapDispatchToProps = dispatch => ( {
16
59
addComponent : ( { title } ) => dispatch ( actions . addComponent ( { title } ) ) ,
17
60
updateComponent : ( {
18
- id, index, newParentId = null , color = null , stateful = null ,
19
- } ) => dispatch (
20
- actions . updateComponent ( {
21
- id,
22
- index,
23
- newParentId,
24
- color,
25
- stateful,
26
- } ) ,
27
- ) ,
61
+ id,
62
+ index,
63
+ newParentId = null ,
64
+ color = null ,
65
+ stateful = null
66
+ } ) =>
67
+ dispatch (
68
+ actions . updateComponent ( {
69
+ id,
70
+ index,
71
+ newParentId,
72
+ color,
73
+ stateful
74
+ } )
75
+ ) ,
28
76
// deleteComponent: ({ index, id, parentIds }) => dispatch(actions.deleteComponent({ index, id, parentIds })),
29
77
// moveToBottom: componentId => dispatch(actions.moveToBottom(componentId)),
30
78
// moveToTop: componentId => dispatch(actions.moveToTop(componentId)),
31
79
// openExpansionPanel: component => dispatch(actions.openExpansionPanel(component)),
32
80
// deleteAllData: () => dispatch(actions.deleteAllData()),
33
81
addChild : ( { title } ) => dispatch ( actions . addChild ( { title } ) ) ,
34
- changeFocusComponent : ( { title } ) => dispatch ( actions . changeFocusComponent ( { title } ) ) ,
35
- changeFocusChild : ( { title, childId } ) => dispatch ( actions . changeFocusChild ( { title, childId } ) ) ,
82
+ changeFocusComponent : ( { title } ) =>
83
+ dispatch ( actions . changeFocusComponent ( { title } ) ) ,
84
+ changeFocusChild : ( { title, childId } ) =>
85
+ dispatch ( actions . changeFocusChild ( { title, childId } ) )
36
86
} ) ;
37
87
38
88
class LeftContainer extends Component {
39
89
state = {
40
- componentName : '' ,
90
+ componentName : ""
41
91
} ;
42
92
43
- handleChange = ( event ) => {
93
+ handleChange = event => {
44
94
this . setState ( {
45
- [ event . target . name ] : event . target . value ,
95
+ [ event . target . name ] : event . target . value
46
96
} ) ;
47
97
} ;
48
98
49
99
handleAddComponent = ( ) => {
50
100
this . props . addComponent ( { title : this . state . componentName } ) ;
51
101
this . setState ( {
52
- componentName : '' ,
102
+ componentName : ""
53
103
} ) ;
54
104
} ;
55
105
@@ -64,7 +114,7 @@ class LeftContainer extends Component {
64
114
addChild,
65
115
changeFocusComponent,
66
116
changeFocusChild,
67
- selectableChildren,
117
+ selectableChildren
68
118
} = this . props ;
69
119
const { componentName } = this . state ;
70
120
@@ -93,13 +143,13 @@ class LeftContainer extends Component {
93
143
< Grid item xs = { 10 } >
94
144
< TextField
95
145
id = "title-input"
96
- label = "Add a new component"
97
- placeholder = "AppComponent "
146
+ label = "Add class component"
147
+ placeholder = "Name of component "
98
148
margin = "normal"
99
149
autoFocus
100
150
onChange = { this . handleChange }
101
- onKeyPress = { ( ev ) => {
102
- if ( ev . key === ' Enter' ) {
151
+ onKeyPress = { ev => {
152
+ if ( ev . key === " Enter" ) {
103
153
// Do code here
104
154
this . handleAddComponent ( ) ;
105
155
ev . preventDefault ( ) ;
@@ -109,10 +159,10 @@ class LeftContainer extends Component {
109
159
name = "componentName"
110
160
className = { classes . light }
111
161
InputProps = { {
112
- className : classes . input ,
162
+ className : classes . input
113
163
} }
114
164
InputLabelProps = { {
115
- className : classes . input ,
165
+ className : classes . input
116
166
} }
117
167
/>
118
168
</ Grid >
@@ -131,6 +181,12 @@ class LeftContainer extends Component {
131
181
</ Grid >
132
182
</ Grid >
133
183
< div className = "expansionPanel" > { componentsExpansionPanel } </ div >
184
+ < div className = { "htmlPanel" } >
185
+ < HTMLComponentPanel
186
+ focusComponent = { focusComponent }
187
+ addChild = { addChild }
188
+ />
189
+ </ div >
134
190
</ div >
135
191
) ;
136
192
}
@@ -140,8 +196,8 @@ export default compose(
140
196
withStyles ( styles ) ,
141
197
connect (
142
198
null ,
143
- mapDispatchToProps ,
144
- ) ,
199
+ mapDispatchToProps
200
+ )
145
201
) ( LeftContainer ) ;
146
202
147
203
// LeftContainer.propTypes = {
@@ -157,44 +213,3 @@ export default compose(
157
213
// totalComponents: PropTypes.number.isRequired,
158
214
// classes: PropTypes.object,
159
215
// };
160
-
161
- function styles ( ) {
162
- return {
163
- cssLabel : {
164
- color : 'white' ,
165
-
166
- '&$cssFocused' : {
167
- color : 'green' ,
168
- } ,
169
- } ,
170
- cssFocused : { } ,
171
- input : {
172
- color : '#fff' ,
173
- opacity : '0.7' ,
174
- marginBottom : '10px' ,
175
- } ,
176
- underline : {
177
- color : 'white' ,
178
- '&::before' : {
179
- color : 'white' ,
180
- } ,
181
- } ,
182
- button : {
183
- color : '#fff' ,
184
-
185
- '&:disabled' : {
186
- color : 'grey' ,
187
- } ,
188
- } ,
189
- clearButton : {
190
- top : '96%' ,
191
- position : 'sticky!important' ,
192
- zIndex : '1' ,
193
-
194
- '&:disabled' : {
195
- color : 'grey' ,
196
- backgroundColor : '#424242' ,
197
- } ,
198
- } ,
199
- } ;
200
- }
0 commit comments