Refactor login component styles

master^2
Tudor Stanciu 2024-03-25 02:51:56 +02:00
parent 968fd2e785
commit 79bd644f95
3 changed files with 8 additions and 17 deletions

View File

@ -1,17 +1,12 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { Card } from "@mui/material"; import { Card } from "@mui/material";
import { makeStyles } from "@mui/material/styles";
import styles from "../styles"; import styles from "../styles";
import LoginComponent from "./LoginComponent"; import LoginComponent from "./LoginComponent";
const useStyles = makeStyles(styles);
const LoginCard = ({ credentials, onChange, onLogin }) => { const LoginCard = ({ credentials, onChange, onLogin }) => {
const classes = useStyles();
return ( return (
<div className={classes.appLogin}> <div style={styles.appLogin}>
<Card variant="outlined"> <Card variant="outlined">
<LoginComponent credentials={credentials} onChange={onChange} onLogin={onLogin} /> <LoginComponent credentials={credentials} onChange={onChange} onLogin={onLogin} />
</Card> </Card>

View File

@ -1,23 +1,19 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { makeStyles } from "@mui/material/styles";
import { TextField, InputAdornment, Button, CardActions, CardContent } from "@mui/material"; import { TextField, InputAdornment, Button, CardActions, CardContent } from "@mui/material";
import { AccountCircleOutlined } from "@mui/icons-material"; import { AccountCircleOutlined } from "@mui/icons-material";
import PasswordField from "../../../components/common/inputs/PasswordField"; import PasswordField from "../../../components/common/inputs/PasswordField";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import styles from "../styles"; import styles from "../styles";
const useStyles = makeStyles(styles);
const LoginComponent = ({ credentials, onChange, onLogin }) => { const LoginComponent = ({ credentials, onChange, onLogin }) => {
const classes = useStyles();
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<> <>
<CardContent> <CardContent>
<TextField <TextField
className={classes.field} sx={styles.field}
id="username" id="username"
label={t("Login.Username")} label={t("Login.Username")}
onChange={onChange("userName")} onChange={onChange("userName")}
@ -34,7 +30,7 @@ const LoginComponent = ({ credentials, onChange, onLogin }) => {
<PasswordField <PasswordField
id="password" id="password"
label={t("Login.Password")} label={t("Login.Password")}
className={classes.field} sx={styles.field}
onChange={onChange("password")} onChange={onChange("password")}
value={credentials.password} value={credentials.password}
onKeyDown={e => { onKeyDown={e => {
@ -42,8 +38,8 @@ const LoginComponent = ({ credentials, onChange, onLogin }) => {
}} }}
/> />
</CardContent> </CardContent>
<CardActions className={classes.actions}> <CardActions sx={styles.actions}>
<Button className={classes.onRight} variant="contained" color="primary" onClick={onLogin}> <Button sx={styles.onRight} variant="contained" color="primary" onClick={onLogin}>
{t("Login.Label")} {t("Login.Label")}
</Button> </Button>
</CardActions> </CardActions>

View File

@ -1,4 +1,4 @@
const styles = theme => ({ const styles = {
onRight: { onRight: {
marginLeft: "auto" marginLeft: "auto"
}, },
@ -9,13 +9,13 @@ const styles = theme => ({
alignItems: "center" alignItems: "center"
}, },
field: { field: {
margin: theme.spacing(1), margin: 1,
width: "300px" width: "300px"
}, },
actions: { actions: {
paddingRight: "16px", paddingRight: "16px",
paddingLeft: "16px" paddingLeft: "16px"
} }
}); };
export default styles; export default styles;