From 42cf45fa19a8d7cc43363b73d21a81d347ff5727 Mon Sep 17 00:00:00 2001 From: Alex Zoitos Date: Mon, 14 Sep 2020 23:09:33 -0400 Subject: [PATCH] refactor(frontend): make sidebar links map (#90) --- src/components/Layout/Sidebar/index.tsx | 118 ++++++++++++++++-------- 1 file changed, 81 insertions(+), 37 deletions(-) diff --git a/src/components/Layout/Sidebar/index.tsx b/src/components/Layout/Sidebar/index.tsx index ddcf941a4..cec9e1394 100644 --- a/src/components/Layout/Sidebar/index.tsx +++ b/src/components/Layout/Sidebar/index.tsx @@ -1,13 +1,47 @@ -import React from 'react'; +import React, { ReactNode } from 'react'; import Transition from '../../Transition'; import Link from 'next/link'; +import { useRouter } from 'next/router'; interface SidebarProps { open?: boolean; setClosed: () => void; } +interface SidebarLinkProps { + href: string; + svgIcon: ReactNode; + name: string; + activeRegExp: RegExp; + as?: string; +} + +const SidebarLinks: SidebarLinkProps[] = [ + { + href: '/', + name: 'Dashboard', + svgIcon: ( + + + + ), + activeRegExp: /^\/(discover\/?(movies|tv)?)?$/, + }, +]; + const Sidebar: React.FC = ({ open, setClosed }) => { + const router = useRouter(); return ( <>
@@ -63,25 +97,30 @@ const Sidebar: React.FC = ({ open, setClosed }) => {
@@ -102,25 +141,30 @@ const Sidebar: React.FC = ({ open, setClosed }) => { Overseerr