mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-01-09 11:46:22 -08:00
* turn autocomplete off by default on inputs * trim input fields onSubmit * move trim to form submit * cleanup * remove dead code * protect trim against null values * make password optional on Login for servers that allow unregisted logins * cleanup Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import React from 'react';
|
|
import { makeStyles } from '@material-ui/core/styles';
|
|
import TextField from '@material-ui/core/TextField';
|
|
import ErrorOutlinedIcon from '@material-ui/icons/ErrorOutlined';
|
|
|
|
import './InputField.css';
|
|
|
|
const useStyles = makeStyles(theme => ({
|
|
root: {
|
|
'& .InputField-error': {
|
|
color: theme.palette.error.main
|
|
},
|
|
|
|
'& .InputField-warning': {
|
|
color: theme.palette.warning.main
|
|
}
|
|
},
|
|
}));
|
|
|
|
const InputField = ({ input, meta: { touched, error, warning }, ...args }) => {
|
|
const classes = useStyles();
|
|
|
|
return (
|
|
<div className={'InputField ' + classes.root}>
|
|
{ touched && (
|
|
<div className="InputField-validation">
|
|
{
|
|
(error &&
|
|
<div className="InputField-error">
|
|
{error}
|
|
<ErrorOutlinedIcon style={{ fontSize: 'small', fontWeight: 'bold' }} />
|
|
</div>
|
|
) ||
|
|
|
|
(warning && <div className="InputField-warning">{warning}</div>)
|
|
}
|
|
</div>
|
|
) }
|
|
|
|
<TextField
|
|
autoComplete='off'
|
|
{ ...input }
|
|
{ ...args }
|
|
className="rounded"
|
|
variant="outlined"
|
|
margin="dense"
|
|
fullWidth={true}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default InputField;
|