-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Add active state styles for top navbar items #7429
Add active state styles for top navbar items #7429
Conversation
Good catch @arzafran 👍 |
I'm not sure why tests are not passing, and didn't understand how to debug failing ci. |
There are some failing tests on windows (appveyor). Doesn't seem related to this PR so they're probably problems on master that are affecting your PR as well. Sorry about the confusion! |
Thanks for the clarification! |
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.
Hey @arzafran!
Thank you so much for jumping on this! 🤗
As mentioned in the issue, I was sceptic if font-weight: bold
would be a good idea, but this is working quite well and I think we should get this in while discussing if we want to go down a different path in terms of styling.
However, one thing that I think we should take care of is that the active styles currently only are applied if the location.pathname
exactly matches the href
of the link -- e.g when visiting /docs/gatsby-starters/
, "Docs" won't be active -- currently it only is for /docs/
. Would be 💯 if you could take a look at this as part of this PR!
I asked @KyleAMathews how to do this and he pointed me to https://next.gatsbyjs.org/docs/migrating-from-v1-to-v2/#the-following-props-are-no-longer-available-on-link and @reach/router's getProps
.
hey! sure, I'll take a look later today! thanks. |
Yay! Thank you @arzafran! 🤗 I don't know anything about |
Hey @arzafran, I just stumbled upon #7526 (comment) which shows how to do this. |
@shannonbux Added a new issue to capture the main navigation expansion: #7544 |
Background
The active item in doc's top navbar wasn't being highlighted, hence #7425
How I've fixed it:
activeClassName="active"
tonavigation.js
itemsScreenshots:
BEFORE

AFTER
