diff --git a/site/components/ButtonLink.tsx b/site/components/ButtonLink.tsx new file mode 100644 index 00000000..24f4ba94 --- /dev/null +++ b/site/components/ButtonLink.tsx @@ -0,0 +1,26 @@ +import Link from 'next/link'; + +export default function ButtonLink({ + style = 'primary', + className = '', + href = '', + children, +}) { + let styleClassName = ''; + + if (style == 'primary') { + styleClassName = 'text-primary bg-blue-400 hover:bg-blue-300'; + } else if (style == 'secondary') { + styleClassName = + 'text-secondary border !border-secondary hover:text-primary hover:bg-blue-300'; + } + + return ( + + {children} + + ); +} diff --git a/site/components/Community.tsx b/site/components/Community.tsx index d5e76c34..b4a8b061 100644 --- a/site/components/Community.tsx +++ b/site/components/Community.tsx @@ -4,6 +4,8 @@ import EmailIcon from './icons/EmailIcon'; import GitHubIcon from './icons/GitHubIcon'; import { siteConfig } from '@/config/siteConfig'; +import { getContributorsCount, getRepoInfo } from '@/lib/getGitHubData'; +import { useEffect, useState } from 'react'; const Stat = ({ title, value, ...props }) => { return ( @@ -29,6 +31,33 @@ const IconButton = ({ Icon, text, href, ...props }) => { }; export default function Community() { + const [repoInfo, setRepoInfo] = useState(); + const [contributorsCount, setContributorsCount] = useState(''); + + useEffect(() => { + // This runs on client side and it's unlikely that users + // will exceed the GitHub API usage limit, but added a + // handling for that just in case. + + getRepoInfo().then((res) => { + if (res.success) { + res.info.then((data) => setRepoInfo(data)); + } else { + // If the request fail e.g API usage limit, use + // a placeholder + setRepoInfo({ stargazers_count: '+2k' }); + } + }); + + getContributorsCount().then((res) => { + if (res.success) { + setContributorsCount(res.count); + } else { + setContributorsCount('+70'); + } + }); + }, []); + return (

@@ -38,8 +67,12 @@ export default function Community() { We are growing. Get in touch or become a contributor!

- - + +
-

+

-

- Discover what's being powered by Portal.JS -

+

Discover what's being powered by Portal.JS

{items.map((item) => { return ; diff --git a/site/components/GalleryItem.tsx b/site/components/GalleryItem.tsx index 53bf5f1e..5afc2c6f 100644 --- a/site/components/GalleryItem.tsx +++ b/site/components/GalleryItem.tsx @@ -9,7 +9,7 @@ export default function GalleryItem({ item }) { className="bg-cover bg-no-repeat bg-top aspect-video w-full group-hover:blur-sm group-hover:scale-105 transition-all duration-200" style={{ backgroundImage: `url(${item.image})` }} > -
+
diff --git a/site/components/Hero.tsx b/site/components/Hero.tsx index 48cf954a..286be50f 100644 --- a/site/components/Hero.tsx +++ b/site/components/Hero.tsx @@ -1,6 +1,7 @@ import clsx from 'clsx'; import Highlight, { defaultProps } from 'prism-react-renderer'; import { Fragment, useRef } from 'react'; +import ButtonLink from './ButtonLink'; import NewsletterForm from './NewsletterForm'; const codeLanguage = 'javascript'; @@ -32,7 +33,10 @@ export function Hero() { const el = useRef(null); return ( -
+