Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added navigation for mobile devices #2198

Merged
merged 8 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions components/MobileBottomNav/MobileBottomNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ const MobileBottomNav: FC = () => {
const inActiveIconCls = 'stroke-gray-400'
const activeIconCls = 'fill-primary dark:fill-white'

const toggleSearch = () => {
// write the code here
console.log('hello')
}

const navLinks = [
{
inActiveIcon: <HomeInActiveIcon className={inActiveIconCls} />,
Expand All @@ -36,6 +41,7 @@ const MobileBottomNav: FC = () => {
inActiveIcon: <SearchInAciveIcon className={inActiveIconCls} />,
activeIcon: <SearchAciveIcon className={activeIconCls} />,
label: 'Search',
aftabrehan marked this conversation as resolved.
Show resolved Hide resolved
onclick: toggleSearch,
Anmol-Baranwal marked this conversation as resolved.
Show resolved Hide resolved
},
{
inActiveIcon: <TeamInActiveIcon className={inActiveIconCls} />,
Expand All @@ -46,38 +52,33 @@ const MobileBottomNav: FC = () => {
]

const renderLinks = () =>
navLinks.map(({ inActiveIcon, activeIcon, label, href }, i) => {
navLinks.map(({ inActiveIcon, activeIcon, label, href, onclick }, i) => {
Anmol-Baranwal marked this conversation as resolved.
Show resolved Hide resolved
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

let 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 (
<li key={i} className="list-none">
{href ? (
<Link
href={href}
className={`w-full flex 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'
}`}
>
{onclick ? (
<button onClick={onclick} className={commonCls}>
<span className="flex items-center justify-center">
{isActive ? activeIcon : inActiveIcon}
{inActiveIcon}
</span>
<span className="text-xs">{label}</span>
</Link>
</button>
) : (
<div
className={`w-full flex 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'
}`}
>
<Link href={href} className={commonCls}>
<span className="flex items-center justify-center">
{inActiveIcon}
{isActive ? activeIcon : inActiveIcon}
</span>
<span className="text-xs">{label}</span>
</div>
</Link>
)}
</li>
)
Expand Down
2 changes: 1 addition & 1 deletion layouts/GeneralLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const GeneralLayout = ({ children }: { children: ReactNode }) => {
<Header />
<SideNavbar />
<div
className={`row-start-2 row-end-3 overflow-y-scroll max-h-[calc(100vh-156px)] sm:max-h-[calc(100vh-72px)] w-full bg-gray-100 dark:bg-[#101623] ${
className={`row-start-2 row-end-3 overflow-y-scroll h-[calc(100vh-156px)] sm:h-[calc(100vh-72px)] w-full bg-gray-100 dark:bg-[#101623] ${
sidebar ? 'max-[1024px]:overflow-hidden' : ''
}`}
>
Expand Down