2022-12-14 18:35:27 +00:00
|
|
|
import { usePathname } from 'next/navigation'
|
2022-12-19 20:03:08 +00:00
|
|
|
import { NavBarMobile, NavIndicator, NavIndicators , NavSideMenu, NavSideMenuButton, NavSideMenuPanel, NavLinkMobile, NavWrapMobile, NavWrapMobileGhost, NavSideMenuGhost } from './styles/navbar/mobile';
|
|
|
|
import { NavBar, NavLink, NavWrap } from './styles/navbar/desktop';
|
2022-12-15 21:33:40 +00:00
|
|
|
import { StyleSelector, StyleSelectorPlaceholder } from './themeselector';
|
2022-12-17 23:38:37 +00:00
|
|
|
import Links from '../public/data/navbar.json';
|
2022-12-18 22:21:38 +00:00
|
|
|
import { useState } from 'react';
|
2022-12-19 20:03:08 +00:00
|
|
|
import { NavMenuFooter } from './footer';
|
2022-12-03 20:02:13 +00:00
|
|
|
|
2022-12-18 22:21:38 +00:00
|
|
|
const PageNavbar = ({ mobile }: { mobile: number }) => {
|
2022-12-14 18:35:27 +00:00
|
|
|
const path = usePathname();
|
2022-12-19 21:18:04 +00:00
|
|
|
const [sideBarActive, setSideBarActive] = useState(false);
|
2022-12-03 20:02:13 +00:00
|
|
|
|
2022-12-18 22:21:38 +00:00
|
|
|
function handleSidebar(event: any) {
|
|
|
|
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
|
|
setSideBarActive(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let navbar: JSX.Element;
|
|
|
|
if (mobile) {
|
|
|
|
navbar = (
|
|
|
|
<>
|
2022-12-19 20:03:08 +00:00
|
|
|
<NavSideMenu tabIndex={-1} onBlur={(event) => handleSidebar(event)} active={+sideBarActive}>
|
|
|
|
<NavSideMenuButton onClick={() => setSideBarActive(sideBarActive => !sideBarActive)} active={+sideBarActive}>Menu</NavSideMenuButton>
|
|
|
|
<NavSideMenuPanel active={+sideBarActive}>
|
|
|
|
<NavBarMobile>
|
|
|
|
{Links.links.map((item) => (
|
2023-03-16 21:17:37 +00:00
|
|
|
<NavLinkMobile active={path === item.href ? +true : +false} key={item.name} href={item.href}>
|
2022-12-19 20:03:08 +00:00
|
|
|
{item.name}
|
|
|
|
</NavLinkMobile>
|
|
|
|
))}
|
|
|
|
<NavLinkMobile key="Mastodon_Verify" rel="me" href="https://mastodon.neshweb.net/@neshura">
|
|
|
|
Mastodon
|
|
|
|
</NavLinkMobile>
|
|
|
|
</NavBarMobile>
|
|
|
|
<NavSideMenuGhost />
|
|
|
|
<StyleSelector mobile={mobile}/>
|
|
|
|
<NavSideMenuGhost num={2}/>
|
|
|
|
<NavMenuFooter />
|
|
|
|
</NavSideMenuPanel>
|
2022-12-18 22:21:38 +00:00
|
|
|
</NavSideMenu>
|
|
|
|
<NavWrapMobile>
|
|
|
|
<NavIndicators>
|
|
|
|
{Links.links.map((item) => (
|
2023-03-16 21:17:37 +00:00
|
|
|
<NavIndicator active={path === item.href ? +true : +false} key={item.name} href={item.href} aria-label={item.name}/>
|
2022-12-18 22:21:38 +00:00
|
|
|
))}
|
|
|
|
</NavIndicators>
|
|
|
|
</NavWrapMobile>
|
2022-12-19 20:03:08 +00:00
|
|
|
<NavWrapMobileGhost />
|
2022-12-18 22:21:38 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
navbar = (
|
|
|
|
<NavWrap>
|
2022-12-19 20:03:08 +00:00
|
|
|
<StyleSelector mobile={mobile}/>
|
2022-12-18 22:21:38 +00:00
|
|
|
<NavBar>
|
|
|
|
{Links.links.map((item) => (
|
|
|
|
<NavLink active={path === item.href ? +true : +false} key={item.name} href={item.href}>
|
|
|
|
{item.name}
|
|
|
|
</NavLink>
|
|
|
|
))}
|
|
|
|
<NavLink key="Mastodon_Verify" rel="me" href="https://mastodon.neshweb.net/@neshura">
|
|
|
|
Mastodon
|
2022-12-15 20:36:15 +00:00
|
|
|
</NavLink>
|
2022-12-18 22:21:38 +00:00
|
|
|
</NavBar>
|
2022-12-19 20:03:08 +00:00
|
|
|
<StyleSelectorPlaceholder />
|
2022-12-18 22:21:38 +00:00
|
|
|
</NavWrap>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return navbar;
|
2022-12-03 20:02:13 +00:00
|
|
|
}
|
|
|
|
|
2022-12-15 20:23:34 +00:00
|
|
|
export default PageNavbar;
|