mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
* save work * fix reset styling * fix toast reducer * update non-react deps * update react libraries * remove jquery, use sanitize-html instead * add missing change * fix deps and dev deps * update workflow to target Node 16 * run @mui/codemod to remove @mui/styles * add default body font size * update react 17 to 18 * declare enum before use * add rel attr to links * fix font sizing issue * trailing commas * refactor deep destructuring Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
60 lines
1.3 KiB
TypeScript
60 lines
1.3 KiB
TypeScript
import React from 'react';
|
|
import { styled } from '@mui/material/styles';
|
|
import TextField from '@mui/material/TextField';
|
|
import ErrorOutlinedIcon from '@mui/icons-material/ErrorOutlined';
|
|
|
|
import './InputField.css';
|
|
|
|
const PREFIX = 'InputField';
|
|
|
|
const classes = {
|
|
root: `${PREFIX}-root`
|
|
};
|
|
|
|
const Root = styled('div')(({ theme }) => ({
|
|
[`&.${classes.root}`]: {
|
|
'& .InputField-error': {
|
|
color: theme.palette.error.main
|
|
},
|
|
|
|
'& .InputField-warning': {
|
|
color: theme.palette.warning.main
|
|
},
|
|
},
|
|
}));
|
|
|
|
const InputField = ({ input, meta, ...args }) => {
|
|
const { touched, error, warning } = meta;
|
|
|
|
return (
|
|
<Root 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"
|
|
size="small"
|
|
fullWidth={true}
|
|
/>
|
|
</Root>
|
|
);
|
|
};
|
|
|
|
export default InputField;
|