forked from emre/www_projectmycelium_com
refactor: implement smart navigation for "Get Mycelium Connector" button with smooth scroll utility
- Added smoothScrollToElement utility function in src/utils/scroll.ts with easeInOutQuad animation and configurable duration - Changed Header and HeaderDark "Get Mycelium Connector" button from static /download link to onClick handler with conditional navigation - Added handleGetConnectorClick function that scrolls to #download section when on /network page, otherwise navigates to /network - Change
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Link, useLocation, useNavigate } from 'react-router-dom'
|
||||
import { smoothScrollToElement } from '@/utils/scroll'
|
||||
import { Container } from './Container'
|
||||
import { Button } from './Button'
|
||||
import pmyceliumLogo from '../images/logos/mainlogo.svg'
|
||||
@@ -9,6 +10,17 @@ import { Bars3Icon, XMarkIcon } from '@heroicons/react/24/outline'
|
||||
export function HeaderDark() {
|
||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false)
|
||||
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
|
||||
const handleGetConnectorClick = () => {
|
||||
if (location.pathname === '/network') {
|
||||
smoothScrollToElement('download', 1200)
|
||||
} else {
|
||||
navigate('/network')
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<header className="bg-[#111111]">
|
||||
<nav className="border-b border-gray-800">
|
||||
@@ -61,7 +73,7 @@ export function HeaderDark() {
|
||||
>
|
||||
Deploy Now
|
||||
</Button>
|
||||
<Button to="/download" variant="solid" color="cyan">
|
||||
<Button variant="solid" color="cyan" onClick={handleGetConnectorClick}>
|
||||
Get Mycelium Connector
|
||||
</Button>
|
||||
</div>
|
||||
@@ -150,7 +162,15 @@ export function HeaderDark() {
|
||||
>
|
||||
Start Deployment
|
||||
</Button>
|
||||
<Button to="/download" variant="solid" color="cyan" className="mt-4 w-full" onClick={() => setMobileMenuOpen(false)}>
|
||||
<Button
|
||||
variant="solid"
|
||||
color="cyan"
|
||||
className="mt-4 w-full"
|
||||
onClick={() => {
|
||||
setMobileMenuOpen(false)
|
||||
handleGetConnectorClick()
|
||||
}}
|
||||
>
|
||||
Get Mycelium Connector
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user