Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added scroll indicator #418

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading