-
Notifications
You must be signed in to change notification settings - Fork 357
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(Nav): Updated to add wrapper for nav link text #9740
Conversation
Preview: https://patternfly-react-pr-9740.surge.sh A11y report: https://patternfly-react-pr-9740-a11y.surge.sh |
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.
The updates from before the latest commit looked good I believe. Currently the NavItem doesn't have the new nav__link-text
class being rendered like it should compared to Core; that new class is only being rendered for the NavExpandable component.
The non-expandable NavItem in Core:
The non-expandable NavItem in this PR:
@@ -68,6 +71,12 @@ A flyout should be a `Menu` component. Press `space` or `right arrow` to open a | |||
|
|||
``` | |||
|
|||
### Link text |
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.
Nit: I feel like the example name could be tweaked a little, something like "With text and icon" or "Custom link text" or something. Not sure if "link text" fully conveys what the example is showing
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.
I don't know that the use case is specifically for an icon. You can pass any react node.
id={srText ? null : this.id} | ||
onClick={(event) => this.onExpand(event, context.onToggle)} | ||
aria-expanded={expandedState} | ||
tabIndex={isSidebarOpen ? null : -1} | ||
{...buttonProps} | ||
> | ||
{title} | ||
{typeof title !== 'string' ? <span className={css(`${styles.nav}__link-text`)}>{title}</span> : title} |
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.
lgtm, only other thing is that we're having this wrapper be an opt-in for the NavItem, but providing logic here to determine if the wrapper is used or not. It seems like we'd want it to be opt in in both places?
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.
So it is not opt in here because we did not have the ability to pass a react node before. Menaing. that it is a new feature. We will not be breaking anyone.
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.
Can we open an issue to make this the default in the next breaking change, if there isn't one already?
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.
@@ -188,7 +191,7 @@ export const NavItem: React.FunctionComponent<NavItemProps> = ({ | |||
{...(hasFlyout && { ...ariaFlyoutProps })} | |||
{...props} | |||
> | |||
{children} | |||
{hasNavLinkWrapper ? <span className={css(`${styles.nav}__link-text`)}>{children}</span> : children} |
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.
👍
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.
LGTM! I have questions about the example, but I think the feature is good-to-go 🚀
@@ -7,6 +7,9 @@ ouia: true | |||
--- | |||
|
|||
import './nav.css'; | |||
import ArrowRightIcon from '@patternfly/react-icons/dist/esm/icons/arrow-right-icon'; | |||
import UserIcon from '@patternfly/react-icons/dist/esm/icons/user-icon'; |
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.
import UserIcon from '@patternfly/react-icons/dist/esm/icons/user-icon'; | |
import UserIcon from '@patternfly/react-icons/dist/esm/icons/user-icon'; |
<NavExpandable | ||
title={ | ||
<> | ||
Link 2<small>(small text)</small> |
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.
This needs a space
Link 2<small>(small text)</small> | |
Link 2 <small>(small text)</small> |
<NavExpandable | ||
title={ | ||
<> | ||
Link 3<strong>(strong text)</strong> |
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.
Link 3<strong>(strong text)</strong> | |
Link 3 <strong>(strong text)</strong> |
<UserIcon /> | ||
Subnav link 1 |
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.
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.
😎
Your changes have been released in:
Thanks for your contribution! 🎉 |
What: Closes #9735