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

feat(HeaderMenu): include isCurrentPage props to HeaderMenu component #9785

Merged

Conversation

RianTavares
Copy link
Contributor

@RianTavares RianTavares commented Oct 1, 2021

Closes #9784

Currently, the links of a HeaderNavigation component (HeaderMenuItem) already have this behavior of Convey menu items and their states setting border-bottom style. Example:

tday

The point is that when creating a dropdown menu, I mean a HeaderMenu with HeaderMenuItems as children, like in "link 4" in the image above, there isn't a prop expected to set it as an active menu.

There is already a way to set the items inside the HeaderMenu as Active like below:
menu-open

As described in one item of W3 WAI (Web Accessibility Tutorials) it's important to:
"Convey menu items and their states by using color and other styling options. For example, alter the shape of a menu item, or add an icon, in addition to changing its color when it is selected."

When the HeaderMenu is closed and a page inside is active the user has no signal of wich page is select looking at the menu.

Before
4select-n

After
<img width="510" alt="4selected" src="https://user-images.githubusercontent.com/8935295/135545416-ef7e69ef-0801-4ef5-89e3-a793eaf5d409.png"

Changelog

New

  • added inside the carbon/packages/components/src/components/ui-shell/_header.scss and the carbon/packages/styles/scss/components/ui-shell/header/_header.scss a new class (${prefix}--header__submenu--current) to set the active border style (same style as HeaderMenuItem).

Changed

  • ClassName const inside HeaderMenu to link the new class created, when the prop isCurrentPage is equal true

Testing / Reviewing

  • Run react storybook
  • Go in the file react/src/components/UIShell/UIShell-story.js
  • Put the prop isCurrentPage in the HeaderMenu component tag. Example:
<HeaderMenu aria-label="Link 4" menuLinkName="Link 4" isCurrentPage>
  • Ensure that the border was added to the bottom of the HeaderMenu on the storybook "Header Base w/ Navigation" example

@RianTavares RianTavares requested a review from a team as a code owner October 1, 2021 00:03
@netlify
Copy link

netlify bot commented Oct 1, 2021

✔️ Deploy Preview for carbon-react-next ready!

🔨 Explore the source changes: acc4045

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-react-next/deploys/61708b6c0d259f00088e65df

😎 Browse the preview: https://deploy-preview-9785--carbon-react-next.netlify.app

@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2021

DCO Assistant Lite bot All contributors have signed the DCO.

@RianTavares
Copy link
Contributor Author

Related to issue #9784

set HeaderMenu as active when selected, contribute to the UX and accessibility
@RianTavares RianTavares force-pushed the feature/headerMenu-active-style branch from 9df322f to e3990a7 Compare October 1, 2021 00:21
@netlify
Copy link

netlify bot commented Oct 1, 2021

✔️ Deploy Preview for carbon-components-react ready!
Built without sensitive environment variables

🔨 Explore the source changes: 9df322f

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-components-react/deploys/6156505d37346d0007b9f05c

😎 Browse the preview: https://deploy-preview-9785--carbon-components-react.netlify.app

@netlify
Copy link

netlify bot commented Oct 1, 2021

✔️ Deploy Preview for carbon-elements ready!

🔨 Explore the source changes: 9df322f

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-elements/deploys/6156505d058f060008e85baf

😎 Browse the preview: https://deploy-preview-9785--carbon-elements.netlify.app

@netlify
Copy link

netlify bot commented Oct 1, 2021

✔️ Deploy Preview for carbon-components-react ready!
Built without sensitive environment variables

🔨 Explore the source changes: acc4045

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-components-react/deploys/61708b6c23c55f0008136bed

😎 Browse the preview: https://deploy-preview-9785--carbon-components-react.netlify.app

@netlify
Copy link

netlify bot commented Oct 1, 2021

✔️ Deploy Preview for carbon-elements ready!

🔨 Explore the source changes: acc4045

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-elements/deploys/61708b6c291a820007b4af17

😎 Browse the preview: https://deploy-preview-9785--carbon-elements.netlify.app

@RianTavares
Copy link
Contributor Author

I have read the DCO document and I hereby sign the DCO.

@RianTavares
Copy link
Contributor Author

recheck

@tay1orjones tay1orjones requested review from a team and johnbister and removed request for a team October 11, 2021 16:14
Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

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

@RianTavares Thanks for the PR! I think we should just modify the story to have Link 4 / Sub-link 2 have isCurrentPage so we can easily view the functionality in storybook

@tay1orjones
Copy link
Member

I updated the PR to include the change to the storybook and resolve the merge conflict.

@johnbister you should be able to view these changes in the storybook deploy preview Header Base w/ Navigation story once it finishes redeploying.

Copy link
Contributor

@johnbister johnbister left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Contributor

@aledavila aledavila left a comment

Choose a reason for hiding this comment

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

lgtm

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.

Add isActive style for HeaderMenu
4 participants