Skip to content

Commit

Permalink
refactor: Update NavMenu component to improve code organization and f…
Browse files Browse the repository at this point in the history
…ix import order
  • Loading branch information
AwalHossain committed Sep 27, 2024
1 parent 4551c81 commit e157a36
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions src/components/shared/NavMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useState } from 'react';

import { Link } from '../../types/Link';
import ThemeToggle from '../config/ThemeToggle';
import { Route, routes } from '../constants/routes';
import HyperLink from './HyperLink';
import ContactForm from '../elements/ContacForm';
import ThemeToggle from '../config/ThemeToggle';
import HyperLink from './HyperLink';

const NavMenu = (): React.ReactElement => {
const [isModalOpen, setIsModalOpen] = useState(false);
Expand All @@ -21,38 +21,40 @@ const NavMenu = (): React.ReactElement => {

// If this is the 'Contact' link, add an onClick handler
const extraProps = route.name === 'Contact' ? { onClick: handleContactClick } : {};
console.log('extraProps', url, extraProps, routes);

return (
<>
<li key={route.path} className="ml-5">
<HyperLink
link={link}
className="uppercase text-xs"
activeClassName="font-bold"
{...extraProps}
>
{route.name}
</HyperLink>
</li>
<li key={route.path} className="ml-5">
<HyperLink
link={link}
className="uppercase text-xs"
activeClassName="font-bold"
{...extraProps}

>
{route.name}
</HyperLink>
</li>
</>

);
});


return (
<>
<ul className="flex flex-row">
{links}
<li className="ml-5 text- uppercase cursor-pointer">
<ThemeToggle />
</li>
</ul>
{
isModalOpen && (
<ContactForm isOpen={isModalOpen} closeModal={closeModal} />
)
}
<ul className="flex flex-row">
{links}
<li className="ml-5 text- uppercase cursor-pointer">
<ThemeToggle />
</li>
</ul>
{
isModalOpen && (
<ContactForm isOpen={isModalOpen} closeModal={closeModal} />
)
}
</>
);
};
Expand Down

0 comments on commit e157a36

Please sign in to comment.