revert state usage for navicons
This commit is contained in:
parent
e95e7b0551
commit
03cbc4456f
6 changed files with 25 additions and 61 deletions
|
@ -3,29 +3,25 @@ import { useRouter } from "next/router";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
interface NavBarProps {
|
const ActiveLink = (props: {
|
||||||
initialPage: string;
|
href: string;
|
||||||
}
|
pageName: string;
|
||||||
|
children: React.ReactNode;
|
||||||
function NavBar(props: NavBarProps) {
|
}) => {
|
||||||
const [activePage, setActivePage] = useState(props.initialPage);
|
const router = useRouter();
|
||||||
const ActiveLink = (props: {
|
let styling = "text-white";
|
||||||
href: string;
|
// if first part of path equals the pageName
|
||||||
pageName: string;
|
if (router.pathname.split("/")[1] === props.pageName) {
|
||||||
children: React.ReactNode;
|
styling = "text-[#a855f7]";
|
||||||
}) => {
|
}
|
||||||
const router = useRouter();
|
return (
|
||||||
let styling = "text-white";
|
<Link href={props.href} className={styling}>
|
||||||
if (activePage === props.pageName) {
|
{props.children}
|
||||||
styling = "text-[#a855f7]";
|
</Link>
|
||||||
}
|
);
|
||||||
return (
|
};
|
||||||
<Link href={props.href} className={styling}>
|
|
||||||
{props.children}
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
function NavBar() {
|
||||||
return (
|
return (
|
||||||
<div className="m-3">
|
<div className="m-3">
|
||||||
<m.div
|
<m.div
|
||||||
|
@ -38,13 +34,7 @@ function NavBar(props: NavBarProps) {
|
||||||
className="flex flex-row items-center justify-center pl-5 lg:flex-col lg:pl-0 lg:pt-5"
|
className="flex flex-row items-center justify-center pl-5 lg:flex-col lg:pl-0 lg:pt-5"
|
||||||
variants={navStripVariants}
|
variants={navStripVariants}
|
||||||
>
|
>
|
||||||
<m.div
|
<m.div variants={navIconVariants} className="pr-5 lg:pr-0 lg:pb-3">
|
||||||
variants={navIconVariants}
|
|
||||||
className="pr-5 lg:pr-0 lg:pb-3"
|
|
||||||
onClick={() => {
|
|
||||||
setActivePage("dashboard");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ActiveLink href="/dashboard" pageName="dashboard">
|
<ActiveLink href="/dashboard" pageName="dashboard">
|
||||||
<DashIcon />
|
<DashIcon />
|
||||||
</ActiveLink>
|
</ActiveLink>
|
||||||
|
@ -52,9 +42,6 @@ function NavBar(props: NavBarProps) {
|
||||||
<m.div
|
<m.div
|
||||||
variants={navIconVariants}
|
variants={navIconVariants}
|
||||||
className="pr-5 lg:pr-0 lg:pt-3 lg:pb-3"
|
className="pr-5 lg:pr-0 lg:pt-3 lg:pb-3"
|
||||||
onClick={() => {
|
|
||||||
setActivePage("ranking");
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<ActiveLink href="/ranking" pageName="ranking">
|
<ActiveLink href="/ranking" pageName="ranking">
|
||||||
<RankingIcon />
|
<RankingIcon />
|
||||||
|
@ -65,13 +52,7 @@ function NavBar(props: NavBarProps) {
|
||||||
className="flex flex-row items-center justify-center pr-5 lg:w-full lg:flex-col lg:pr-0 lg:pb-5"
|
className="flex flex-row items-center justify-center pr-5 lg:w-full lg:flex-col lg:pr-0 lg:pb-5"
|
||||||
variants={navStripVariants}
|
variants={navStripVariants}
|
||||||
>
|
>
|
||||||
<m.div
|
<m.div variants={navIconVariants} className="pr-5 lg:pr-0 lg:pb-3">
|
||||||
variants={navIconVariants}
|
|
||||||
className="pr-5 lg:pr-0 lg:pb-3"
|
|
||||||
onClick={() => {
|
|
||||||
setActivePage("wiki");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ActiveLink href="/wiki" pageName="wiki">
|
<ActiveLink href="/wiki" pageName="wiki">
|
||||||
<WikiIcon />
|
<WikiIcon />
|
||||||
</ActiveLink>
|
</ActiveLink>
|
||||||
|
|
|
@ -11,7 +11,6 @@ import NavBar from "../components/dashboard/NavBar";
|
||||||
|
|
||||||
interface DashLayoutProps {
|
interface DashLayoutProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
navIcon?: string;
|
|
||||||
metaTags: {
|
metaTags: {
|
||||||
title?: string;
|
title?: string;
|
||||||
ogTitle?: string;
|
ogTitle?: string;
|
||||||
|
@ -89,7 +88,7 @@ function DashLayout(props: DashLayoutProps) {
|
||||||
{/* dashboard nav bar */}
|
{/* dashboard nav bar */}
|
||||||
<LazyMotion features={domAnimation}>
|
<LazyMotion features={domAnimation}>
|
||||||
<AnimatePresence mode="wait">
|
<AnimatePresence mode="wait">
|
||||||
<NavBar initialPage={props.navIcon ?? ""} />
|
<NavBar />
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
</LazyMotion>
|
</LazyMotion>
|
||||||
{/* dashboard content */}
|
{/* dashboard content */}
|
||||||
|
|
|
@ -80,11 +80,7 @@ const gridItemVariants: Variants = {
|
||||||
|
|
||||||
Dashboard.getLayout = function getLayout(page: ReactElement) {
|
Dashboard.getLayout = function getLayout(page: ReactElement) {
|
||||||
const metaTags = {};
|
const metaTags = {};
|
||||||
return (
|
return <DashLayout metaTags={metaTags}>{page}</DashLayout>;
|
||||||
<DashLayout metaTags={metaTags} navIcon="dashboard">
|
|
||||||
{page}
|
|
||||||
</DashLayout>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Dashboard;
|
export default Dashboard;
|
||||||
|
|
|
@ -290,11 +290,7 @@ Ranking.getLayout = function getLayout(page: ReactElement) {
|
||||||
title: "Ranking - toffee",
|
title: "Ranking - toffee",
|
||||||
description: "Top investors on toffee",
|
description: "Top investors on toffee",
|
||||||
};
|
};
|
||||||
return (
|
return <DashLayout metaTags={metaTags}>{page}</DashLayout>;
|
||||||
<DashLayout metaTags={metaTags} navIcon="ranking">
|
|
||||||
{page}
|
|
||||||
</DashLayout>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Ranking;
|
export default Ranking;
|
||||||
|
|
|
@ -662,11 +662,7 @@ UserPage.getLayout = function getLayout(page: ReactElement) {
|
||||||
"twitter:card": "summary",
|
"twitter:card": "summary",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return (
|
return <DashLayout metaTags={metaTags}>{page}</DashLayout>;
|
||||||
<DashLayout metaTags={metaTags} navIcon="user">
|
|
||||||
{page}
|
|
||||||
</DashLayout>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default UserPage;
|
export default UserPage;
|
||||||
|
|
|
@ -152,11 +152,7 @@ WikiLandingPage.getLayout = function getLayout(page: React.ReactNode) {
|
||||||
title: "Wiki - toffee",
|
title: "Wiki - toffee",
|
||||||
description: "Wiki for toffee",
|
description: "Wiki for toffee",
|
||||||
};
|
};
|
||||||
return (
|
return <DashLayout metaTags={metaTags}>{page}</DashLayout>;
|
||||||
<DashLayout metaTags={metaTags} navIcon="wiki">
|
|
||||||
{page}
|
|
||||||
</DashLayout>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default WikiLandingPage;
|
export default WikiLandingPage;
|
||||||
|
|
Loading…
Reference in a new issue