Skip to content
Open
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
39 changes: 30 additions & 9 deletions app/components/ProgressBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import { useEffect, useState } from 'react';
import { usePathname } from 'next/navigation';
import { ArrowUp } from 'lucide-react';

export default function ProgressBar() {
const [scrollPercentage, setScrollPercentage] = useState(0);
const [showBackToTop, setShowBackToTop] = useState(false);
const pathname = usePathname();

useEffect(() => {
Expand All @@ -14,6 +16,7 @@ export default function ProgressBar() {
const scrollY = window.scrollY;

const scrollableDistance = documentHeight - windowHeight;
setShowBackToTop(scrollY > 300);

if (scrollableDistance > 0) {
const percentage = (scrollY / scrollableDistance) * 100;
Expand All @@ -30,20 +33,38 @@ export default function ProgressBar() {
return () => window.removeEventListener('scroll', handleScroll);
}, [pathname]);

if (!pathname.startsWith('/sem')) {
return null;
}
const scrollToTop = () => {
window.scrollTo({ top: 0, behavior: 'smooth' });
};

return (

<div className="fixed top-0 left-0 w-full h-1.5 z-[99999] bg-black/20 pointer-events-none">
<div
className="h-full transition-all duration-150 ease-out"
<>
{pathname.startsWith('/sem') && (
<div className="fixed top-0 left-0 w-full h-1.5 z-[99999] bg-black/20 pointer-events-none">
<div
className="h-full transition-all duration-150 ease-out"
style={{
width: `${scrollPercentage}%`,
backgroundColor: '#C7A669'
}}
/>
</div>
/>
</div>
)}

{showBackToTop && (
<button
type="button"
onClick={scrollToTop}
aria-label="Back to top"
className="fixed bottom-6 right-6 z-[99999] flex items-center justify-center
h-12 w-12 rounded-full border border-[#d2b48c]/40
bg-[#1B0D00] text-[#FAE8D7] shadow-[0_12px_32px_rgba(0,0,0,0.28)]
transition duration-300 hover:-translate-y-1 hover:bg-[#d2b48c] hover:text-[#1B0D00]
focus:outline-none focus:ring-2 focus:ring-[#d2b48c] focus:ring-offset-2 focus:ring-offset-[#1B0D00]"
>
<ArrowUp size={20} />
</button>
)}
</>
);
}
3 changes: 1 addition & 2 deletions app/components/footer.tsx
Comment thread
Sanjhivvarshan-b-s marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default function Footer() {
const scrollToTop = () => {
window.scrollTo({ top: 0, behavior: "smooth" });
};

return (
<footer className="bg-[#1B0D00] text-[#FAE8D7] py-12 px-6 border-t-4 border-[#2b1b0e]">
<div className="max-w-7xl mx-auto grid grid-cols-1 md:grid-cols-3 gap-12">
Expand Down Expand Up @@ -59,7 +58,7 @@ export default function Footer() {
<Mail size={24} />
</a>
</div>

<button
onClick={scrollToTop}
className="flex items-center gap-2 mt-6 text-lg hover:text-[#d2b48c] transition"
Expand Down