-
Notifications
You must be signed in to change notification settings - Fork 142
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
Solution #686
base: master
Are you sure you want to change the base?
Solution #686
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -30,12 +30,39 @@ const SubMenu = ({ isVisible, transparent }) => { | |||||
useEffect(() => { | ||||||
changeLanguage(language); | ||||||
}, [language]); | ||||||
// Check if the viewport matches a mobile screen width | ||||||
const mediaQuery = window.matchMedia('(max-width: 767px)'); | ||||||
const handleMediaQueryChange = (event) => { | ||||||
setIsMobile(event.matches); | ||||||
}; | ||||||
|
||||||
const [isMobile, setIsMobile] = useState(false); | ||||||
|
||||||
useEffect(() => { | ||||||
const mediaQuery = window.matchMedia('(max-width: 767px)'); | ||||||
const handleMediaQueryChange = (event) => { | ||||||
setIsMobile(event.matches); | ||||||
}; | ||||||
|
||||||
// Initial check | ||||||
handleMediaQueryChange(mediaQuery); | ||||||
|
||||||
// Listen for changes in viewport width | ||||||
mediaQuery.addEventListener('change', handleMediaQueryChange); | ||||||
|
||||||
// Clean up the event listener | ||||||
return () => { | ||||||
mediaQuery.removeEventListener('change', handleMediaQueryChange); | ||||||
}; | ||||||
}, []); // Empty dependency array to run the effect only once | ||||||
|
||||||
return ( | ||||||
<ul | ||||||
className={`navbar ${transparent ? 'transparent-navbar' : ''} | ||||||
${isVisible ? 'visible opacity-1' : 'hidden opacity-0'} | ||||||
${isVisible ? '' : 'pointer-events-none'} | ||||||
space-y-5 lg:space-y-0 lg:space-x-5 transition-all duration-100`} | ||||||
space-y-5 lg:space-y-0 lg:space-x-5 transition-all duration-100 | ||||||
${isMobile ? 'text-red-500' : ''}`} | ||||||
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. instead of creating a new
Suggested change
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. @PeaceOloruntoba bumping this comment |
||||||
> | ||||||
<li className="transition-element"> | ||||||
<button | ||||||
|
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.
none of this is necessary since you can just use responsive TailwindCSS classnames
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.
@PeaceOloruntoba please make this change - we don't need this extra code