feat: getting rid of tab index -1 and setting form with semantics on login and register

This commit is contained in:
Caio Cabral committed 2024-11-01 19:10:50 -04:00
1 parent 8f603d1a5d
commit 4f647028e7
5 files changed
+98 -34

No files matched your search

+36 -10
View File
@@ -51,6 +51,10 @@ const LandingPage = ({ onContinue }) => {
stroke: theme.palette.other.icon, stroke: theme.palette.other.icon,
}, },
}, },
"&:focus-visible": {
outline: `2px solid ${theme.palette.primary.main}`,
outlineOffset: `2px`,
},
}} }}
> >
<Mail /> <Mail />
@@ -137,11 +141,14 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
<Typography component="h1">Log In</Typography> <Typography component="h1">Log In</Typography>
<Typography>Enter your email address</Typography> <Typography>Enter your email address</Typography>
</Box> </Box>
<Box textAlign="left"> <Box
<form textAlign="left"
component="form"
noValidate noValidate
spellCheck={false} spellCheck={false}
onSubmit={onSubmit} onSubmit={onSubmit}
display="grid"
gap={{ xs: theme.spacing(12), sm: theme.spacing(16) }}
> >
<Field <Field
type="email" type="email"
@@ -156,8 +163,6 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
error={errors.email} error={errors.email}
ref={inputRef} ref={inputRef}
/> />
</form>
</Box>
<Stack <Stack
direction="row" direction="row"
justifyContent="space-between" justifyContent="space-between"
@@ -171,8 +176,11 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
"& svg.MuiSvgIcon-root": { "& svg.MuiSvgIcon-root": {
mr: theme.spacing(3), mr: theme.spacing(3),
}, },
"&:focus-visible": {
outline: `2px solid ${theme.palette.primary.main}`,
outlineOffset: `2px`,
},
}} }}
props={{ tabIndex: -1 }}
> >
<ArrowBackRoundedIcon /> <ArrowBackRoundedIcon />
Back Back
@@ -180,13 +188,21 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
<Button <Button
variant="contained" variant="contained"
color="primary" color="primary"
onClick={onSubmit} type="submit"
disabled={errors.email && true} disabled={errors.email && true}
sx={{ width: "30%" }} sx={{
width: "30%",
"&.Mui-focusVisible": {
outline: `2px solid ${theme.palette.primary.main}`,
outlineOffset: `2px`,
boxShadow: `none`,
},
}}
> >
Continue Continue
</Button> </Button>
</Stack> </Stack>
</Box>
</Stack> </Stack>
</> </>
); );
@@ -285,8 +301,11 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
"& svg.MuiSvgIcon-root": { "& svg.MuiSvgIcon-root": {
mr: theme.spacing(3), mr: theme.spacing(3),
}, },
"&:focus-visible": {
outline: `2px solid ${theme.palette.primary.main}`,
outlineOffset: `2px`,
},
}} }}
props={{ tabIndex: -1 }}
> >
<ArrowBackRoundedIcon /> <ArrowBackRoundedIcon />
Back Back
@@ -294,9 +313,16 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
<Button <Button
variant="contained" variant="contained"
color="primary" color="primary"
onClick={onSubmit} type="submit"
disabled={errors.password && true} disabled={errors.password && true}
sx={{ width: "30%" }} sx={{
width: "30%",
"&.Mui-focusVisible": {
outline: `2px solid ${theme.palette.primary.main}`,
outlineOffset: `2px`,
boxShadow: `none`,
},
}}
> >
Continue Continue
</Button> </Button>
@@ -53,6 +53,10 @@ const LandingPage = ({ isSuperAdmin, onSignup }) => {
stroke: theme.palette.other.icon, stroke: theme.palette.other.icon,
}, },
}, },
"&:focus-visible": {
outline: `2px solid ${theme.palette.primary.main}`,
outlineOffset: `2px`,
},
}} }}
> >
<Mail /> <Mail />
@@ -37,21 +37,28 @@ function StepOne({ form, errors, onSubmit, onChange, onBack }) {
return ( return (
<> <>
{/* TODO this stack should be a component */}
<Stack <Stack
gap={{ xs: theme.spacing(8), sm: theme.spacing(12) }} gap={{ xs: theme.spacing(12), sm: theme.spacing(16) }}
textAlign="center" textAlign="center"
> >
<Box> <Box>
<Typography component="h1">Sign Up</Typography> <Typography component="h1">Sign Up</Typography>
<Typography>Enter your personal details</Typography> <Typography>Enter your personal details</Typography>
</Box> </Box>
<Box textAlign="left">
<Box <Box
textAlign="left"
component="form" component="form"
noValidate noValidate
spellCheck={false} spellCheck={false}
onSubmit={onSubmit} onSubmit={onSubmit}
mb={theme.spacing(10)} display="grid"
gap={{ xs: theme.spacing(12), sm: theme.spacing(16) }}
>
<Box
display="grid"
gap={{ xs: theme.spacing(8), sm: theme.spacing(12) }}
> >
<Field <Field
id="register-firstname-input" id="register-firstname-input"
@@ -64,14 +71,6 @@ function StepOne({ form, errors, onSubmit, onChange, onBack }) {
error={errors.firstName} error={errors.firstName}
ref={inputRef} ref={inputRef}
/> />
</Box>
<Box
component="form"
noValidate
spellCheck={false}
onSubmit={onSubmit}
mb={theme.spacing(5)}
>
<Field <Field
id="register-lastname-input" id="register-lastname-input"
label="Surname" label="Surname"
@@ -83,11 +82,11 @@ function StepOne({ form, errors, onSubmit, onChange, onBack }) {
error={errors.lastName} error={errors.lastName}
/> />
</Box> </Box>
</Box>
<Stack <Stack
direction="row" direction="row"
justifyContent="space-between" justifyContent="space-between"
> >
{/* TODO buttons should be a component should be a component */}
<Button <Button
variant="outlined" variant="outlined"
color="info" color="info"
@@ -97,8 +96,12 @@ function StepOne({ form, errors, onSubmit, onChange, onBack }) {
"& svg.MuiSvgIcon-root": { "& svg.MuiSvgIcon-root": {
mr: theme.spacing(3), mr: theme.spacing(3),
}, },
"&:focus-visible": {
outline: `2px solid ${theme.palette.primary.main}`,
outlineOffset: `2px`,
},
}} }}
props={{ tabIndex: -1 }}
> >
<ArrowBackRoundedIcon /> <ArrowBackRoundedIcon />
Back Back
@@ -106,13 +109,21 @@ function StepOne({ form, errors, onSubmit, onChange, onBack }) {
<Button <Button
variant="contained" variant="contained"
color="primary" color="primary"
onClick={onSubmit} type="submit"
disabled={(errors.firstName || errors.lastName) && true} disabled={(errors.firstName || errors.lastName) && true}
sx={{ width: "30%" }} sx={{
width: "30%",
"&.Mui-focusVisible": {
outline: `2px solid ${theme.palette.primary.main}`,
outlineOffset: `2px`,
boxShadow: `none`,
},
}}
> >
Continue Continue
</Button> </Button>
</Stack> </Stack>
</Box>
</Stack> </Stack>
</> </>
); );
@@ -47,13 +47,17 @@ function StepThree({ onSubmit, onBack }) {
spellCheck={false} spellCheck={false}
onSubmit={onSubmit} onSubmit={onSubmit}
textAlign="left" textAlign="left"
display="grid"
gap={{ xs: theme.spacing(12), sm: theme.spacing(16) }}
sx={{ sx={{
display: "grid",
gap: theme.spacing(8),
"& .input-error": { "& .input-error": {
display: "none", display: "none",
}, },
}} }}
>
<Box
display="grid"
gap={{ xs: theme.spacing(8), sm: theme.spacing(12) }}
> >
<Field <Field
type="password" type="password"
@@ -80,6 +84,7 @@ function StepThree({ onSubmit, onBack }) {
onChange={handleChange} onChange={handleChange}
error={errors.confirm && errors.confirm[0]} error={errors.confirm && errors.confirm[0]}
/> />
</Box>
<Stack <Stack
gap={theme.spacing(4)} gap={theme.spacing(4)}
mb={{ xs: theme.spacing(6), sm: theme.spacing(8) }} mb={{ xs: theme.spacing(6), sm: theme.spacing(8) }}
@@ -133,7 +138,6 @@ function StepThree({ onSubmit, onBack }) {
outlineOffset: "4px", outlineOffset: "4px",
}, },
}} }}
props={{ tabIndex: -1 }}
> >
<ArrowBackRoundedIcon /> <ArrowBackRoundedIcon />
Back Back
@@ -147,7 +151,14 @@ function StepThree({ onSubmit, onBack }) {
form.confirm.length === 0 || form.confirm.length === 0 ||
Object.keys(errors).length !== 0 Object.keys(errors).length !== 0
} }
sx={{ width: "30%" }} sx={{
width: "30%",
"&.Mui-focusVisible": {
outline: `2px solid ${theme.palette.primary.main}`,
outlineOffset: `2px`,
boxShadow: `none`,
},
}}
> >
Continue Continue
</Button> </Button>
@@ -44,13 +44,16 @@ function StepTwo({ form, errors, onSubmit, onChange, onBack }) {
<Typography component="h1">Sign Up</Typography> <Typography component="h1">Sign Up</Typography>
<Typography>Enter your email address</Typography> <Typography>Enter your email address</Typography>
</Box> </Box>
<Box textAlign="left">
<Box <Box
component="form" component="form"
textAlign="left"
noValidate noValidate
spellCheck={false} spellCheck={false}
onSubmit={onSubmit} onSubmit={onSubmit}
mb={theme.spacing(5)} mb={theme.spacing(5)}
display="grid"
gap={{ xs: theme.spacing(12), sm: theme.spacing(16) }}
> >
<Field <Field
type="email" type="email"
@@ -65,8 +68,6 @@ function StepTwo({ form, errors, onSubmit, onChange, onBack }) {
error={errors.email} error={errors.email}
ref={inputRef} ref={inputRef}
/> />
</Box>
</Box>
<Stack <Stack
direction="row" direction="row"
justifyContent="space-between" justifyContent="space-between"
@@ -80,8 +81,11 @@ function StepTwo({ form, errors, onSubmit, onChange, onBack }) {
"& svg.MuiSvgIcon-root": { "& svg.MuiSvgIcon-root": {
mr: theme.spacing(3), mr: theme.spacing(3),
}, },
"&:focus-visible": {
outline: `2px solid ${theme.palette.primary.main}`,
outlineOffset: `2px`,
},
}} }}
props={{ tabIndex: -1 }}
> >
<ArrowBackRoundedIcon /> <ArrowBackRoundedIcon />
Back Back
@@ -91,11 +95,19 @@ function StepTwo({ form, errors, onSubmit, onChange, onBack }) {
color="primary" color="primary"
onClick={onSubmit} onClick={onSubmit}
disabled={errors.email && true} disabled={errors.email && true}
sx={{ width: "30%" }} sx={{
width: "30%",
"&.Mui-focusVisible": {
outline: `2px solid ${theme.palette.primary.main}`,
outlineOffset: `2px`,
boxShadow: `none`,
},
}}
> >
Continue Continue
</Button> </Button>
</Stack> </Stack>
</Box>
</Stack> </Stack>
</> </>
); );