-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new component Login Form using Formik
- Loading branch information
1 parent
540d62c
commit abc1d7c
Showing
6 changed files
with
182 additions
and
72 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
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.heading { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
color: crimson; | ||
font-weight: bold; | ||
} | ||
.labelField { | ||
font-weight: bolder; | ||
} | ||
.inputField { | ||
margin-left: 1%; | ||
} | ||
.buttonField { | ||
margin-left: 25%; | ||
} | ||
.errorMsg { | ||
display: block; | ||
font-weight: bold; | ||
font-size: 12px; | ||
color: crimson; | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import "./LoginForm.css"; | ||
import { useState } from "react"; | ||
import { Formik, Field, Form, ErrorMessage } from 'formik'; | ||
|
||
function LoginForm() { | ||
|
||
const handleValidation = () => { | ||
console.log("Validation was invoked"); | ||
}; | ||
return ( | ||
<> | ||
<h1>Sign Up</h1> | ||
<Formik | ||
initialValues={{ | ||
email: '', | ||
password: '', | ||
confirmPassword: '', | ||
}} | ||
onSubmit={async (values) => { | ||
await new Promise((r) => setTimeout(r, 500)); | ||
alert(JSON.stringify(values, null, 2)); | ||
}} | ||
validate = {handleValidation} | ||
> | ||
<Form> | ||
<label htmlFor="email">Email id</label> | ||
<Field id="email" name="email" placeholder="Enter Email" type="email"/> | ||
{/* <ErrorMessage name="email" >{error}</ErrorMessage> */} | ||
|
||
<label htmlFor="password">Password</label> | ||
<Field id="password" name="password" placeholder="Enter Password" type="password" /> | ||
{/* <ErrorMessage name="password" >{error}</ErrorMessage> */} | ||
|
||
<label htmlFor="confirmPassword">Confirm Password</label> | ||
<Field | ||
id="confirmPassword" | ||
name="confirmPassword" | ||
placeholder="Confirm Password" | ||
type="password" | ||
/> | ||
{/* <ErrorMessage name="confirmPassword" >{error}</ErrorMessage> */} | ||
|
||
<button type="submit">Submit</button> | ||
</Form> | ||
</Formik> | ||
</> | ||
) | ||
} | ||
|
||
export default LoginForm; |
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,16 +1,22 @@ | ||
.heading{ | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
color:crimson; | ||
font-weight: bold; | ||
} | ||
.labelField{ | ||
.heading { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
color: crimson; | ||
font-weight: bold; | ||
} | ||
.inputField{ | ||
margin-left: 1%; | ||
.labelField { | ||
font-weight: bolder; | ||
} | ||
.inputField { | ||
margin-left: 1%; | ||
} | ||
.buttonField { | ||
margin-left: 25%; | ||
} | ||
.errorMsg { | ||
display: block; | ||
font-weight: bold; | ||
font-size: 12px; | ||
color: crimson; | ||
} | ||
.buttonField{ | ||
margin-left: 25%; | ||
} |
Oops, something went wrong.