From 2daedb1c84cf5dacb94f80a9acadc42eb2d76672 Mon Sep 17 00:00:00 2001 From: MAXASSASSINS Date: Fri, 1 Dec 2023 00:12:00 +0530 Subject: [PATCH] adding mobile only navigation component --- .../MobileBottomNav/MobileBottomNav.tsx | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 components/MobileBottomNav/MobileBottomNav.tsx diff --git a/components/MobileBottomNav/MobileBottomNav.tsx b/components/MobileBottomNav/MobileBottomNav.tsx new file mode 100644 index 000000000..f468d68ca --- /dev/null +++ b/components/MobileBottomNav/MobileBottomNav.tsx @@ -0,0 +1,93 @@ +import React, { FC, useEffect, useState } from 'react' +import { useRouter } from 'next/router' +import Link from 'next/link' + +import QuestionMarkIcon from 'assets/icons/svg/question-mark.svg' +import HomeInActiveIcon from 'assets/icons/svg/nav/home-inactive.svg' +import HomeActiveIcon from 'assets/icons/svg/nav/home-active.svg' +import SaveInActiveIcon from 'assets/icons/svg/nav/save-inactive.svg' +import SaveActiveIcon from 'assets/icons/svg/nav/save-active.svg' +import TeamInActiveIcon from 'assets/icons/svg/nav/team-inactive.svg' +import TeamActiveIcon from 'assets/icons/svg/nav/team-active.svg' +import SearchAciveIcon from 'assets/icons/svg/nav/search-active.svg' +import SearchInAciveIcon from 'assets/icons/svg/nav/search-inactive.svg' + +const MobileBottomNav: FC = () => { + const router = useRouter() + + const inActiveIconCls = 'stroke-gray-400' + const activeIconCls = 'fill-primary dark:fill-white' + + const navLinks = [ + { + inActiveIcon: , + activeIcon: , + label: 'Home', + href: '/', + spaceActive: true, + }, + { + inActiveIcon: , + activeIcon: , + label: 'Saved', + href: '/saved', + }, + { + inActiveIcon: , + activeIcon: , + label: 'Search', + }, + { + inActiveIcon: , + activeIcon: , + label: 'Our Team', + href: '/contributors', + }, + ] + + const renderLinks = () => + navLinks.map(({ inActiveIcon, activeIcon, label, href }, i) => { + const checkRoute = (val: string) => router.asPath.startsWith(val) + + const isHomeActive = !checkRoute('/saved') && !checkRoute('/contributors') + const isUrlMatched = href && checkRoute(href) + const isActive = label === 'Home' ? isHomeActive : isUrlMatched + + return ( +
  • + {href ? ( + + + {isActive ? activeIcon : inActiveIcon} + + {label} + + ) : ( +
    + + {inActiveIcon} + + {label} +
    + )} +
  • + ) + }) + + return ( +
    + {renderLinks()} +
    + ) +} + +export default MobileBottomNav