diff --git a/components/common/NavBar.tsx b/components/common/NavBar.tsx index 97f2906..5432c45 100644 --- a/components/common/NavBar.tsx +++ b/components/common/NavBar.tsx @@ -169,7 +169,7 @@ const logoContainerVariants: Variants = { transition: { duration: 4, type: "spring", - stiffness: 20, + stiffness: 15, }, }, }; diff --git a/components/dashboard/NavBar.tsx b/components/dashboard/NavBar.tsx index b8f4a90..27b106f 100644 --- a/components/dashboard/NavBar.tsx +++ b/components/dashboard/NavBar.tsx @@ -1,35 +1,54 @@ import { m, Variants } from "framer-motion"; +import { useRouter } from "next/router"; import Link from "next/link"; function NavBar() { return ( - - - - - - - - - - - - - +
- - - + + + + + + + + + + + + + + + + + + + - +
); } @@ -43,6 +62,12 @@ const NavSvgWrap = (props: { children: React.ReactNode }) => { x={0} y={0} origin="center" + whileHover={{ + scale: 1.1, + }} + whileTap={{ + scale: 0.9, + }} > {props.children} @@ -54,9 +79,9 @@ const DashIcon = () => { ); @@ -67,9 +92,9 @@ const ExitIcon = () => { ); @@ -80,14 +105,29 @@ const RankingIcon = () => { ); }; +const ActiveLink = (props: { href: string; children: React.ReactNode }) => { + const router = useRouter(); + let styling = "text-white"; + console.log(router.pathname); + console.log(props.href); + if (router.pathname === props.href) { + styling = "text-[#a855f7]"; + } + return ( + + {props.children} + + ); +}; + const navContainerVariants: Variants = { initial: { opacity: 0, diff --git a/layouts/DashLayout.tsx b/layouts/DashLayout.tsx index 58d6344..d212598 100644 --- a/layouts/DashLayout.tsx +++ b/layouts/DashLayout.tsx @@ -34,7 +34,7 @@ function DashLayout(props: DashLayoutProps) { -
+
{/* dashboard nav bar */} @@ -46,7 +46,7 @@ function DashLayout(props: DashLayoutProps) { diff --git a/pages/api/fakeRanking.ts b/pages/api/fakeRanking.ts new file mode 100644 index 0000000..0b5731d --- /dev/null +++ b/pages/api/fakeRanking.ts @@ -0,0 +1,208 @@ +import type { NextApiRequest, NextApiResponse } from "next"; + +type Data = { + [key: string]: any; +}; + +export default async function handler( + req: NextApiRequest, + res: NextApiResponse +) { + const sortBy = req.query.s ? (req.query.s as string) : undefined; + + let data = fakeData; + if (sortBy) { + if (sortBy === "netWorth") { + data = data.sort((a, b) => b.netWorth - a.netWorth); + } else if (sortBy === "dailyChange") { + data = data.sort((a, b) => b.dailyChange - a.dailyChange); + } else if (sortBy === "dailyChangePercent") { + data = data.sort((a, b) => b.dailyChangePercent - a.dailyChangePercent); + } else if (sortBy === "shares") { + data = data.sort((a, b) => b.shares - a.shares); + } else if (sortBy === "points") { + data = data.sort((a, b) => b.points - a.points); + } else if (sortBy === "name") { + data = data.sort((a, b) => a.name.localeCompare(b.name)); + } + } + + res.status(200).json({ data }); +} + +interface fakeDataEntry { + id: number; + name: string; + netWorth: number; + points: number; + shares: number; + dailyChange: number; + dailyChangePercent: number; +} + +const fakeData: fakeDataEntry[] = [ + { + id: 4, + name: "3zachm", + netWorth: 10030, // stocks + points + points: 70, /// uninvested points + shares: 20, + dailyChange: -500, + dailyChangePercent: -0.523, + }, + { + id: 1, + name: "ModulatingForce", + netWorth: 142910, + points: 10020, + shares: 200, + dailyChange: 5420, + dailyChangePercent: 0.14, + }, + { + id: 2, + name: "notohh", + netWorth: 153495392, + points: 10020, + shares: 2432, + dailyChange: 0, + dailyChangePercent: 0, + }, + { + id: 3, + name: "SecondSock", + netWorth: 153495, + points: 15020, + shares: 20, + dailyChange: 5432, + dailyChangePercent: 0.104, + }, + { + id: 0, + name: "Ente", + netWorth: 429481824, + points: 1002022, + shares: 94214, + dailyChange: 3294444224, + dailyChangePercent: 0.94, + }, + { + id: 5, + name: "ObnoxiouslyLongNameWICKED", + netWorth: 0, + points: 100, + shares: 0, + dailyChange: 0, + dailyChangePercent: 0, + }, + { + id: 6, + name: "User", + netWorth: 0, + points: 100, + shares: 0, + dailyChange: 0, + dailyChangePercent: 0, + }, + { + id: 7, + name: "User", + netWorth: 0, + points: 100, + shares: 0, + dailyChange: 0, + dailyChangePercent: 0, + }, + { + id: 8, + name: "User", + netWorth: 0, + points: 100, + shares: 0, + dailyChange: 0, + dailyChangePercent: 0, + }, + { + id: 9, + name: "User", + netWorth: 0, + points: 100, + shares: 0, + dailyChange: 0, + dailyChangePercent: 0, + }, + { + id: 10, + name: "User", + netWorth: 0, + points: 100, + shares: 0, + dailyChange: 0, + dailyChangePercent: 0, + }, + { + id: 11, + name: "User", + netWorth: 0, + points: 100, + shares: 0, + dailyChange: 0, + dailyChangePercent: 0, + }, + { + id: 12, + name: "User", + netWorth: 0, + points: 100, + shares: 0, + dailyChange: 0, + dailyChangePercent: 0, + }, + { + id: 13, + name: "User", + netWorth: 0, + points: 100, + shares: 0, + dailyChange: 0, + dailyChangePercent: 0, + }, + { + id: 14, + name: "User", + netWorth: 0, + points: 100, + shares: 0, + dailyChange: 0, + dailyChangePercent: 0, + }, + { + id: 15, + name: "User", + netWorth: 0, + points: 100, + shares: 0, + dailyChange: 0, + dailyChangePercent: 0, + }, + { + id: 16, + name: "User", + netWorth: 0, + points: 100, + shares: 0, + dailyChange: 0, + dailyChangePercent: 0, + }, + { + id: 17, + name: "User", + netWorth: 0, + points: 100, + shares: 0, + dailyChange: 0, + dailyChangePercent: 0, + }, +]; + +export type { fakeDataEntry }; diff --git a/pages/dashboard/index.tsx b/pages/dashboard/index.tsx index 112747d..6595e0a 100644 --- a/pages/dashboard/index.tsx +++ b/pages/dashboard/index.tsx @@ -11,37 +11,37 @@ function Dashboard() { Dashboard - InvestBot 1 2 3 4 5 diff --git a/pages/dashboard/ranking.tsx b/pages/dashboard/ranking.tsx index 1c35eed..52b041a 100644 --- a/pages/dashboard/ranking.tsx +++ b/pages/dashboard/ranking.tsx @@ -1,26 +1,101 @@ import { m, Variants } from "framer-motion"; import Head from "next/head"; -import { ReactElement } from "react"; +import { ReactElement, useEffect, useState } from "react"; import DashLayout from "../../layouts/DashLayout"; +import { fakeDataEntry } from "../api/fakeRanking"; + +function Ranking() { + const [sortBy, setSortBy] = useState("netWorth"); + const [fakeData, setFakeData] = useState([]); + + useEffect(() => { + fetch(`/api/fakeRanking?s=${sortBy}`) + .then((res) => res.json()) + .then((data) => { + setFakeData(data.data); + }); + }, [sortBy]); -function Dashboard() { return ( <> Ranking - InvestBot -
+
- - rankings + Top Investors + + + + # + setSortBy("name")} + > + Name + + setSortBy("netWorth")}>Assets + setSortBy("points")} + > + Points + + setSortBy("shares")} + > + Shares + + setSortBy("dailyChange")}>Daily + + { + // TODO: add arrow to show which column is being sorted by and which direction + fakeData.map((entry: fakeDataEntry, index) => { + let changeClass = " text-lime-500"; + if (entry.dailyChangePercent < 0) { + changeClass = " text-red-500"; + } + return ( + + + + {index + 1} + + + {entry.name} + + {entry.netWorth.toLocaleString("en-US")} + + {entry.points.toLocaleString("en-US")} + + + {entry.shares.toLocaleString("en-US")} + + + {( + Math.round(entry.dailyChangePercent * 1000) / 10 + ).toFixed(1) + "%"} + + + + ); + }) + }
@@ -48,23 +123,42 @@ const containerVariants: Variants = { const headerVariants: Variants = { initial: { opacity: 0, - y: 100, + y: -100, }, animate: { opacity: 1, y: 0, transition: { - delay: 0.5, + delay: 1.0, duration: 1.0, type: "spring", bounce: 0.5, - stiffness: 80, + stiffness: 60, }, }, }; -Dashboard.getLayout = function getLayout(page: ReactElement) { +const rankingCardVariants: Variants = { + initial: { + opacity: 0, + y: 300, + }, + animate: { + opacity: 1, + y: 0, + transition: { + duration: 3, + delayChildren: 0.5, + staggerChildren: 0.25, + type: "spring", + bounce: 0.5, + stiffness: 40, + }, + }, +}; + +Ranking.getLayout = function getLayout(page: ReactElement) { return {page}; }; -export default Dashboard; +export default Ranking; diff --git a/styles/globals.css b/styles/globals.css index 800f679..52fd3d1 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -3,6 +3,7 @@ @tailwind utilities; @import url("https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"); @import url("https://fonts.googleapis.com/css?family=Plus+Jakarta+Sans:300,400,500,700&display=swap"); +@import url("https://fonts.googleapis.com/css?family=Space+Mono:300,400,500,700&display=swap"); html, body { diff --git a/tailwind.config.js b/tailwind.config.js index 68e017a..42ea415 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -10,6 +10,7 @@ module.exports = { fontFamily: { roboto: ["Roboto", "sans-serif"], plusJakarta: ["Plus Jakarta Sans", "sans-serif"], + spaceMono: ["Space Mono", "monospace"], }, }, },