generated from mateusfg7/nextjs-setup
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
166 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import * as Dialog from '@radix-ui/react-dialog' | ||
import NextLink, { LinkProps as NextLinkProps } from 'next/link' | ||
import { | ||
Icon as IconType, | ||
List, | ||
X, | ||
House, | ||
ArrowUpRight, | ||
ReadCvLogo, | ||
Tag, | ||
FolderOpen, | ||
File, | ||
GithubLogo, | ||
RssSimple, | ||
TreeStructure | ||
} from '@/shared/lib/phosphor-icons' | ||
import { AnchorHTMLAttributes, useState } from 'react' | ||
|
||
import './styles.css' | ||
import { ToggleTheme } from './toggle-theme' | ||
|
||
interface LinkProps extends NextLinkProps { | ||
title: string | ||
icon: IconType | ||
} | ||
|
||
interface OutLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> { | ||
title: string | ||
icon: IconType | ||
} | ||
|
||
export function MobileMenu() { | ||
const [isDialogOpen, setIsDialogOpen] = useState(false) | ||
|
||
const Link = ({ title, icon, ...props }: LinkProps) => { | ||
const Icon = icon | ||
|
||
return ( | ||
<NextLink | ||
{...props} | ||
onClick={() => setIsDialogOpen(false)} | ||
className="menu-item" | ||
> | ||
<Icon weight="duotone" /> | ||
<span>{title}</span> | ||
</NextLink> | ||
) | ||
} | ||
|
||
const OutLink = ({ title, icon, ...props }: OutLinkProps) => { | ||
const Icon = icon | ||
|
||
return ( | ||
<a {...props} className="menu-item" target="_blank"> | ||
<Icon weight="duotone" /> | ||
<span className="flex items-end gap-px"> | ||
<span>{title}</span> | ||
<ArrowUpRight className="text-xs" /> | ||
</span> | ||
</a> | ||
) | ||
} | ||
|
||
return ( | ||
<Dialog.Root open={isDialogOpen} onOpenChange={setIsDialogOpen}> | ||
<Dialog.Trigger asChild className="md:hidden"> | ||
<button> | ||
<List /> | ||
</button> | ||
</Dialog.Trigger> | ||
<Dialog.Portal className="z-50"> | ||
<Dialog.Overlay className="fixed inset-0 z-50 bg-black/40 backdrop-blur-md data-[state=open]:animate-overlayShow" /> | ||
<Dialog.Content className="fixed top-0 bottom-0 right-0 z-50 w-3/4 data-[state=open]:animate-slide-left data-[state=closed]:animate-slide-right"> | ||
<div className="relative flex h-screen w-full"> | ||
<Dialog.Close | ||
asChild | ||
className="absolute top-2 left-2 rounded-full p-2 backdrop-blur-lg active:bg-red-300/20 active:text-red-500 active:dark:bg-red-300/10 active:dark:text-red-400" | ||
> | ||
<button aria-label="Close"> | ||
<X weight="bold" /> | ||
</button> | ||
</Dialog.Close> | ||
<div className="flex flex-1 flex-col overflow-y-scroll rounded-tl-[2rem] rounded-bl-[2rem] bg-neutral-100 py-10 text-xl dark:bg-neutral-900"> | ||
<Link title="Home" icon={House} href="/" /> | ||
<Link title="Tags" icon={Tag} href="/tag" /> | ||
<Link title="Categories" icon={FolderOpen} href="/categories" /> | ||
<OutLink | ||
title="Portifolio" | ||
icon={ReadCvLogo} | ||
rel="author" | ||
href="/portifolio" | ||
/> | ||
<OutLink | ||
title="License" | ||
icon={File} | ||
rel="license" | ||
href="https://github.com/mateusfg7/mfg-b/blob/main/LICENSE" | ||
/> | ||
<OutLink | ||
title="Github" | ||
icon={GithubLogo} | ||
rel="external" | ||
href="https://github.com/mateusfg7/mfg-b" | ||
/> | ||
<OutLink | ||
title="RSS" | ||
icon={RssSimple} | ||
rel="noreferrer" | ||
href="/feed" | ||
/> | ||
<OutLink | ||
title="Sitemap" | ||
icon={TreeStructure} | ||
rel="noreferrer" | ||
href="/sitemap.xml" | ||
/> | ||
<ToggleTheme /> | ||
</div> | ||
</div> | ||
</Dialog.Content> | ||
</Dialog.Portal> | ||
</Dialog.Root> | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.menu-item { | ||
@apply flex items-center gap-7 px-7 py-5 leading-none active:bg-neutral-200 active:dark:bg-neutral-1000; | ||
} |
33 changes: 33 additions & 0 deletions
33
src/app/(blog)/components/header/mobile-menu/toggle-theme.tsx
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useTheme } from 'next-themes' | ||
import { Desktop, Moon, Sun } from '@/shared/lib/phosphor-icons' | ||
|
||
export function ToggleTheme() { | ||
const { setTheme, theme: currTheme } = useTheme() | ||
|
||
return ( | ||
<div className="flex flex-1 items-end justify-center pt-5"> | ||
<div className="flex overflow-hidden rounded-xl bg-neutral-200/50 text-2xl dark:bg-neutral-1000/50"> | ||
<button | ||
onClick={() => setTheme('light')} | ||
className={`p-4 ${currTheme === 'light' && 'bg-neutral-300'}`} | ||
> | ||
<Sun weight={currTheme === 'light' ? 'duotone' : 'regular'} /> | ||
</button> | ||
<button | ||
onClick={() => setTheme('system')} | ||
className={`p-4 ${ | ||
currTheme === 'system' && 'bg-neutral-300 dark:bg-neutral-800' | ||
}`} | ||
> | ||
<Desktop weight={currTheme === 'system' ? 'duotone' : 'regular'} /> | ||
</button> | ||
<button | ||
onClick={() => setTheme('dark')} | ||
className={`p-4 ${currTheme === 'dark' && 'bg-neutral-800'}`} | ||
> | ||
<Moon weight={currTheme === 'dark' ? 'duotone' : 'regular'} /> | ||
</button> | ||
</div> | ||
</div> | ||
) | ||
} |