Skip to content

765-fix: Fix styles active menu item #814

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

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

JuliaAnt
Copy link
Collaborator

@JuliaAnt JuliaAnt commented Mar 12, 2025

What type of PR is this? (select all that apply)

  • πŸ• Feature
  • πŸ› Bug Fix
  • 🚧 Breaking Change
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ“ Documentation Update

Description

Rework desktop and mobile menus according to the new design.

Related Tickets & Documents

Screenshots, Recordings

Before:

Screenshot 2025-04-12 at 23 03 28

After:

Screenshot 2025-04-12 at 23 04 21

Added/updated tests?

  • πŸ‘Œ Yes
  • πŸ™…β€β™‚οΈ No, because they aren't needed
  • πŸ™‹β€β™‚οΈ No, because I need help

[optional] Are there any post deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

Feel free to hit me with your best practices :))

so-little-work-i-done

@JuliaAnt JuliaAnt self-assigned this Mar 12, 2025
@github-actions github-actions bot changed the title fix: 765 - change style of active menu item. Fix lighthouse problem 765-fix: Fix styles active menu item Mar 12, 2025
@SpaNb4
Copy link
Collaborator

SpaNb4 commented Mar 13, 2025

The arrow's focus state could be improved
image

This isn't due to your changes, but the spacing is inconsistent here
image

Copy link

Lighthouse Report:

  • Performance: 97 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link
Collaborator

@SpaNb4 SpaNb4 left a comment

Choose a reason for hiding this comment

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

Keyboard navigation of submenus seems broken to me. First Enter/Space press redirects the page, second opens the menu

2025-03-15.12-16-29.mp4

Copy link
Collaborator

@ansivgit ansivgit left a comment

Choose a reason for hiding this comment

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

image

For a non-yellow background of the hero-banner, the underline blends in with the image. Also, I think the current page should be highlighted.

setDropdownOpen((prev) => !prev);
}
};

const handleEscKeyPress = (e: KeyboardEvent<HTMLElement>) => {
if (e.code === 'Escape') {
Copy link
Collaborator

@ansivgit ansivgit Mar 18, 2025

Choose a reason for hiding this comment

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

Let's all keys' codes move to constant like KEY_CODES = {ESCAPE: 'Escape', .....} You could add it here src/core/const/index.ts

@YulikK YulikK changed the title 765-fix: Fix styles active menu item DRAFT - 765-fix: Fix styles active menu item Mar 18, 2025
Copy link

Lighthouse Report:

  • Performance: 96 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

width: max-content;
min-width: 100%;
// min-width: calc(100% + var(--header-padding));
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets delete it

@YulikK YulikK changed the title DRAFT - 765-fix: Fix styles active menu item 765-fix: Fix styles active menu item Apr 14, 2025
@oibioib
Copy link
Collaborator

oibioib commented Apr 14, 2025

The breadcrumbs on the site are broken.
2025-04-14_212418

Copy link
Member

@Quiddlee Quiddlee left a comment

Choose a reason for hiding this comment

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

Screenshot 2025-04-17 at 2 58 22β€―PM Screenshot 2025-04-17 at 2 49 07β€―PM Screenshot 2025-04-17 at 2 48 25β€―PM Screenshot 2025-04-17 at 3 04 29β€―PM

some design inconsistencies, i found so far

  1. the top shadow should not be visible
  2. the shadow value overall is not matched the design
  3. Support Us description should't contain hover
  4. Support Us icons size inconsistent with the design
  5. Support Us there is a gap missing between columns
  6. Support Us typography mismatch
  7. Courses the course text should be vertically aligned to the end
  8. Courses the gap between rows inconsistent with the design
  9. Courses the gap between icon and typography inconsistent with the design
  10. in the header RS icon should be smaller as the design shows
  • bunch of other spacing/typography inconsistencies, please pay attention to these

</div>
);
};
export const DropdownWrapper = forwardRef<HTMLDivElement, DropdownWrapperProps>(
Copy link
Member

Choose a reason for hiding this comment

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

since we're using react 19, can we get rid of forward ref please


const onDropdownToggle = () => {
if (!isDropdownOpen) {
window.dispatchEvent(new CustomEvent('closeAllDropdowns'));
Copy link
Member

Choose a reason for hiding this comment

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

let's wrap 'closeAllDropdowns' event in constant

className={cx('dropdown-arrow')}
aria-expanded={isDropdownOpen}
>
{label === 'Support Us'
Copy link
Member

Choose a reason for hiding this comment

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

let's think what if in the near future we wanted to change Support Us label to something else, in this case we can potentially miss that nav-item is relying on Support Us string to render the icon.

let's add the new prop to nav-item called icon, and delegate passing the icon to consumer component. In this case the nav-item don't need to worry about what icon to render, and for us developers, in case of refactor, there is no way we can miss that the icon could be potentially lost.

Comment on lines 110 to 130
&& (pathname.includes(ROUTES.MENTORSHIP)
? (
<Image
src={iconBlue}
alt="Donate-icon"
width={18}
height={16}
aria-hidden="true"
data-testid="school-item-icon"
/>
)
: (
<Image
src={iconYellow}
alt="Donate-icon"
width={18}
height={16}
aria-hidden="true"
data-testid="school-item-icon"
/>
))}
Copy link
Member

Choose a reason for hiding this comment

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

could be simplified to this

           const iconSrc = pathname.includes(ROUTES.MENTORSHIP) ? iconBlue : iconYellow
             
            <Image
              src={iconSrc}
              alt="Donate-icon"
              width={18}
              height={16}
              aria-hidden="true"
              data-testid="school-item-icon"
            />

export function useOutsideClick<T extends HTMLElement>(
ref: React.RefObject<T | null>,
callback: () => void,
when: boolean,
Copy link
Member

Choose a reason for hiding this comment

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

What does when mean in our case?

Comment on lines 145 to 154
<button onClick={() => onMenuItemClick('Community')} className={cx('category-link', color)}>
<span>Community</span>
<span
className={cx('dropdown-arrow', { rotate: Boolean(activeDropdowns.has('Community')) })}
role="button"
aria-expanded={activeDropdowns.has('Community')}
>
<DropdownArrow />
</span>
</button>
Copy link
Member

Choose a reason for hiding this comment

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

this button is duplicated several times across the file, let's wrap it in a reusable component

Comment on lines 28 to 30
const isStaticImageData = (icon: StaticImageData | ReactNode): icon is StaticImageData =>
typeof icon === 'object' && icon !== null && 'src' in icon;

Copy link
Member

Choose a reason for hiding this comment

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

let's move this to shared/helpers

Comment on lines 35 to 50
&& (isStaticImageData(icon)
? (
<Image
src={icon}
alt=""
width={32}
height={32}
aria-hidden="true"
data-testid="school-item-icon"
/>
)
: (
<span aria-hidden="true" data-testid="school-item-icon">
{icon}
</span>
))}
Copy link
Member

Choose a reason for hiding this comment

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

can we please, get rid of renderIcon and inside donateOptions in icon field, just place icons src?

@@ -12,13 +12,31 @@ type SchoolMenuProps = PropsWithChildren &
HTMLProps<HTMLUListElement> & {
heading?: string;
color?: Color;
layout?: 'columns' | 'single';
mobileClass?: 'visible' | 'hidden';
Copy link
Member

Choose a reason for hiding this comment

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

IMO this adds extra complexity to consumer component, hence in the end we are getting duplicated code across the app mobileClass={activeDropdowns.has('Mentorship') ? 'visible' : 'hidden'}>

let's keep it as simple as possible and delegate rendering the right class to the component itself

Suggested change
mobileClass?: 'visible' | 'hidden';
isVisible?: boolean;

Comment on lines 32 to 39
style={
layout === 'columns'
? { gridTemplateRows: `repeat(${Math.ceil(Children.count(children) / 2)}, auto)` }
: undefined
}
>
{children}
</ul>
Copy link
Member

Choose a reason for hiding this comment

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

we could simplify this logic by applying these styles

&--columns {
      grid-auto-flow: column;
      grid-template-rows: repeat(2, 48px);

      &:has(:nth-child(5)) {
        grid-template-rows: repeat(auto-fit, 48px);
      }
}

Copy link

github-actions bot commented May 8, 2025

Lighthouse Report:

  • Performance: 78 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

github-actions bot commented May 8, 2025

Lighthouse Report:

  • Performance: 73 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

@SpaNb4
Copy link
Collaborator

SpaNb4 commented May 14, 2025

@JuliaAnt, please check the keyboard navigation. It seems like this functionality is no longer working

Comment on lines 6 to 34
export const donateOptions = [
{
id: 1,
linkLabel: 'Donate now',
icon: 'openCollective',
icon: OpenCollectiveIcon,
href: LINKS.DONATE_OPEN_COLLECTIVE,
},
{
id: 2,
linkLabel: 'Subscribe now',
icon: 'boosty',
icon: BoostyIcon,
href: LINKS.DONATE_BOOSTY,
},
];

export const donateOptionsForNavMenu = [
{
id: 1,
linkLabel: 'Subscribe on Boosty',
icon: boostyIconMenu,
href: LINKS.DONATE_BOOSTY,
},
{
id: 2,
linkLabel: 'Donate on Opencollective',
icon: openCollective,
href: LINKS.DONATE_OPEN_COLLECTIVE,
},
];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we make one object for support info?
{
id: 1,
buttonLinkLabel: 'Donate now',
menuLinkLabel: 'Donate on Opencollective',
buttonIcon: OpenCollectiveIcon,
menuImage: openCollective
href: LINKS.DONATE_OPEN_COLLECTIVE,
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

we already have icon boosty-icon.svg. Can we use it for menu and for button?

justify-content: space-between;

max-width: 470px;
margin-right: 62px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we not use margin and do it with an assistant property gap?

import classNames from 'classnames/bind';
import { usePathname } from 'next/navigation';

import { BurgerMenu } from './ui/burger/burger';
import { donateOptionsForNavMenu } from '../../../dev-data/donate-options.data';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add donateOptionsForNavMenu to file dev-data/index.ts
And update import:
import { donateOptionsForNavMenu } from 'data';

return (
<nav className={cx('navbar', color)} data-testid="navigation">
<nav className={cx('navbar', 'white')} data-testid="navigation">
Copy link
Collaborator

Choose a reason for hiding this comment

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

if we have only one color for nav panel now, can we remove white-class and add all propertis in navbar?

@@ -21,7 +29,7 @@
&:hover {
.title {
&.dark {
color: $color-black;
color: #969fa8;
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets make a color constant

Comment on lines 79 to 88
opacity: 0;
}

&.visible {
@extend %transition-all;

max-height: 624px;
margin-top: 26px;
visibility: visible;
opacity: 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use constant for opacity
$opacity-100, $opacity-0

Comment on lines +32 to +33
visible: isVisible === true,
hidden: isVisible === false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we move all properties from .visible to .school-menu and add .hidden if isVisible===true?

))}
</SchoolMenu>
</div>
</div>
</nav>
Copy link
Collaborator

Choose a reason for hiding this comment

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

as a suggestion above, if you're going to split the main header menu into separate blocks, you should split the mobile menu as well. It came out as a very large component

Comment on lines +29 to +35
<Image
src={icon}
alt="Donate-icon"
width={20}
height={18}
aria-hidden="true"
/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand that we have only one icon now, but still it seems wrong to set in alt donate-icon - if the icon comes in props, maybe then together with the icon to pass the alt? And let's write β€œlittle heart” in this icon alt.

Copy link

Lighthouse Report:

  • Performance: 79 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

Lighthouse Report:

  • Performance: 99 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Menu items active text color Desktop menu rework
7 participants