2022-12-14 18:35:27 +00:00
|
|
|
import { usePathname } from 'next/navigation'
|
2022-12-18 22:21:38 +00:00
|
|
|
import { NavBar, NavBarMobile, NavIndicator, NavIndicators, NavLink, NavSideMenu, NavSideMenuButton, NavSideMenuPanel, NavSideMenuButtonPlaceholder, NavWrap, NavWrapMobile, NavWrapMobileGhost, NavSideMenuGhost } from './styles/navbar';
|
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';
|
|
|
|
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-18 22:21:38 +00:00
|
|
|
const [sideBarActive, setSideBarActive] = useState(true); //DEBUG: set to 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);
|
|
|
|
console.log(event.relatedTarget); // DEBUG
|
|
|
|
}
|
|
|
|
else { console.log("nah") } // DEBUG
|
|
|
|
}
|
|
|
|
|
|
|
|
let navbar: JSX.Element;
|
|
|
|
if (mobile) {
|
|
|
|
navbar = (
|
|
|
|
<>
|
|
|
|
<NavSideMenu onBlur={(event) => handleSidebar(event)} active={+sideBarActive}>
|
|
|
|
<NavBarMobile>
|
|
|
|
{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
|
|
|
|
</NavLink>
|
|
|
|
</NavBarMobile>
|
|
|
|
<NavSideMenuGhost/>
|
|
|
|
<StyleSelector />
|
|
|
|
<NavSideMenuGhost/>
|
|
|
|
<NavMenuFooter />
|
|
|
|
</NavSideMenu>
|
|
|
|
<NavWrapMobile>
|
|
|
|
<NavSideMenuButton onClick={() => setSideBarActive(!sideBarActive)} active={+sideBarActive}>Menu</NavSideMenuButton>
|
|
|
|
<NavIndicators>
|
|
|
|
{Links.links.map((item) => (
|
|
|
|
<NavIndicator active={path === item.href ? +true : +false} key={item.name} href={item.href} />
|
|
|
|
))}
|
|
|
|
</NavIndicators>
|
|
|
|
<NavSideMenuButtonPlaceholder />
|
|
|
|
</NavWrapMobile>
|
|
|
|
<NavWrapMobileGhost/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
navbar = (
|
|
|
|
<NavWrap>
|
|
|
|
<StyleSelector></StyleSelector>
|
|
|
|
<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>
|
|
|
|
<StyleSelectorPlaceholder></StyleSelectorPlaceholder>
|
|
|
|
</NavWrap>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return navbar;
|
2022-12-03 20:02:13 +00:00
|
|
|
}
|
|
|
|
|
2022-12-15 20:23:34 +00:00
|
|
|
export default PageNavbar;
|