1
- import React , { Component , Fragment } from " react" ;
2
- import { connect } from " react-redux" ;
3
- import { withStyles } from " @material-ui/core/styles" ;
4
- import Grid from " @material-ui/core/Grid" ;
5
- import TextField from " @material-ui/core/TextField" ;
6
- import IconButton from " @material-ui/core/IconButton" ;
7
- import { updateHtmlAttr } from "../actions/components" ;
8
- import UpdateIcon from "@material-ui/icons/Update" ;
9
- import { HTMLelements , getSize } from " ../utils/htmlElements.util" ;
1
+ import React , { Component , Fragment } from ' react' ;
2
+ import { connect } from ' react-redux' ;
3
+ import { withStyles } from ' @material-ui/core/styles' ;
4
+ import Grid from ' @material-ui/core/Grid' ;
5
+ import TextField from ' @material-ui/core/TextField' ;
6
+ import IconButton from ' @material-ui/core/IconButton' ;
7
+ import UpdateIcon from '@material-ui/icons/Update' ;
8
+ import { updateHtmlAttr } from '../actions/components' ;
9
+ import { HTMLelements , getSize } from ' ../utils/htmlElements.util' ;
10
10
11
11
const styles = theme => ( {
12
12
root : {
13
- display : " flex" ,
14
- justifyContent : " center" ,
15
- flexWrap : " wrap"
13
+ display : ' flex' ,
14
+ justifyContent : ' center' ,
15
+ flexWrap : ' wrap' ,
16
16
} ,
17
17
chip : {
18
18
margin : theme . spacing . unit ,
19
- color : " #eee" ,
20
- backgroundColor : " #333333"
19
+ color : ' #eee' ,
20
+ backgroundColor : ' #333333' ,
21
21
} ,
22
22
column : {
23
- display : " inline-flex" ,
24
- alignItems : " baseline"
23
+ display : ' inline-flex' ,
24
+ alignItems : ' baseline' ,
25
25
} ,
26
26
icon : {
27
- fontSize : " 20px" ,
28
- color : " #eee" ,
29
- opacity : " 0.7" ,
30
- transition : " all .2s ease" ,
27
+ fontSize : ' 20px' ,
28
+ color : ' #eee' ,
29
+ opacity : ' 0.7' ,
30
+ transition : ' all .2s ease' ,
31
31
32
- " &:hover" : {
33
- color : " red"
34
- }
32
+ ' &:hover' : {
33
+ color : ' red' ,
34
+ } ,
35
35
} ,
36
36
cssLabel : {
37
- color : " white" ,
37
+ color : ' white' ,
38
38
39
- " &$cssFocused" : {
40
- color : " green"
41
- }
39
+ ' &$cssFocused' : {
40
+ color : ' green' ,
41
+ } ,
42
42
} ,
43
43
cssFocused : { } ,
44
44
input : {
45
- color : " #fff" ,
46
- opacity : " 0.7" ,
47
- marginBottom : " 10px"
45
+ color : ' #fff' ,
46
+ opacity : ' 0.7' ,
47
+ marginBottom : ' 10px' ,
48
48
} ,
49
49
light : {
50
- color : " #eee"
50
+ color : ' #eee' ,
51
51
} ,
52
52
avatar : {
53
- color : " #eee" ,
54
- fontSize : " 10px"
55
- }
53
+ color : ' #eee' ,
54
+ fontSize : ' 10px' ,
55
+ } ,
56
56
} ) ;
57
57
58
58
const mapDispatchToProps = dispatch => ( {
59
- updateHtmlAttr : ( { attr, value } ) => dispatch ( updateHtmlAttr ( { attr, value } ) )
59
+ updateHtmlAttr : ( { attr, value } ) => dispatch ( updateHtmlAttr ( { attr, value } ) ) ,
60
60
} ) ;
61
61
62
62
const mapStateToProps = store => ( {
63
63
focusComponent : store . workspace . focusComponent ,
64
- focusChild : store . workspace . focusChild
64
+ focusChild : store . workspace . focusChild ,
65
65
} ) ;
66
66
67
67
class HtmlAttr extends Component {
68
- state = HTMLelements [ this . props . focusChild . htmlElement ] . attributes . reduce (
69
- ( acc , attr ) => {
70
- acc [ attr ] = "" ;
71
- return acc ;
72
- } ,
73
- { }
74
- ) ;
68
+ state = HTMLelements [ this . props . focusChild . htmlElement ] . attributes . reduce ( ( acc , attr ) => {
69
+ acc [ attr ] = '' ;
70
+ return acc ;
71
+ } , { } ) ;
75
72
76
- handleChange = event => {
77
- console . log ( event . target . id , event . target . value ) ;
73
+ handleChange = ( event ) => {
78
74
this . setState ( {
79
- [ event . target . id ] : event . target . value . trim ( )
75
+ [ event . target . id ] : event . target . value . trim ( ) ,
80
76
} ) ;
81
77
} ;
82
78
@@ -88,77 +84,63 @@ class HtmlAttr extends Component {
88
84
89
85
render ( ) {
90
86
const {
91
- focusComponent,
92
- classes,
93
- deleteProp,
94
- addProp,
95
- focusChild,
96
- updateHtmlAttr
87
+ focusComponent, classes, deleteProp, addProp, focusChild, updateHtmlAttr,
97
88
} = this . props ;
98
89
99
90
const focusChildType = focusChild . htmlElement ;
100
91
101
92
console . log ( focusChild ) ;
102
93
103
- const HtmlForm = HTMLelements [ focusChildType ] . attributes . map ( ( attr , i ) => {
104
- return (
105
- < Grid
106
- container
107
- spacing = { 8 }
108
- alignItems = "baseline"
109
- align = "stretch"
110
- key = { i }
111
- >
112
- < Grid item xs = { 6 } >
113
- < TextField
114
- id = { attr }
115
- label = { attr }
116
- margin = "normal"
117
- autoFocus
118
- // style={(marginLeft = "20px")}
119
- onChange = { this . handleChange }
120
- value = { this . state [ attr ] }
121
- InputProps = { {
122
- className : classes . input
123
- } }
124
- InputLabelProps = { {
125
- className : classes . input
126
- } }
127
- />
128
- < IconButton
129
- aria-label = "Update"
130
- onClick = { ( ) => {
131
- updateHtmlAttr ( { attr, value : this . state [ attr ] } ) ;
132
- } }
133
- // onClick={() => {
134
- // addChild({ title, childType: "COMP" });
135
- // }}
136
- >
137
- < UpdateIcon />
138
- </ IconButton >
139
- </ Grid >
140
- < Grid item xs = { 6 } >
141
- < TextField
142
- disabled
143
- id = "filled-disabled"
144
- label = { attr }
145
- defaultValue = { focusChild . HTMLInfo [ attr ] }
146
- style = { { background : "bcbcbc" } }
147
- className = { classes . textField }
148
- margin = "normal"
149
- variant = "filled"
150
- />
151
- </ Grid >
94
+ const HtmlForm = HTMLelements [ focusChildType ] . attributes . map ( ( attr , i ) => (
95
+ < Grid container spacing = { 8 } alignItems = "baseline" align = "stretch" key = { i } >
96
+ < Grid item xs = { 6 } >
97
+ < TextField
98
+ id = { attr }
99
+ label = { attr }
100
+ margin = "normal"
101
+ autoFocus
102
+ // style={(marginLeft = "20px")}
103
+ onChange = { this . handleChange }
104
+ value = { this . state [ attr ] }
105
+ InputProps = { {
106
+ className : classes . input ,
107
+ } }
108
+ InputLabelProps = { {
109
+ className : classes . input ,
110
+ } }
111
+ />
112
+ < IconButton
113
+ aria-label = "Update"
114
+ onClick = { ( ) => {
115
+ updateHtmlAttr ( { attr, value : this . state [ attr ] } ) ;
116
+ } }
117
+ // onClick={() => {
118
+ // addChild({ title, childType: "COMP" });
119
+ // }}
120
+ >
121
+ < UpdateIcon />
122
+ </ IconButton >
152
123
</ Grid >
153
- ) ;
154
- } ) ;
155
- // console.log(HtmlForm);
124
+ < Grid item xs = { 6 } >
125
+ < TextField
126
+ disabled
127
+ id = "filled-disabled"
128
+ label = { attr }
129
+ defaultValue = { focusChild . HTMLInfo [ attr ] }
130
+ style = { { background : 'bcbcbc' } }
131
+ className = { classes . textField }
132
+ margin = "normal"
133
+ variant = "filled"
134
+ />
135
+ </ Grid >
136
+ </ Grid >
137
+ ) ) ;
156
138
157
- return < div className = { " htmlattr" } > { HtmlForm } </ div > ;
139
+ return < div className = { ' htmlattr' } > { HtmlForm } </ div > ;
158
140
}
159
141
}
160
142
161
143
export default connect (
162
144
mapStateToProps ,
163
- mapDispatchToProps
145
+ mapDispatchToProps ,
164
146
) ( withStyles ( styles ) ( HtmlAttr ) ) ;
0 commit comments