Skip to content

Commit

Permalink
feat: added scroll indicator (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourabh782 committed Aug 8, 2024
1 parent eb97359 commit da5cf81
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Footer from "@/components/core/footer";
import Navbar from "@/components/core/navbar";
import { cookies } from "next/headers";
import { getGithubStars } from "@/helper/getGithubStars";
import ProgressBar from "@/components/ProgressBar";

export default async function Home() {
const starCount: number = await getGithubStars();
Expand All @@ -13,6 +14,7 @@ export default async function Home() {

return (
<>
<ProgressBar start={"origin-left"} />
<Navbar starCount={starCount} />
<HomePage accountId={accountId} />
<Footer />
Expand Down
20 changes: 20 additions & 0 deletions src/components/ProgressBar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use client"
import { motion, useScroll, useSpring } from "framer-motion";

const ProgressBar = ({start}: {start: string}) => {
const { scrollYProgress } = useScroll();
const scaleX = useSpring(scrollYProgress, {
stiffness: 100,
damping: 30,
restDelta: 0.001,
});

return (
<motion.div
className={`fixed top-0 left-0 right-0 h-2 bg-primary ${start} z-[51]`}
style={{ scaleX }}
/>
)
}

export default ProgressBar
6 changes: 4 additions & 2 deletions src/components/pages/contribute/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Footer from "@/components/core/footer";
import Navbar from "@/components/core/navbar";
import { Forking, AppwriteSetup, DevSetup } from "@/components/core/contributionSections";
import { motion, useScroll, useSpring } from "framer-motion";
import ProgressBar from "@/components/ProgressBar";

// Component to render the contribution guide with dynamic tabs
export default function Contribute() {
Expand Down Expand Up @@ -75,10 +76,11 @@ export default function Contribute() {
</article>
<article>
<Tabs currentTab={currentTab || ""} />
<motion.div
{/* <motion.div
className="fixed bottom-0 left-0 right-0 h-2 bg-primary origin-center"
style={{ scaleX }}
/>
/> */}
<ProgressBar start={"origin-center"} />
</article>
</section>
<Footer />
Expand Down

0 comments on commit da5cf81

Please sign in to comment.