diff --git a/assets/icons/svg/nav/search-active.svg b/assets/icons/svg/nav/search-active.svg new file mode 100644 index 000000000..1f64c1ff9 --- /dev/null +++ b/assets/icons/svg/nav/search-active.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/icons/svg/nav/search-inactive.svg b/assets/icons/svg/nav/search-inactive.svg new file mode 100644 index 000000000..b57d9c8d7 --- /dev/null +++ b/assets/icons/svg/nav/search-inactive.svg @@ -0,0 +1,4 @@ + + + + diff --git a/components/MobileBottomNav/MobileBottomNav.tsx b/components/MobileBottomNav/MobileBottomNav.tsx new file mode 100644 index 000000000..9258518f3 --- /dev/null +++ b/components/MobileBottomNav/MobileBottomNav.tsx @@ -0,0 +1,93 @@ +import React, { FC } from 'react' +import { useRouter } from 'next/router' +import Link from 'next/link' + +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 toggleSearch = () => { + // write the code here + console.log('hello') + } + + const navLinks = [ + { + inActiveIcon: , + activeIcon: , + label: 'Home', + href: '/', + spaceActive: true, + }, + { + inActiveIcon: , + activeIcon: , + label: 'Saved', + href: '/saved', + }, + { + inActiveIcon: , + activeIcon: , + label: 'Search', + onClick: toggleSearch, + }, + { + inActiveIcon: , + activeIcon: , + label: 'Our Team', + href: '/contributors', + }, + ] + + const renderLinks = () => + navLinks.map(({ inActiveIcon, activeIcon, label, href, onClick }, 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 + + const commonCls = `w-full flex items-center flex-col px-4 p-3 gap-2 font-medium rounded-xl hover:bg-slate-100 hover:bg-opacity-50 dark:hover:bg-zinc-400 dark:hover:bg-opacity-10 ${ + isActive ? 'text-primary dark:text-white' : 'text-gray-400' + }` + + return ( +
  • + {onClick ? ( + + ) : ( + + + {isActive ? activeIcon : inActiveIcon} + + {label} + + )} +
  • + ) + }) + + return ( +
    + {renderLinks()} +
    + ) +} + +export default MobileBottomNav diff --git a/layouts/GeneralLayout.tsx b/layouts/GeneralLayout.tsx index b147de122..f1bfcd54c 100644 --- a/layouts/GeneralLayout.tsx +++ b/layouts/GeneralLayout.tsx @@ -10,6 +10,7 @@ import { IContext } from 'types' import { GlobalContext } from 'context/GlobalContext' import clsx from 'clsx' import { usePathname } from 'next/navigation' +import MobileBottomNav from 'components/MobileBottomNav/MobileBottomNav' const GeneralLayout = ({ children }: { children: ReactNode }) => { const { sidebar } = useContext(GlobalContext) @@ -20,7 +21,7 @@ const GeneralLayout = ({ children }: { children: ReactNode }) => {
    @@ -38,6 +39,7 @@ const GeneralLayout = ({ children }: { children: ReactNode }) => { > {children}
    +
    diff --git a/pages/index.tsx b/pages/index.tsx index d6bfc6ad6..c142c5133 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -98,7 +98,7 @@ export default function Home() { 👾 -
    +

    {' '} LinksHub aims to provide developers with access to a wide range of