diff --git a/docs/data/material/getting-started/templates/sign-in-side/SignInCard.js b/docs/data/material/getting-started/templates/sign-in-side/SignInCard.js index 57d293c0490a54..458568bf87b837 100644 --- a/docs/data/material/getting-started/templates/sign-in-side/SignInCard.js +++ b/docs/data/material/getting-started/templates/sign-in-side/SignInCard.js @@ -50,7 +50,10 @@ export default function SignInCard() { }; const handleSubmit = (event) => { - event.preventDefault(); + if (emailError || passwordError) { + event.preventDefault(); + return; + } const data = new FormData(event.currentTarget); console.log({ email: data.get('email'), @@ -126,6 +129,7 @@ export default function SignInCard() { Password or - - Already have an account?{' '} - - - Sign in - - - - - - or - - - - - - - + error={passwordError} + helperText={passwordErrorMessage} + color={passwordError ? 'error' : 'primary'} + /> + + } + label="I want to receive updates via email." + /> + + + Already have an account?{' '} + + + Sign in + + + + + + or + + + + + + diff --git a/docs/data/material/getting-started/templates/sign-up/SignUp.tsx b/docs/data/material/getting-started/templates/sign-up/SignUp.tsx index ce73b97e4438c2..a375bae9d1f15f 100644 --- a/docs/data/material/getting-started/templates/sign-up/SignUp.tsx +++ b/docs/data/material/getting-started/templates/sign-up/SignUp.tsx @@ -42,8 +42,11 @@ const Card = styled(MuiCard)(({ theme }) => ({ })); const SignUpContainer = styled(Stack)(({ theme }) => ({ - height: '100%', - padding: 4, + minHeight: '100%', + padding: theme.spacing(2), + [theme.breakpoints.up('sm')]: { + padding: theme.spacing(4), + }, backgroundImage: 'radial-gradient(ellipse at 50% 50%, hsl(210, 100%, 97%), hsl(0, 0%, 100%))', backgroundRepeat: 'no-repeat', @@ -58,12 +61,12 @@ export default function SignUp() { const [showCustomTheme, setShowCustomTheme] = React.useState(true); const defaultTheme = createTheme({ palette: { mode } }); const SignUpTheme = createTheme(getSignUpTheme(mode)); + const [nameError, setNameError] = React.useState(false); + const [nameErrorMessage, setNameErrorMessage] = React.useState(''); const [emailError, setEmailError] = React.useState(false); const [emailErrorMessage, setEmailErrorMessage] = React.useState(''); const [passwordError, setPasswordError] = React.useState(false); const [passwordErrorMessage, setPasswordErrorMessage] = React.useState(''); - const [nameError, setNameError] = React.useState(false); - const [nameErrorMessage, setNameErrorMessage] = React.useState(''); // This code only runs on the client side, to determine the system color preference React.useEffect(() => { // Check if there is a preferred mode in localStorage @@ -127,7 +130,10 @@ export default function SignUp() { }; const handleSubmit = (event: React.FormEvent) => { - event.preventDefault(); + if (nameError || emailError || passwordError) { + event.preventDefault(); + return; + } const data = new FormData(event.currentTarget); console.log({ name: data.get('name'), @@ -146,124 +152,113 @@ export default function SignUp() { > - - - - - - Sign up - - - - Full name - - - - Email - - - - Password - - - } - label="I want to receive updates via email." - /> - - - Already have an account?{' '} - - - Sign in - - - - - - or - - - - - - - + error={passwordError} + helperText={passwordErrorMessage} + color={passwordError ? 'error' : 'primary'} + /> + + } + label="I want to receive updates via email." + /> + + + Already have an account?{' '} + + + Sign in + + + + + + or + + + + + +