Skip to content

Commit da5cf81

Browse files
authored
feat: added scroll indicator (#418)
1 parent eb97359 commit da5cf81

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/app/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Footer from "@/components/core/footer";
33
import Navbar from "@/components/core/navbar";
44
import { cookies } from "next/headers";
55
import { getGithubStars } from "@/helper/getGithubStars";
6+
import ProgressBar from "@/components/ProgressBar";
67

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

1415
return (
1516
<>
17+
<ProgressBar start={"origin-left"} />
1618
<Navbar starCount={starCount} />
1719
<HomePage accountId={accountId} />
1820
<Footer />
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"use client"
2+
import { motion, useScroll, useSpring } from "framer-motion";
3+
4+
const ProgressBar = ({start}: {start: string}) => {
5+
const { scrollYProgress } = useScroll();
6+
const scaleX = useSpring(scrollYProgress, {
7+
stiffness: 100,
8+
damping: 30,
9+
restDelta: 0.001,
10+
});
11+
12+
return (
13+
<motion.div
14+
className={`fixed top-0 left-0 right-0 h-2 bg-primary ${start} z-[51]`}
15+
style={{ scaleX }}
16+
/>
17+
)
18+
}
19+
20+
export default ProgressBar

src/components/pages/contribute/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Footer from "@/components/core/footer";
55
import Navbar from "@/components/core/navbar";
66
import { Forking, AppwriteSetup, DevSetup } from "@/components/core/contributionSections";
77
import { motion, useScroll, useSpring } from "framer-motion";
8+
import ProgressBar from "@/components/ProgressBar";
89

910
// Component to render the contribution guide with dynamic tabs
1011
export default function Contribute() {
@@ -75,10 +76,11 @@ export default function Contribute() {
7576
</article>
7677
<article>
7778
<Tabs currentTab={currentTab || ""} />
78-
<motion.div
79+
{/* <motion.div
7980
className="fixed bottom-0 left-0 right-0 h-2 bg-primary origin-center"
8081
style={{ scaleX }}
81-
/>
82+
/> */}
83+
<ProgressBar start={"origin-center"} />
8284
</article>
8385
</section>
8486
<Footer />

0 commit comments

Comments
 (0)