-
Notifications
You must be signed in to change notification settings - Fork 1
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
Modify nav link underline to match design #54
Conversation
const pathSegments = pathname.split('/').filter((segment) => segment !== ''); | ||
if (pathSegments.length > 0 && url.toString().includes(pathSegments[0])) { | ||
return true; | ||
} |
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.
Definitely open to suggestions here if there is a better way to handle this.
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.
Maybe this
function useIsActive(url: NavigationLinkProps['href']) {
const pathname = usePathname();
const urlStr = url.toString();
return (
pathname === urlStr ||
(pathname.startsWith(urlStr) && (urlStr !== '/' || pathname === '/'))
);
}
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 like it.
const pathSegments = pathname.split('/').filter((segment) => segment !== ''); | ||
if (pathSegments.length > 0 && url.toString().includes(pathSegments[0])) { | ||
return true; | ||
} |
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.
Maybe this
function useIsActive(url: NavigationLinkProps['href']) {
const pathname = usePathname();
const urlStr = url.toString();
return (
pathname === urlStr ||
(pathname.startsWith(urlStr) && (urlStr !== '/' || pathname === '/'))
);
}
This PR updates the currently selected NavLink's underline to be offset, which more closely resembles the Figma design.
I've also created the
useIsActive
hook, which is used to check whether we are currently on a parent page or a child page of one of the parent pages.For example, navigating to
/products
or/products/ecr-viewer
should cause the "Our products" NavLink to be underlined now, as the Figma designs show.