fixes
This commit is contained in:
parent
aa93e42441
commit
01d3a3aa79
|
|
@ -167,12 +167,12 @@
|
||||||
"value": "121 King St , ملبورن VIC 3000, أستراليا"
|
"value": "121 King St , ملبورن VIC 3000, أستراليا"
|
||||||
},
|
},
|
||||||
"2": {
|
"2": {
|
||||||
"title": "المكتب الرئيسي",
|
"title": "رقم الهاتف",
|
||||||
"image": "/contact/2.png",
|
"image": "/contact/2.png",
|
||||||
"value": "+61 2 8376 6284"
|
"value": "+61 2 8376 6284"
|
||||||
},
|
},
|
||||||
"3": {
|
"3": {
|
||||||
"title": "المكتب الرئيسي",
|
"title": "عنوان البريد الإلكتروني",
|
||||||
"image": "/contact/3.png",
|
"image": "/contact/3.png",
|
||||||
"value": " hello@your domain.com"
|
"value": " hello@your domain.com"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,19 @@
|
||||||
// NavBar.tsx
|
import React, { useEffect, useState } from 'react';
|
||||||
import React, { useState } from 'react';
|
|
||||||
import { RoutesEnums } from '../../enums/RoutesEnums';
|
import { RoutesEnums } from '../../enums/RoutesEnums';
|
||||||
import { MdLanguage } from 'react-icons/md';
|
import { MdLanguage } from 'react-icons/md';
|
||||||
import { FaEllipsis } from 'react-icons/fa6';
|
import { FaEllipsis } from 'react-icons/fa6';
|
||||||
import { Popover } from 'antd';
|
import { Popover } from 'antd';
|
||||||
import { navBar as navBarData, Setting } from '../../../data.json';
|
import { navBar as navBarData, Setting } from '../../../data.json';
|
||||||
// Define an enum for the routes
|
import { useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
// Define a type for the link objects
|
|
||||||
interface NavLink {
|
interface NavLink {
|
||||||
path: RoutesEnums;
|
path: string;
|
||||||
label: string;
|
label: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NavBar: React.FC = () => {
|
const NavBar: React.FC = () => {
|
||||||
// Define an array of link objects using the RoutesEnums
|
const location = useLocation();
|
||||||
|
|
||||||
const links: NavLink[] = [
|
const links: NavLink[] = [
|
||||||
{ path: RoutesEnums.HOME, label: navBarData.link1 },
|
{ path: RoutesEnums.HOME, label: navBarData.link1 },
|
||||||
{ path: RoutesEnums.FEATURES, label: navBarData.link2 },
|
{ path: RoutesEnums.FEATURES, label: navBarData.link2 },
|
||||||
|
|
@ -25,47 +24,43 @@ const NavBar: React.FC = () => {
|
||||||
{ path: RoutesEnums.PRIVACY, label: navBarData.link7 },
|
{ path: RoutesEnums.PRIVACY, label: navBarData.link7 },
|
||||||
{ path: RoutesEnums.DOWNLOAD, label: navBarData.link8 },
|
{ path: RoutesEnums.DOWNLOAD, label: navBarData.link8 },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const [active, setActive] = useState(location.pathname + location.hash);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setActive(location.pathname + location.hash);
|
||||||
|
if (location.pathname + location.hash === '/') {
|
||||||
|
setActive(location.pathname+'#');
|
||||||
|
}
|
||||||
|
}, [location.pathname, location.hash]);
|
||||||
|
|
||||||
|
const handleToggle = () => setOpen(!Open);
|
||||||
const [Open, setOpen] = useState(false);
|
const [Open, setOpen] = useState(false);
|
||||||
const handleToggle = () => {
|
|
||||||
setOpen(!Open);
|
|
||||||
};
|
|
||||||
|
|
||||||
const NavBarContent = (
|
const NavBarContent = (
|
||||||
<div className="NavBarContent">
|
<div className="NavBarContent">
|
||||||
<ul className="NavBarLinks">
|
<ul className="NavBarLinks">
|
||||||
{links.map((link) => {
|
{links.map((link) => (
|
||||||
return (
|
<li onClick={handleToggle} key={link.path} className="nav-item">
|
||||||
<li
|
<a href={link.path}>{link.label}</a>
|
||||||
onClick={handleToggle}
|
</li>
|
||||||
key={link.path}
|
))}
|
||||||
className={`${'activeLink'}`}
|
|
||||||
>
|
|
||||||
<a href={link.path}>{link.label}</a>
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
const [Active, setActive] = useState(location.hash);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="NavBar">
|
<nav className="NavBar">
|
||||||
<img loading="lazy" src={Setting.Logo} className="scale" alt="" />
|
<img loading="lazy" src={Setting.Logo} className="scale" alt="" />
|
||||||
<ul className="NavBarLinks">
|
<ul className="NavBarLinks">
|
||||||
{links.map((link) => {
|
{links.map((link) => {
|
||||||
const handleClick = () => {
|
const isActive = active === link.path;
|
||||||
setActive(link.path);
|
|
||||||
};
|
|
||||||
|
|
||||||
const isActive =
|
|
||||||
Active === '' && link.path === '/#' ? true : Active === link.path;
|
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
key={link.path}
|
key={link.path}
|
||||||
onClick={handleClick}
|
onClick={() => setActive(link.path)}
|
||||||
className={`${isActive ? 'activeLink' : ''}`}
|
className={isActive ? 'activeLink' : ''}
|
||||||
>
|
>
|
||||||
<a href={link.path}>{link.label}</a>
|
<a href={link.path}>{link.label}</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user