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 PropTypes from "prop-types";
import { Card } from "@mui/material";
import { makeStyles } from "@mui/material/styles";
import styles from "../styles";
import LoginComponent from "./LoginComponent";
const useStyles = makeStyles(styles);
const LoginCard = ({ credentials, onChange, onLogin }) => {
const classes = useStyles();
return (
<div className={classes.appLogin}>
<div style={styles.appLogin}>
<Card variant="outlined">
<LoginComponent credentials={credentials} onChange={onChange} onLogin={onLogin} />
</Card>

View File

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

View File

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