@@ -62,7 +62,7 @@ const availableButtonTypes = {
62
62
// function for generating the button types for select dropdown
63
63
// uses Object.keys method on object of drop down types
64
64
const buttonTypeOptions = [
65
- < option value = "" key = "" /> ,
65
+ < option value = '' key = '' /> ,
66
66
...Object . keys ( availableButtonTypes ) . map ( type => (
67
67
< option value = { type } key = { type } style = { { color : '#000' } } >
68
68
{ type == null ? '' : type }
@@ -76,13 +76,16 @@ let buttonTypeTemp: string;
76
76
// HtmlAttr is creating attributes grabbed from htmlElement & placing them
77
77
// as the new state
78
78
class HtmlAttr extends Component < HTMLAttrPropsInt , StateInt > {
79
- state = HTMLelements [ this . props . focusChild . htmlElement ] . attributes . reduce ( ( acc , attr ) => {
80
- acc [ attr ] = '' ;
79
+ state = HTMLelements [ this . props . focusChild . htmlElement ] . attributes . reduce (
80
+ ( acc , attr ) => {
81
+ acc [ attr ] = '' ;
81
82
82
- return acc ;
83
- } , { } ) ;
83
+ return acc ;
84
+ } ,
85
+ { }
86
+ ) ;
84
87
85
- // looks like:
88
+ // State looks like:
86
89
// className: '',
87
90
// id: '',
88
91
// type: '',
@@ -123,96 +126,108 @@ class HtmlAttr extends Component<HTMLAttrPropsInt, StateInt> {
123
126
124
127
const focusChildType = focusChild . htmlElement ;
125
128
126
- const HtmlForm = HTMLelements [ focusChildType ] . attributes . map ( ( attr : string , i : number ) => (
127
- < Grid container spacing = { 0 } key = { i } style = { { marginTop : '10px' , marginRight : '20px' } } >
128
- < Grid item xs = { 1 } >
129
- { /* if the attr being rendered for the HTMLForm is a button, then give it a special
129
+ const HtmlForm = HTMLelements [ focusChildType ] . attributes . map (
130
+ ( attr : string , i : number ) => (
131
+ < Grid
132
+ container
133
+ spacing = { 0 }
134
+ key = { i }
135
+ style = { { marginTop : '10px' , marginRight : '20px' } }
136
+ >
137
+ < Grid item xs = { 1 } >
138
+ { /* if the attr being rendered for the HTMLForm is a button, then give it a special
130
139
condition to render a "select" component rather than a text-input component */ }
131
- { attr == 'type' ? (
132
- < FormControl required >
133
- < InputLabel className = { classes . light } htmlFor = "htmlType" >
134
- Type
135
- </ InputLabel >
136
- < Select
137
- native
138
- className = { classes . light }
139
- id = "htmlType"
140
- placeholder = "title"
141
- onChange = { this . handleChange }
142
- value = { buttonTypeTemp }
143
- defaultValue = { 'button' }
144
- style = { {
145
- background : '#424242' ,
146
- height : '45px' ,
147
- width : '146px' ,
148
- marginBottom : '23px' ,
149
- marginTop : '0px' ,
150
- color : '#fff' ,
151
- paddingLeft : '14px'
140
+ { attr == 'type' ? (
141
+ < FormControl required >
142
+ < InputLabel className = { classes . light } htmlFor = 'htmlType' >
143
+ Type
144
+ </ InputLabel >
145
+ < Select
146
+ native
147
+ className = { classes . light }
148
+ id = 'htmlType'
149
+ placeholder = 'title'
150
+ onChange = { this . handleChange }
151
+ value = { buttonTypeTemp }
152
+ defaultValue = { 'button' }
153
+ style = { {
154
+ background : '#424242' ,
155
+ height : '45px' ,
156
+ width : '146px' ,
157
+ marginBottom : '23px' ,
158
+ marginTop : '0px' ,
159
+ color : '#fff' ,
160
+ paddingLeft : '14px'
161
+ } }
162
+ required
163
+ >
164
+ { buttonTypeOptions }
165
+ </ Select >
166
+ </ FormControl >
167
+ ) : (
168
+ < TextField
169
+ InputLabelProps = { {
170
+ classes : {
171
+ root : classes . cssLabel ,
172
+ focused : classes . cssFocused ,
173
+ input : classes . input
174
+ }
175
+ } }
176
+ InputProps = { {
177
+ classes : {
178
+ root : classes . cssOutlinedInput ,
179
+ focused : classes . cssFocused ,
180
+ notchedOutline : classes . notchedOutline ,
181
+ input : classes . input
182
+ }
152
183
} }
153
- required
154
- >
155
- { buttonTypeOptions }
156
- </ Select >
157
- </ FormControl >
158
- ) : (
159
- < TextField
160
- InputLabelProps = { {
161
- classes : {
162
- root : classes . cssLabel ,
163
- focused : classes . cssFocused ,
164
- input : classes . input
165
- }
184
+ style = { { background : '#424242' , height : '70%' } }
185
+ label = { attr }
186
+ variant = 'outlined'
187
+ id = { attr }
188
+ onChange = { this . handleChange }
189
+ value = { this . state [ attr ] }
190
+ />
191
+ ) }
192
+ </ Grid >
193
+ < Grid item xs = { 2 } >
194
+ < Fab
195
+ variant = 'extended'
196
+ size = 'small'
197
+ color = 'default'
198
+ aria-label = 'Save'
199
+ style = { {
200
+ marginLeft : '10px' ,
201
+ marginTop : '5px' ,
202
+ marginBottom : '10px'
166
203
} }
167
- InputProps = { {
168
- classes : {
169
- root : classes . cssOutlinedInput ,
170
- focused : classes . cssFocused ,
171
- notchedOutline : classes . notchedOutline ,
172
- input : classes . input
173
- }
204
+ onClick = { e => {
205
+ e . preventDefault ( ) ;
206
+ this . handleSave ( attr ) ;
174
207
} }
175
- style = { { background : '#424242' , height : '70%' } }
176
- label = { attr }
177
- variant = "outlined"
178
- id = { attr }
179
- onChange = { this . handleChange }
180
- value = { this . state [ attr ] }
181
- />
182
- ) }
183
- </ Grid >
184
- < Grid item xs = { 2 } >
185
- < Fab
186
- variant = "extended"
187
- size = "small"
188
- color = "default"
189
- aria-label = "Save"
190
- style = { {
191
- marginLeft : '10px' ,
192
- marginTop : '5px' ,
193
- marginBottom : '10px'
194
- } }
195
- onClick = { e => {
196
- e . preventDefault ( ) ;
197
- this . handleSave ( attr ) ;
198
- } }
199
- >
200
- < SaveIcon />
201
- Save
202
- </ Fab >
203
- </ Grid >
204
- < Grid item xs = { 3 } >
205
- < Paper className = { classes . root } style = { { height : '70%' } } >
206
- < p style = { { color : 'black' } } >
207
- { focusChild . HTMLInfo [ attr ] ? focusChild . HTMLInfo [ attr ] : ' no attribute assigned' }
208
- </ p >
209
- </ Paper >
208
+ >
209
+ < SaveIcon />
210
+ Save
211
+ </ Fab >
212
+ </ Grid >
213
+ < Grid item xs = { 3 } >
214
+ < Paper className = { classes . root } style = { { height : '70%' } } >
215
+ < p style = { { color : 'black' } } >
216
+ { focusChild . HTMLInfo [ attr ]
217
+ ? focusChild . HTMLInfo [ attr ]
218
+ : ' no attribute assigned' }
219
+ </ p >
220
+ </ Paper >
221
+ </ Grid >
210
222
</ Grid >
211
- </ Grid >
212
- ) ) ;
223
+ )
224
+ ) ;
213
225
214
226
return < div className = { 'htmlattr' } > { HtmlForm } </ div > ;
215
227
}
216
228
}
217
229
218
- export default connect ( mapStateToProps , mapDispatchToProps ) ( withStyles ( styles ) ( HtmlAttr ) ) ;
230
+ export default connect (
231
+ mapStateToProps ,
232
+ mapDispatchToProps
233
+ ) ( withStyles ( styles ) ( HtmlAttr ) ) ;
0 commit comments