-
-
Notifications
You must be signed in to change notification settings - Fork 581
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make the landing page responsive and works on mobile
- Loading branch information
Showing
11 changed files
with
100 additions
and
25 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,33 @@ | ||
/* eslint-disable jsx-a11y/control-has-associated-label */ | ||
type IToggleMenuButtonProps = { | ||
onClick: () => void; | ||
}; | ||
|
||
/** | ||
* A toggle button to show/hide component in small screen. | ||
* @component | ||
* @params props - Component props. | ||
* @param props.onClick - Function to run when the button is clicked. | ||
*/ | ||
const ToggleMenuButton = (props: IToggleMenuButtonProps) => ( | ||
<button | ||
className="rounded-md p-2 text-gray-900 hover:bg-white" | ||
onClick={props.onClick} | ||
type="button" | ||
> | ||
<svg | ||
className="size-6 stroke-current" | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 24 24" | ||
strokeWidth="1.5" | ||
fill="none" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
> | ||
<path d="M0 0h24v24H0z" stroke="none" /> | ||
<path d="M4 6h16M4 12h16M4 18h16" /> | ||
</svg> | ||
</button> | ||
); | ||
|
||
export { ToggleMenuButton }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,48 @@ | ||
'use client'; | ||
|
||
import Link from 'next/link'; | ||
|
||
import { ToggleMenuButton } from '@/components/ToggleMenuButton'; | ||
import { useMenu } from '@/hooks/UseMenu'; | ||
import { cn } from '@/utils/Helpers'; | ||
|
||
const CenteredMenu = (props: { | ||
logo: React.ReactNode; | ||
children: React.ReactNode; | ||
rightMenu: React.ReactNode; | ||
}) => ( | ||
<div className="flex items-center justify-between"> | ||
<Link href="/">{props.logo}</Link> | ||
|
||
<nav> | ||
<ul className="flex flex-row items-center gap-x-6 text-lg font-medium [&_li:hover]:opacity-100 [&_li]:opacity-60"> | ||
{props.children} | ||
</ul> | ||
</nav> | ||
|
||
<div> | ||
<ul className="flex flex-row items-center gap-x-4 text-lg font-medium [&_li:not(:last-child):hover]:opacity-100 [&_li:not(:last-child)]:opacity-60"> | ||
{props.rightMenu} | ||
</ul> | ||
}) => { | ||
const { showMenu, handleToggleMenu } = useMenu(); | ||
|
||
const navClass = cn('max-lg:w-full max-lg:bg-secondary max-lg:p-5', { | ||
'max-lg:hidden': !showMenu, | ||
}); | ||
|
||
return ( | ||
<div className="flex flex-wrap items-center justify-between"> | ||
<Link href="/">{props.logo}</Link> | ||
|
||
<div className="lg:hidden"> | ||
<ToggleMenuButton onClick={handleToggleMenu} /> | ||
</div> | ||
|
||
<nav className={cn('rounded-t max-lg:mt-2', navClass)}> | ||
<ul className="flex gap-x-6 gap-y-1 text-lg font-medium max-lg:flex-col [&_a:hover]:opacity-100 [&_a]:opacity-60 max-lg:[&_a]:inline-block max-lg:[&_a]:w-full"> | ||
{props.children} | ||
</ul> | ||
</nav> | ||
|
||
<div | ||
className={cn( | ||
'rounded-b max-lg:border-t max-lg:border-border', | ||
navClass, | ||
)} | ||
> | ||
<ul className="flex flex-row items-center gap-x-4 text-lg font-medium [&_li:not(:last-child):hover]:opacity-100 [&_li:not(:last-child)]:opacity-60"> | ||
{props.rightMenu} | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
); | ||
}; | ||
|
||
export { CenteredMenu }; |
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,19 @@ | ||
import { useState } from 'react'; | ||
|
||
/** | ||
* React Hook to toggle element. Mostly used for responsive menu. | ||
* @hook | ||
*/ | ||
export const useMenu = () => { | ||
const [showMenu, setShowMenu] = useState(false); | ||
|
||
const handleToggleMenu = () => { | ||
setShowMenu((prevState) => !prevState); | ||
}; | ||
|
||
const handleClose = () => { | ||
setShowMenu(false); | ||
}; | ||
|
||
return { showMenu, handleToggleMenu, handleClose }; | ||
}; |
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