generated from ReCoded-Org/capstone-react-redux-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* login component completed * login page design completed * added form validation to login page * added snapshot to login page * merged develop branch into current branch Co-authored-by: allan <[email protected]>
- Loading branch information
1 parent
645fbfd
commit fea30d1
Showing
12 changed files
with
331 additions
and
66 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
2 changes: 1 addition & 1 deletion
2
src/components/Hero/Hero.test.js → src/components/Hero/__tests__/Hero.test.js
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
File renamed without changes.
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,89 @@ | ||
import { useForm } from "react-hook-form"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faGoogle } from "@fortawesome/free-brands-svg-icons"; | ||
|
||
function Login() { | ||
const { | ||
register, | ||
formState: { errors }, | ||
handleSubmit, | ||
} = useForm(); | ||
const onSubmit = (data) => console.log(data); | ||
return ( | ||
<div className=" my-52"> | ||
<h1 className="font-inter font-black text-2xl mb-6">Log in</h1> | ||
<div className="w-full max-w-sm mx-auto"> | ||
<form onSubmit={handleSubmit(onSubmit)}> | ||
<div className="mb-4"> | ||
<input | ||
className="shadow border-2 border-black rounded-md w-full py-2 px-3 text-dark-gray leading-tight focus:outline-1 focus:shadow-outline" | ||
id="email" | ||
type="email" | ||
placeholder="[email protected] " | ||
{...register("email", { | ||
required: true, | ||
pattern: /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/i, | ||
})} | ||
/> | ||
<error className="text-primary font-inter"> | ||
{errors.email?.type === "required" && "Please enter an email"} | ||
{errors.email?.type === "pattern" && | ||
"Entered email is in wrong format"} | ||
</error> | ||
</div> | ||
<div className="mb-4 font-inter"> | ||
<input | ||
className="shadow border-2 border-black rounded-md w-full py-2 px-3 text-dark-gray leading-tight focus:outline-1 focus:shadow-outline" | ||
id="password" | ||
type="password" | ||
placeholder="Password " | ||
{...register("password", { | ||
required: true, | ||
minLength: 8, | ||
maxLength: 20, | ||
})} | ||
/> | ||
|
||
<error className="text-primary font-inter"> | ||
{errors.password?.type === "required" && | ||
"Please enter a password"} | ||
{errors.password?.type === "minLength" && | ||
"Entered password is less than 8 characters"} | ||
{errors.password?.type === "maxLength" && | ||
"Entered password is more than 20 characters"} | ||
</error> | ||
</div> | ||
<div className="mb-4"> | ||
<button | ||
type="submit" | ||
className="w-full bg-accent font-inter text-white rounded-md py-1 hover:bg-red-500" | ||
> | ||
Log in | ||
</button> | ||
</div> | ||
<div className="mb-4"> | ||
<p className="text-dark-gray"> | ||
Don't Have an Account?{" "} | ||
<span className="font-semibold">Sign up</span> | ||
</p> | ||
</div> | ||
<div> | ||
<button | ||
type="button" | ||
className=" text-black border-t-2 border-l-2 border-r-4 border-b-4 border-black py-0.5 px-8 rounded-lg bg-white hover:shadow-md" | ||
> | ||
<FontAwesomeIcon | ||
icon={faGoogle} | ||
className="pr-3 text-2xl font-bold" | ||
/> | ||
Log in with | ||
<span className="font-bold"> Google</span> | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default Login; |
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,8 @@ | ||
import renderer from "react-test-renderer"; | ||
|
||
import Login from "../Login"; | ||
|
||
it("renders correctly when the component matches the snapshot", () => { | ||
const tree = renderer.create(<Login />).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); |
108 changes: 108 additions & 0 deletions
108
src/components/Login/__test__/__snapshots__/Login.test.js.snap
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,108 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders correctly when the component matches the snapshot 1`] = ` | ||
<div | ||
className=" my-52" | ||
> | ||
<h1 | ||
className="font-inter font-black text-2xl mb-6" | ||
> | ||
Log in | ||
</h1> | ||
<div | ||
className="w-full max-w-sm mx-auto" | ||
> | ||
<form | ||
onSubmit={[Function]} | ||
> | ||
<div | ||
className="mb-4" | ||
> | ||
<input | ||
className="shadow border-2 border-black rounded-md w-full py-2 px-3 text-dark-gray leading-tight focus:outline-1 focus:shadow-outline" | ||
id="email" | ||
name="email" | ||
onBlur={[Function]} | ||
onChange={[Function]} | ||
placeholder="[email protected] " | ||
type="email" | ||
/> | ||
<error | ||
className="text-primary font-inter" | ||
/> | ||
</div> | ||
<div | ||
className="mb-4 font-inter" | ||
> | ||
<input | ||
className="shadow border-2 border-black rounded-md w-full py-2 px-3 text-dark-gray leading-tight focus:outline-1 focus:shadow-outline" | ||
id="password" | ||
name="password" | ||
onBlur={[Function]} | ||
onChange={[Function]} | ||
placeholder="Password " | ||
type="password" | ||
/> | ||
<error | ||
className="text-primary font-inter" | ||
/> | ||
</div> | ||
<div | ||
className="mb-4" | ||
> | ||
<button | ||
className="w-full bg-accent font-inter text-white rounded-md py-1 hover:bg-red-500" | ||
type="submit" | ||
> | ||
Log in | ||
</button> | ||
</div> | ||
<div | ||
className="mb-4" | ||
> | ||
<p | ||
className="text-dark-gray" | ||
> | ||
Don't Have an Account? | ||
<span | ||
className="font-semibold" | ||
> | ||
Sign up | ||
</span> | ||
</p> | ||
</div> | ||
<div> | ||
<button | ||
className=" text-black border-t-2 border-l-2 border-r-4 border-b-4 border-black py-0.5 px-8 rounded-lg bg-white hover:shadow-md" | ||
type="button" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
className="svg-inline--fa fa-google pr-3 text-2xl font-bold" | ||
data-icon="google" | ||
data-prefix="fab" | ||
focusable="false" | ||
role="img" | ||
style={Object {}} | ||
viewBox="0 0 488 512" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M488 261.8C488 403.3 391.1 504 248 504 110.8 504 0 393.2 0 256S110.8 8 248 8c66.8 0 123 24.5 166.3 64.9l-67.5 64.9C258.5 52.6 94.3 116.6 94.3 256c0 86.5 69.1 156.6 153.7 156.6 98.2 0 135-70.4 140.8-106.9H248v-85.3h236.1c2.3 12.7 3.9 24.9 3.9 41.4z" | ||
fill="currentColor" | ||
style={Object {}} | ||
/> | ||
</svg> | ||
Log in with | ||
<span | ||
className="font-bold" | ||
> | ||
</span> | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
`; |
2 changes: 1 addition & 1 deletion
2
...omponents/whyChooseUs/WhyChooseUs.test.js → ...whyChooseUs/__tests__/WhyChooseUs.test.js
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
File renamed without changes.
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
Oops, something went wrong.