-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from Anikesh02/SignInWithGoogle
Added Github SignIn
- Loading branch information
Showing
4 changed files
with
88 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import "../components/css/GithubSignIn.css"; | ||
import { useAuth } from "../context/AuthContext.js"; | ||
|
||
const GithubSignIn = () => { | ||
const { currentUser, githubSignIn } = useAuth(); | ||
const [loading, setLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
const checkAuthentication = async () => { | ||
await new Promise((resolve) => setTimeout(resolve, 50)); | ||
setLoading(false); | ||
}; | ||
checkAuthentication(); | ||
}, [currentUser]); | ||
|
||
const handleSignIn = async () => { | ||
try { | ||
await githubSignIn(); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}; | ||
|
||
return loading ? null : ( | ||
<button onClick={handleSignIn} className="github-sign-in-button"> | ||
<img | ||
className="github-logo" | ||
src="https://www.svgrepo.com/show/452211/github.svg" | ||
loading="lazy" | ||
alt="github logo" | ||
/> | ||
<span>Login with Github</span> | ||
</button> | ||
); | ||
}; | ||
|
||
export default GithubSignIn; |
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,34 @@ | ||
.github-sign-in-button { | ||
display: flex; | ||
align-items: center; | ||
gap: 0.5rem; | ||
padding: 0.5rem 1rem; | ||
border: 1px solid #e2e8f0; | ||
border-radius: 0.5rem; | ||
color: #334155; | ||
background-color: black; | ||
transition: all 150ms ease-in-out; | ||
cursor: pointer; | ||
} | ||
|
||
.github-sign-in-button:hover { | ||
border-color: #94a3b8; | ||
color: #0f172a; | ||
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); | ||
} | ||
|
||
.github-logo { | ||
width: 1.5rem; | ||
height: 1.5rem; | ||
} | ||
|
||
/* Dark mode styles */ | ||
@media (prefers-color-scheme: dark) { | ||
.github-sign-in-button { | ||
color: #ffffff; | ||
} | ||
|
||
.github-sign-in-button:hover { | ||
color: #f1f5f9; | ||
} | ||
} |
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