-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from JohannesKonings/serial_gameid
Serial gameid
- Loading branch information
Showing
2 changed files
with
522 additions
and
502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,92 @@ | ||
import React from "react"; | ||
import classNames from "classnames"; | ||
import PropTypes from "prop-types"; | ||
// @material-ui/core components | ||
import { makeStyles } from "@material-ui/core/styles"; | ||
import FormControl from "@material-ui/core/FormControl"; | ||
import InputLabel from "@material-ui/core/InputLabel"; | ||
import Input from "@material-ui/core/Input"; | ||
// @material-ui/icons | ||
import Clear from "@material-ui/icons/Clear"; | ||
import Check from "@material-ui/icons/Check"; | ||
// core components | ||
import styles from "assets/jss/material-dashboard-react/components/customInputStyle.js"; | ||
|
||
const useStyles = makeStyles(styles); | ||
|
||
export default function CustomInput(props) { | ||
const classes = useStyles(); | ||
const { | ||
formControlProps, | ||
labelText, | ||
id, | ||
labelProps, | ||
inputProps, | ||
error, | ||
success | ||
} = props; | ||
|
||
const labelClasses = classNames({ | ||
[" " + classes.labelRootError]: error, | ||
[" " + classes.labelRootSuccess]: success && !error | ||
}); | ||
const underlineClasses = classNames({ | ||
[classes.underlineError]: error, | ||
[classes.underlineSuccess]: success && !error, | ||
[classes.underline]: true | ||
}); | ||
const marginTop = classNames({ | ||
[classes.marginTop]: labelText === undefined | ||
}); | ||
return ( | ||
<FormControl | ||
{...formControlProps} | ||
className={formControlProps.className + " " + classes.formControl} | ||
> | ||
{labelText !== undefined ? ( | ||
<InputLabel | ||
className={classes.labelRoot + labelClasses} | ||
htmlFor={id} | ||
{...labelProps} | ||
> | ||
{labelText} | ||
</InputLabel> | ||
) : null} | ||
<Input | ||
classes={{ | ||
root: marginTop, | ||
disabled: classes.disabled, | ||
underline: underlineClasses | ||
}} | ||
id={id} | ||
{...inputProps} | ||
/> | ||
{error ? ( | ||
<Clear className={classes.feedback + " " + classes.labelRootError} /> | ||
) : success ? ( | ||
<Check className={classes.feedback + " " + classes.labelRootSuccess} /> | ||
) : null} | ||
</FormControl> | ||
); | ||
} | ||
|
||
CustomInput.propTypes = { | ||
labelText: PropTypes.node, | ||
labelProps: PropTypes.object, | ||
id: PropTypes.string, | ||
inputProps: PropTypes.object, | ||
formControlProps: PropTypes.object, | ||
error: PropTypes.bool, | ||
success: PropTypes.bool | ||
}; | ||
import React from "react"; | ||
import classNames from "classnames"; | ||
import PropTypes from "prop-types"; | ||
// @material-ui/core components | ||
import { makeStyles } from "@material-ui/core/styles"; | ||
import FormControl from "@material-ui/core/FormControl"; | ||
import InputLabel from "@material-ui/core/InputLabel"; | ||
import Input from "@material-ui/core/Input"; | ||
// @material-ui/icons | ||
import Clear from "@material-ui/icons/Clear"; | ||
import Check from "@material-ui/icons/Check"; | ||
// core components | ||
import styles from "assets/jss/material-dashboard-react/components/customInputStyle.js"; | ||
|
||
const useStyles = makeStyles(styles); | ||
|
||
export default function CustomInput(props) { | ||
const classes = useStyles(); | ||
const [value, setValue] = React.useState(""); | ||
|
||
const { | ||
formControlProps, | ||
labelText, | ||
id, | ||
labelProps, | ||
inputProps, | ||
error, | ||
success, | ||
textFieldValue | ||
} = props; | ||
|
||
const handleChange = event => { | ||
setValue(event.target.value); | ||
textFieldValue(event.target.value); | ||
}; | ||
|
||
const labelClasses = classNames({ | ||
[" " + classes.labelRootError]: error, | ||
[" " + classes.labelRootSuccess]: success && !error | ||
}); | ||
const underlineClasses = classNames({ | ||
[classes.underlineError]: error, | ||
[classes.underlineSuccess]: success && !error, | ||
[classes.underline]: true | ||
}); | ||
const marginTop = classNames({ | ||
[classes.marginTop]: labelText === undefined | ||
}); | ||
return ( | ||
<FormControl | ||
{...formControlProps} | ||
className={formControlProps.className + " " + classes.formControl} | ||
> | ||
{labelText !== undefined ? ( | ||
<InputLabel | ||
className={classes.labelRoot + labelClasses} | ||
htmlFor={id} | ||
{...labelProps} | ||
> | ||
{labelText} | ||
</InputLabel> | ||
) : null} | ||
<Input | ||
classes={{ | ||
root: marginTop, | ||
disabled: classes.disabled, | ||
underline: underlineClasses | ||
}} | ||
id={id} | ||
value={value} | ||
onChange={handleChange} | ||
{...inputProps} | ||
/> | ||
{error ? ( | ||
<Clear className={classes.feedback + " " + classes.labelRootError} /> | ||
) : success ? ( | ||
<Check className={classes.feedback + " " + classes.labelRootSuccess} /> | ||
) : null} | ||
</FormControl> | ||
); | ||
} | ||
|
||
CustomInput.propTypes = { | ||
labelText: PropTypes.node, | ||
labelProps: PropTypes.object, | ||
id: PropTypes.string, | ||
inputProps: PropTypes.object, | ||
formControlProps: PropTypes.object, | ||
error: PropTypes.bool, | ||
success: PropTypes.bool, | ||
textFieldValue: PropTypes.func | ||
}; |
Oops, something went wrong.