forked from poppyseedDev/polkadot-fandom-page
-
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.
- Loading branch information
1 parent
fe7f15e
commit 7f7afeb
Showing
5 changed files
with
81 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import StarGazers from "./StarGazers"; | ||
|
||
export default function Header() { | ||
return ( | ||
<header | ||
className="h-[110px] sm:!h-[144px] w-full bg-cover bg-no-repeat relative" | ||
style={{ | ||
backgroundImage: "url(/header_bg.svg)", | ||
}} | ||
> | ||
<div className="rainfall w-full h-full absolute" /> | ||
<nav className="w-11/12 h-24 max-w-5xl mx-auto flex items-center justify-between relative"> | ||
<a href="/"> | ||
<img | ||
src="/logo.svg" | ||
alt="Deno Logo" | ||
className="h-14 w-14" | ||
/> | ||
</a> | ||
<StarGazers /> | ||
</nav> | ||
</header> | ||
) | ||
} |
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,42 @@ | ||
import IconGithub from "./IconGithub" | ||
import useSWR from "swr" | ||
|
||
export interface GithubData { | ||
watchers: number | ||
} | ||
|
||
async function githubApiFetcher(): Promise<GithubData> { | ||
const res = await fetch("https://api.github.com/repos/kodadot/nft-gallery"); | ||
return await res.json(); | ||
} | ||
|
||
export function useStargazers() { | ||
return useSWR<GithubData, Error>("watchers", githubApiFetcher); | ||
} | ||
|
||
export default function StarGazers() { | ||
const { data, error } = useStargazers(); | ||
|
||
const add = () => { | ||
const url = `https://github.com/kodadot/nft-gallery/`; | ||
window.open(url, '_blank') | ||
}; | ||
|
||
if (error) { | ||
return <div>Error: {error.message}</div>; | ||
} | ||
|
||
|
||
return ( | ||
<div> | ||
<button | ||
onClick={add} | ||
className="flex items-center gap-2 border-2 border-gray-800 rounded-full px-5 py-1 font-semibold text-gray-800 hover:bg-gray-800 hover:text-white transition-colors duration-300" | ||
> | ||
<IconGithub /> | ||
{data?.watchers ?? "0"} | ||
</button> | ||
|
||
</div> | ||
) | ||
} |
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