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 Typography from " @material-ui/core/Typography" ;
8- import SaveIcon from " @material-ui/icons/Save" ;
9- import Paper from " @material-ui/core/Paper" ;
10- import Fab from " @material-ui/core/Fab" ;
11- import { updateHtmlAttr } from " ../actions/components.ts" ;
12- import { HTMLelements , getSize } from " ../utils/htmlElements.util.ts" ;
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 Typography from ' @material-ui/core/Typography' ;
8+ import SaveIcon from ' @material-ui/icons/Save' ;
9+ import Paper from ' @material-ui/core/Paper' ;
10+ import Fab from ' @material-ui/core/Fab' ;
11+ import { updateHtmlAttr } from ' ../actions/components.ts' ;
12+ import { HTMLelements , getSize } from ' ../utils/htmlElements.util.ts' ;
1313
1414const styles = theme => ( {
1515 root : {
16- display : " flex" ,
17- justifyContent : " center" ,
18- flexWrap : " wrap"
16+ display : ' flex' ,
17+ justifyContent : ' center' ,
18+ flexWrap : ' wrap' ,
1919 } ,
2020 cssLabel : {
21- color : " white" ,
22- "&$cssFocused" : {
23- color : "green"
24- }
21+ color : ' white' ,
22+ } ,
23+ cssFocused : {
24+ color : 'green' ,
2525 } ,
2626 input : {
27- color : " #fff" ,
28- opacity : " 0.7" ,
29- marginBottom : "10px"
30- }
27+ color : ' #fff' ,
28+ opacity : ' 0.7' ,
29+ marginBottom : '15px' ,
30+ } ,
3131} ) ;
3232
3333const mapDispatchToProps = dispatch => ( {
34- updateHtmlAttr : ( { attr, value } ) => dispatch ( updateHtmlAttr ( { attr, value } ) )
34+ updateHtmlAttr : ( { attr, value } ) => dispatch ( updateHtmlAttr ( { attr, value } ) ) ,
3535} ) ;
3636
3737const mapStateToProps = store => ( {
3838 focusComponent : store . workspace . focusComponent ,
39- focusChild : store . workspace . focusChild
39+ focusChild : store . workspace . focusChild ,
4040} ) ;
4141
4242class HtmlAttr extends Component {
43- state = HTMLelements [ this . props . focusChild . htmlElement ] . attributes . reduce (
44- ( acc , attr ) => {
45- acc [ attr ] = "" ;
46- return acc ;
47- } ,
48- { }
49- ) ;
43+ state = HTMLelements [ this . props . focusChild . htmlElement ] . attributes . reduce ( ( acc , attr ) => {
44+ acc [ attr ] = '' ;
45+ return acc ;
46+ } , { } ) ;
5047
51- handleSave = attr => {
48+ handleSave = ( attr ) => {
5249 console . log ( attr , this . state [ attr ] ) ;
5350 this . props . updateHtmlAttr ( { attr, value : this . state [ attr ] } ) ;
5451 this . setState ( {
55- [ attr ] : ""
52+ [ attr ] : '' ,
5653 } ) ;
5754 } ;
5855
59- handleChange = event => {
56+ handleChange = ( event ) => {
6057 this . setState ( {
61- [ event . target . id ] : event . target . value . trim ( )
58+ [ event . target . id ] : event . target . value . trim ( ) ,
6259 } ) ;
6360 } ;
6461
6562 render ( ) {
6663 const {
67- focusComponent,
68- classes,
69- deleteProp,
70- addProp,
71- focusChild,
72- updateHtmlAttr
64+ focusComponent, classes, deleteProp, addProp, focusChild, updateHtmlAttr,
7365 } = this . props ;
7466
7567 const focusChildType = focusChild . htmlElement ;
7668
7769 const HtmlForm = HTMLelements [ focusChildType ] . attributes . map ( ( attr , i ) => (
78- < Grid
79- container
80- spacing = { 0 }
81- key = { i }
82- style = { { marginTop : "10px" , marginRight : "20px" } }
83- >
84- < Grid item xs = { 1.5 } >
70+ < Grid container spacing = { 0 } key = { i } style = { { marginTop : '10px' , marginRight : '20px' } } >
71+ < Grid item xs = { 2 } >
8572 < TextField
8673 InputLabelProps = { {
8774 classes : {
8875 root : classes . cssLabel ,
89- focused : classes . cssFocused
90- }
76+ focused : classes . cssFocused ,
77+ input : classes . input ,
78+ } ,
9179 } }
9280 InputProps = { {
9381 classes : {
9482 root : classes . cssOutlinedInput ,
9583 focused : classes . cssFocused ,
9684 notchedOutline : classes . notchedOutline ,
97- input : classes . input
98- }
85+ input : classes . input ,
86+ } ,
9987 } }
100- style = { { background : " #424242" , height : " 70%" } }
88+ style = { { background : ' #424242' , height : ' 70%' } }
10189 label = { attr }
10290 variant = "outlined"
10391 id = { attr }
@@ -112,9 +100,9 @@ class HtmlAttr extends Component {
112100 color = "default"
113101 aria-label = "Save"
114102 style = { {
115- marginLeft : " 10px" ,
116- marginTop : " 5px" ,
117- marginBottom : " 10px"
103+ marginLeft : ' 10px' ,
104+ marginTop : ' 5px' ,
105+ marginBottom : ' 10px' ,
118106 } }
119107 onClick = { ( ) => this . handleSave ( attr ) }
120108 >
@@ -123,22 +111,20 @@ class HtmlAttr extends Component {
123111 </ Fab >
124112 </ Grid >
125113 < Grid item xs = { 4 } >
126- < Paper className = { classes . root } style = { { height : "70%" } } >
127- < p style = { { color : "black" } } >
128- { focusChild . HTMLInfo [ attr ]
129- ? focusChild . HTMLInfo [ attr ]
130- : " no attribute assigned" }
114+ < Paper className = { classes . root } style = { { height : '70%' } } >
115+ < p style = { { color : 'black' } } >
116+ { focusChild . HTMLInfo [ attr ] ? focusChild . HTMLInfo [ attr ] : ' no attribute assigned' }
131117 </ p >
132118 </ Paper >
133119 </ Grid >
134120 </ Grid >
135121 ) ) ;
136122
137- return < div className = { " htmlattr" } > { HtmlForm } </ div > ;
123+ return < div className = { ' htmlattr' } > { HtmlForm } </ div > ;
138124 }
139125}
140126
141127export default connect (
142128 mapStateToProps ,
143- mapDispatchToProps
129+ mapDispatchToProps ,
144130) ( withStyles ( styles ) ( HtmlAttr ) ) ;
0 commit comments