feat(homepage): refine gradient rightwards, dim hero background, seamless bottom fade, and scroll-activated navbar
This commit is contained in:
@@ -14,8 +14,34 @@ interface NavbarProps {
|
||||
|
||||
export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
||||
const [isScrolledPastHero, setIsScrolledPastHero] = useState(false);
|
||||
const pathname = usePathname();
|
||||
|
||||
// Scroll detection:
|
||||
// - On homepage: transparent text buttons while hero image is visible.
|
||||
// - Once hero image area is completely scrolled up (or on other pages): transforms into the navbar!
|
||||
useEffect(() => {
|
||||
if (pathname !== '/') {
|
||||
setIsScrolledPastHero(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const checkScroll = () => {
|
||||
const hero = document.getElementById('hero-section');
|
||||
// Hero image area is completely scrolled up when window.scrollY reaches hero.offsetHeight
|
||||
const threshold = hero ? Math.max(300, hero.offsetHeight - 4) : window.innerHeight;
|
||||
setIsScrolledPastHero(window.scrollY >= threshold);
|
||||
};
|
||||
|
||||
checkScroll();
|
||||
window.addEventListener('scroll', checkScroll, { passive: true });
|
||||
window.addEventListener('resize', checkScroll, { passive: true });
|
||||
return () => {
|
||||
window.removeEventListener('scroll', checkScroll);
|
||||
window.removeEventListener('resize', checkScroll);
|
||||
};
|
||||
}, [pathname]);
|
||||
|
||||
// Close mobile menu on Escape key
|
||||
useEffect(() => {
|
||||
if (!mobileMenuOpen) return;
|
||||
@@ -41,11 +67,22 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
};
|
||||
}, [mobileMenuOpen]);
|
||||
|
||||
// Text-only mode while viewing the homepage hero image
|
||||
const isTextOnlyMode = pathname === '/' && !isScrolledPastHero;
|
||||
|
||||
return (
|
||||
<header className="fixed top-0 left-0 right-0 w-full z-50 bg-[#FAF8F5]/96 backdrop-blur-sm border-b border-slate-200/90 shadow-2xs py-2.5 sm:py-3 transition-colors duration-200 pointer-events-auto">
|
||||
<header
|
||||
className={`fixed top-0 left-0 right-0 w-full z-50 transition-[background-color,border-color,padding,box-shadow] duration-300 pointer-events-auto ${
|
||||
mobileMenuOpen
|
||||
? 'bg-[#FAF8F5] border-b border-slate-200/90 shadow-2xs py-2.5 sm:py-3'
|
||||
: isTextOnlyMode
|
||||
? 'bg-transparent border-b border-transparent py-3 sm:py-4'
|
||||
: 'bg-[#FAF8F5]/96 backdrop-blur-sm border-b border-slate-200/90 shadow-2xs py-2 sm:py-2.5'
|
||||
}`}
|
||||
>
|
||||
<div className="max-w-[1640px] mx-auto px-4 sm:px-6 lg:px-10 flex items-center justify-between">
|
||||
{/* Brand Logo */}
|
||||
<div className="relative z-20 flex-shrink-0">
|
||||
{/* Brand Logo - In text-only mode on hero it is hidden, sliding into place when scrolled past hero */}
|
||||
<div className={`relative z-20 flex-shrink-0 transition-all duration-300 ${isTextOnlyMode ? 'opacity-0 -translate-x-3 pointer-events-none' : 'opacity-100 translate-x-0'}`}>
|
||||
<BrandLogo size="md" />
|
||||
</div>
|
||||
|
||||
@@ -121,7 +158,11 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
<div className="flex md:hidden items-center space-x-2 relative z-20">
|
||||
<button
|
||||
onClick={() => setMobileMenuOpen(!mobileMenuOpen)}
|
||||
className="p-2.5 rounded-xl border text-slate-800 bg-white hover:bg-slate-50 border-slate-200/90 shadow-2xs transition-colors active:scale-95"
|
||||
className={`transition-all duration-300 active:scale-95 ${
|
||||
isTextOnlyMode && !mobileMenuOpen
|
||||
? 'p-2 text-slate-800 hover:text-blue-600 bg-transparent border-transparent'
|
||||
: 'p-2.5 rounded-xl border text-slate-800 bg-white hover:bg-slate-50 border-slate-200/90 shadow-2xs'
|
||||
}`}
|
||||
aria-label={mobileMenuOpen ? 'Close navigation menu' : 'Open navigation menu'}
|
||||
aria-expanded={mobileMenuOpen}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user