-
Notifications
You must be signed in to change notification settings - Fork 14
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
enhance: Update font size and height of drop down for mobile view #35
Open
Tanuj1718
wants to merge
8
commits into
ohcnetwork:main
Choose a base branch
from
Tanuj1718:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+68
−54
Open
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b95a1f0
updated font size and height of showDropdown component
Tanuj1718 82b511b
revert changes in lockfile and use predefined size
Tanuj1718 1b833dd
improve mobile view for menu
Tanuj1718 c59a6fa
clicking on item will close the menu
Tanuj1718 53f261a
clicking on item will close the menu
Tanuj1718 3552141
clicking on item will close the menu
Tanuj1718 8c3de68
updated the dekstop version
Tanuj1718 d53707b
changes section to link for support tab
Tanuj1718 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,7 @@ export default function Header(props: { fixed?: boolean }) { | |
const navigation: NavigationItem[] = [ | ||
{ type: "dropdown", content: "Products", items: productsItems }, | ||
{ type: "dropdown", content: "Community", items: communityItems }, | ||
{ type: "link", content: "Supporters", href: "/supporters" }, | ||
{ type: "section", content: "Supporters", id: "supporters", page: "/supporters" }, | ||
{ type: "section", content: "Contact", id: "contact", page: "/" }, | ||
{ | ||
type: "link", | ||
|
@@ -93,7 +93,9 @@ export default function Header(props: { fixed?: boolean }) { | |
width={50} | ||
height={50} | ||
className={`md:w-[25px] ${ | ||
scrolled ? "brightness-0" : "" | ||
scrolled ? "brightness-0" : "" | ||
} ${ | ||
mobileMenuOpen?"pb-44 pt-4 m-0":"" | ||
} transition-all`} | ||
/> | ||
), | ||
|
@@ -137,15 +139,17 @@ export default function Header(props: { fixed?: boolean }) { | |
const NavigationItemRender = (props: { | ||
item: NavigationItem; | ||
onHover?: (hoverstate: boolean, leftOffset: number) => void; | ||
setMobileMenuOpen: (state: boolean) => void; | ||
setShowDropdown: (state: number | null) => void; | ||
}) => { | ||
const { item, onHover } = props; | ||
|
||
const { item, onHover, setMobileMenuOpen, setShowDropdown } = props; | ||
const className = `font-black md:font-semibold ${ | ||
scrolled ? "md:hover:text-black/100" : "md:hover:text-white/100" | ||
} transition-all px-3 flex items-center md:justify-center h-full`; | ||
|
||
const itemRef = useRef<HTMLButtonElement>(null); | ||
|
||
switch (item.type) { | ||
case "link": | ||
return ( | ||
|
@@ -157,8 +161,9 @@ export default function Header(props: { fixed?: boolean }) { | |
return ( | ||
<Link | ||
href={item.page + "#" + item.id} | ||
className={className} | ||
className={`${className} ${mobileMenuOpen?"h-3 p-6":"h-full"}`} | ||
onClick={(e) => { | ||
setMobileMenuOpen(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should come below the prevent default and stop propagation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
e.preventDefault(); | ||
e.stopPropagation(); | ||
if (path === item.page) { | ||
|
@@ -183,7 +188,7 @@ export default function Header(props: { fixed?: boolean }) { | |
return ( | ||
<button | ||
ref={itemRef} | ||
className={"nav-button " + className} | ||
className={`nav-button ${className} ${mobileMenuOpen?"h-3 p-6":"h-full"}`} | ||
onMouseOver={() => { | ||
onHover?.( | ||
true, | ||
|
@@ -198,6 +203,9 @@ export default function Header(props: { fixed?: boolean }) { | |
(itemRef.current?.clientWidth || 0) / 2 | ||
); | ||
}} | ||
onClick={() => { | ||
setShowDropdown(item.items ? item.items.length : null); | ||
}} | ||
> | ||
{item.content} | ||
</button> | ||
|
@@ -223,6 +231,10 @@ export default function Header(props: { fixed?: boolean }) { | |
className={`p-4 w-[200px] text-left rounded-lg ${ | ||
scrolled ? "hover:bg-black/5" : "hover:bg-black/10" | ||
} transition-all flex flex-col gap-2`} | ||
onClick={() => { | ||
setMobileMenuOpen(false); | ||
setShowDropdown(null); | ||
}} | ||
> | ||
<Image | ||
src={item.image} | ||
|
@@ -252,13 +264,13 @@ export default function Header(props: { fixed?: boolean }) { | |
}`} | ||
id="header" | ||
> | ||
<div | ||
className={`absolute inset-x-0 h-full bg-white/70 backdrop-blur-xl -z-10 transition-all ${ | ||
<div | ||
className={`absolute inset-x-0 h-full bg-white/70 backdrop-blur-xl -z-10 transition-all ${ | ||
scrolled ? "top-0" : "-top-full" | ||
}`} | ||
/> | ||
<nav | ||
className={`flex relative items-stretch justify-between transition-all px-4 md:px-6 lg:px-8`} | ||
className={`flex relative items-stretch justify-between transition-all px-4 md:px-6 lg:px-8 text-xs`} | ||
aria-label="Global" | ||
> | ||
<div | ||
|
@@ -296,33 +308,35 @@ export default function Header(props: { fixed?: boolean }) { | |
</button> | ||
</div> | ||
<div | ||
className={`flex md:items-center p-6 md:p-0 fixed ${ | ||
mobileMenuOpen ? "right-0" : "right-[-100vw]" | ||
className={`flex md:items-center p-6 md:p-0 fixed text-2xl ${ | ||
mobileMenuOpen ? "right-0" : "right-[-100vw] text-2xl" | ||
} md:right-auto transition-all md:static ${ | ||
scrolled ? "bg-white/50" : "bg-black/50" | ||
} pb-[300px] md:pb-0 md:bg-transparent backdrop-blur-lg md:backdrop-blur-none h-screen md:h-auto top-0 md:top-auto w-screen md:w-auto flex-col md:flex-row text-5xl md:text-base`} | ||
} pb-[300px] md:pb-0 md:bg-transparent backdrop-blur-lg md:backdrop-blur-none h-screen md:h-auto top-0 md:top-auto w-screen md:w-auto flex-col md:flex-row md:text-base`} | ||
> | ||
<button | ||
className="md:hidden block absolute top-6 right-8" | ||
onClick={() => setMobileMenuOpen(false)} | ||
> | ||
<XMarkIcon className="h-6 w-6" aria-hidden="true" /> | ||
</button> | ||
{navigation.map((item, i) => ( | ||
<NavigationItemRender | ||
item={item} | ||
key={i} | ||
onHover={(hoverstate, leftOffset) => { | ||
if (hoverstate) { | ||
setShowDropdown(i + 1); | ||
triangleRef.current?.style.setProperty( | ||
"left", | ||
`${leftOffset - triangleRef.current.clientWidth / 2}px` | ||
); | ||
} | ||
}} | ||
/> | ||
))} | ||
{navigation.map((item, i) => ( | ||
<NavigationItemRender | ||
item={item} | ||
key={i} | ||
setMobileMenuOpen={setMobileMenuOpen} | ||
setShowDropdown={setShowDropdown} | ||
onHover={(hoverstate, leftOffset) => { | ||
if (hoverstate) { | ||
setShowDropdown(i + 1); | ||
triangleRef.current?.style.setProperty( | ||
"left", | ||
`${leftOffset - triangleRef.current.clientWidth / 2}px` | ||
); | ||
} | ||
}} | ||
/> | ||
))} | ||
</div> | ||
<svg | ||
id="dropdown-triangle" | ||
|
@@ -347,7 +361,7 @@ export default function Header(props: { fixed?: boolean }) { | |
className={`nav-dropdown ${scrolled ? "bg-black/5" : "bg-black/20"} ${ | ||
scrolled ? "" : "backdrop-blur md:rounded-xl md:mx-10" | ||
} transition-all overflow-hidden fixed bottom-0 md:bottom-auto inset-x-0 md:inset-x-auto md:relative ${ | ||
!!showDropdown ? "max-h-[400px]" : "max-h-0" | ||
!!showDropdown ? " max-h-xs" : "max-h-0" | ||
}`} | ||
style={{ height: dropDownHeight }} | ||
> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why this change? 🤔
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.
Because I want to use the section properties defined in 'switch' statements. Otherwise I have to write those properties in 'link' case.
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.
@Tanuj1718 a link must be used for links, you should find a way around this without disturbing existing elements