@@ -113,14 +113,15 @@ const HTMLPanel = (props): JSX.Element => {
113
113
114
114
const handleSubmit = ( e ) => {
115
115
e . preventDefault ( ) ;
116
-
116
+ console . log ( 'did submit' ) ;
117
117
if ( tag . trim ( ) === '' || name . trim ( ) === '' ) return triggerError ( 'empty' ) ;
118
118
if ( ! tag . charAt ( 0 ) . match ( / [ a - z A - Z ] / ) || ! name . charAt ( 0 ) . match ( / [ a - z A - Z ] / ) )
119
119
return triggerError ( 'letters' ) ;
120
120
if ( ! alphanumeric ( tag ) || ! alphanumeric ( name ) )
121
121
return triggerError ( 'symbolsDetected' ) ;
122
122
if ( checkNameDupe ( tag ) || checkNameDupe ( name ) ) return triggerError ( 'dupe' ) ;
123
123
if ( name . length > 10 ) return triggerError ( 'length' ) ;
124
+ setAlertOpen ( true ) ;
124
125
createOption ( tag , name ) ;
125
126
resetError ( ) ;
126
127
} ;
@@ -143,8 +144,6 @@ const HTMLPanel = (props): JSX.Element => {
143
144
} ;
144
145
} , [ ] ) ;
145
146
146
- const handleAlertOpen = ( ) => setAlertOpen ( true ) ;
147
-
148
147
const handleAlertClose = (
149
148
event : React . SyntheticEvent | Event ,
150
149
reason ?: string
@@ -162,126 +161,84 @@ const HTMLPanel = (props): JSX.Element => {
162
161
163
162
return (
164
163
< >
165
- < div className = "HTMLItemCreate" >
166
- < div className = { `${ classes . addComponentWrapper } ` } >
167
- < div className = { classes . inputWrapper } >
168
- < form onSubmit = { handleSubmit } className = "customForm" >
169
- < TextField
170
- id = "outlined-basic"
171
- label = "Element Name"
172
- variant = "outlined"
173
- size = "small"
174
- value = { name }
175
- autoComplete = "off"
176
- placeholder = "Element Name"
177
- sx = { { width : '80%' } }
178
- onChange = { handleNameChange }
179
- helperText = { errorMsg }
180
- />
181
- < div
182
- style = { { display : 'flex' , alignItems : 'center' , width : '100%' } }
183
- >
184
- < TextField
185
- id = "outlined-basic"
186
- label = "HTML Tag"
187
- variant = "outlined"
188
- size = "small"
189
- value = { tag }
190
- autoComplete = "off"
191
- placeholder = "HTML Tag"
192
- sx = { { width : '80%' } }
193
- onChange = { handleTagChange }
194
- helperText = { errorMsg }
195
- />
196
- < Fab
197
- id = "submitButton"
198
- type = "submit"
199
- color = "primary"
200
- aria-label = "add"
201
- size = "small"
202
- value = "Add Element"
203
- sx = { { width : '15%' , height : 40 , borderRadius : 1 } }
204
- onClick = { handleAlertOpen }
205
- >
206
- < AddIcon />
207
- </ Fab >
208
- </ div >
209
- </ form >
210
- </ div >
164
+ < form onSubmit = { handleSubmit } className = { classes . customForm } >
165
+ < div className = { classes . inputWrapper } >
166
+ < TextField
167
+ id = "outlined-basic"
168
+ label = "Element Name"
169
+ variant = "outlined"
170
+ size = "small"
171
+ value = { name }
172
+ autoComplete = "off"
173
+ sx = { { width : '80%' } }
174
+ onChange = { handleNameChange }
175
+ helperText = { errorMsg }
176
+ />
211
177
</ div >
212
- </ div >
213
- < >
214
- < Snackbar
215
- open = { alertOpen }
216
- autoHideDuration = { 3000 }
217
- anchorOrigin = { { vertical : 'top' , horizontal : 'center' } }
178
+ < div className = { classes . inputWrapper } >
179
+ < TextField
180
+ id = "outlined-basic"
181
+ label = "HTML Tag"
182
+ variant = "outlined"
183
+ size = "small"
184
+ value = { tag }
185
+ autoComplete = "off"
186
+ sx = { { width : '80%' } }
187
+ onChange = { handleTagChange }
188
+ helperText = { errorMsg }
189
+ />
190
+ < Fab
191
+ id = "submitButton"
192
+ type = "submit"
193
+ color = "primary"
194
+ aria-label = "add"
195
+ size = "small"
196
+ value = "Add Element"
197
+ sx = { { width : '15%' , height : 40 , borderRadius : 1 } }
198
+ onClick = { handleSubmit }
199
+ >
200
+ < AddIcon />
201
+ </ Fab >
202
+ </ div >
203
+ </ form >
204
+
205
+ < Snackbar
206
+ open = { alertOpen }
207
+ autoHideDuration = { 3000 }
208
+ anchorOrigin = { { vertical : 'top' , horizontal : 'center' } }
209
+ onClose = { handleAlertClose }
210
+ >
211
+ < Alert
218
212
onClose = { handleAlertClose }
213
+ severity = "success"
214
+ sx = { { width : '100%' , color : 'white' , backgroundColor : '#f88e16' } }
219
215
>
220
- < Alert
221
- onClose = { handleAlertClose }
222
- severity = "success"
223
- sx = { { width : '100%' , color : 'white' , backgroundColor : '#f88e16' } }
224
- >
225
- HTML Tag Created!
226
- </ Alert >
227
- </ Snackbar >
228
- </ >
216
+ HTML Tag Created!
217
+ </ Alert >
218
+ </ Snackbar >
229
219
</ >
230
220
) ;
231
221
} ;
232
222
233
223
const useStyles = makeStyles ( {
234
- inputField : {
235
- marginTop : '10px' ,
236
- borderRadius : '5px' ,
237
- whiteSpace : 'nowrap' ,
238
- overflowX : 'hidden' ,
239
- textOverflow : 'ellipsis' ,
240
- backgroundColor : 'rgba(255,255,255,0.15)' ,
241
- margin : '0px 0px 0px 10px' ,
242
- width : '100%' ,
243
- height : '30px'
224
+ customForm : {
225
+ display : 'flex' ,
226
+ flexDirection : 'column' ,
227
+ alignItems : 'start'
244
228
} ,
245
229
inputWrapper : {
230
+ display : 'flex' ,
246
231
width : '100%' ,
247
232
marginBottom : '10px' , // was originally 10px, decreased to 0 to decrease overall menu height
248
- alignItems : 'center'
249
- } ,
250
- addComponentWrapper : {
251
- width : '100%'
252
- } ,
253
- input : {
254
- width : '500px' ,
255
- whiteSpace : 'nowrap' ,
256
- overflowX : 'hidden' ,
257
- textOverflow : 'ellipsis' ,
258
- margin : '0px 0px 0px 0px' ,
259
- alignSelf : 'center'
260
- } ,
261
- lightThemeFontColor : {
262
- color : 'white' ,
263
- '& .MuiInputBase-root' : {
264
- color : 'rgba (0, 0, 0, 0.54)'
265
- }
266
- } ,
267
- darkThemeFontColor : {
268
- color : '#ffffff' ,
269
- '& .MuiInputBase-root' : {
270
- color : '#fff'
271
- }
233
+ justifyContent : 'start'
272
234
} ,
273
235
errorMessage : {
274
236
display : 'flex' ,
275
- alignSelf : 'center ' ,
237
+ alignSelf : 'start ' ,
276
238
fontSize : '11px' ,
277
239
marginTop : '10px' ,
278
- width : '150px'
279
- } ,
280
- errorMessageLight : {
281
- color : '#6B6B6B'
282
- } ,
283
- errorMessageDark : {
284
- color : 'white'
240
+ width : '150px' ,
241
+ borderRadius : '5px'
285
242
}
286
243
} ) ;
287
244
0 commit comments