Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/pages/components/Navbar/SubMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,31 @@ 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);
};

// Initial check
handleMediaQueryChange(mediaQuery);

// Listen for changes in viewport width
mediaQuery.addEventListener('change', handleMediaQueryChange);

// Clean up the event listener
return () => {
mediaQuery.removeEventListener('change', handleMediaQueryChange);
};
}, []);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no need for this useEffect since we're able to apply styles based on viewport size via TailwindCSS classnames - you can remove this section


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' : ''}`}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of creating a new isMobile variable, you can rely on the TailwindCSS responsive classname paradigm to assign the text color based on the device size

Suggested change
${isMobile ? 'text-red-500' : ''}`}
text-red-500 md:text-gray // text-gray should be the default text color

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PeaceOloruntoba bumping this comment

>
<li className="transition-element">
<button
Expand Down