-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a navbar for blog pages in small screens...
- Loading branch information
1 parent
f683e34
commit ef4bd1b
Showing
8 changed files
with
90 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,71 @@ | ||
import React from "react"; | ||
import Link from "next/link"; | ||
|
||
import { AiOutlineMenu } from "react-icons/ai"; | ||
|
||
import { NavProps } from "@/types/Blogs"; | ||
|
||
export default function Navbar({ links, technology, slug }: NavProps) { | ||
export default function Navbar({ | ||
links, | ||
technology, | ||
slug, | ||
isOpen, | ||
setIsOpen, | ||
}: NavProps) { | ||
return ( | ||
<nav | ||
className={`fixed bg-white md:bg-transparent md:sticky top-0 md:top-24 left-0 h-screen md:h-auto z-50 duration-200`} | ||
> | ||
<div className="w-64 px-4 mt-4"> | ||
<h1 className="font-medium">{technology}</h1> | ||
{links.map((d) => ( | ||
<Link | ||
key={d.frontmatter.title} | ||
href={`${ | ||
slug | ||
? d.slug.replace(".mdx", "") | ||
: `${technology.toLowerCase()}/${d.slug.replace(".mdx", "")}` | ||
}`} | ||
> | ||
<p | ||
className={`px-4 py-1 mt-2 border-l-2 hover:border-primary capitalize ${ | ||
slug == d.slug.replace(".mdx", "") && | ||
"text-primary border-primary" | ||
<> | ||
<nav | ||
className={`fixed bg-white md:bg-transparent md:sticky top-0 md:top-24 left-0 h-screen md:h-auto z-[60] duration-200 ${ | ||
isOpen ? "translate-x-0" : "-translate-x-full md:translate-x-0" | ||
}`} | ||
> | ||
<div className="w-64 px-4 mt-4"> | ||
<h1 className="mb-4 text-2xl font-medium">{technology}</h1> | ||
{links.map((d) => ( | ||
<Link | ||
key={d.frontmatter.title} | ||
href={`${ | ||
slug | ||
? d.slug.replace(".mdx", "") | ||
: `${technology.toLowerCase()}/${d.slug.replace(".mdx", "")}` | ||
}`} | ||
> | ||
{d.slug.replace(".mdx", "").replaceAll("-", " ")} | ||
</p> | ||
</Link> | ||
))} | ||
</div> | ||
</nav> | ||
<p | ||
className={`px-4 py-1 mt-2 border-l-2 hover:border-primary capitalize ${ | ||
slug == d.slug.replace(".mdx", "") && | ||
"text-primary border-primary" | ||
}`} | ||
> | ||
{d.slug.replace(".mdx", "").replaceAll("-", " ")} | ||
</p> | ||
</Link> | ||
))} | ||
</div> | ||
</nav> | ||
{isOpen && ( | ||
<div | ||
className="md:hidden fixed left-0 w-[100vw] h-screen bg-white bg-opacity-80 backdrop-blur-sm top-0 z-50" | ||
onClick={() => setIsOpen(false)} | ||
></div> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
type NavbarSmallProps = { | ||
setIsOpen: (a: boolean) => void; | ||
}; | ||
|
||
export const NavbarSmall = ({ setIsOpen }: NavbarSmallProps) => { | ||
return ( | ||
<div className="fixed z-20 flex items-center w-full gap-3 px-4 bg-white border-b-2 opacity-95 backdrop-blur-md md:hidden h-14 top-16 md:px-8"> | ||
<AiOutlineMenu className="text-xl" onClick={() => setIsOpen(true)} /> | ||
<Link | ||
href={"/docs"} | ||
className="px-3 py-1 text-sm rounded-full bg-opacity-30 bg-primary" | ||
> | ||
Home | ||
</Link> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ef4bd1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
anilearn – ./
anilearn.vercel.app
anilearn-git-main-alireza1083.vercel.app
anilearn-alireza1083.vercel.app