-
Notifications
You must be signed in to change notification settings - Fork 2
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 activeClass to link component? #5
Comments
Seems like a good idea. 👍 I wonder whether it would be possible to do this modularly so that one could choose whether the active class is added and also the same for the ext class? |
Are you thinking about a wrapper component for |
Hmm... I didn't really have particular solution in mind. Note that you can almost achieve the functionality just by giving the property as a Perhaps both the ext and active classes could be added by some sort of component modifier functions and you'd say something like this: const AppLink = Link.withActive(Link.withExt(Link.Component))
// ...
<AppLink href='...' /> The component modifiers would grab the const withActive = LinkBase => U.withContext(({href, className}, {path}) =>
<LinkBase href={href} className={className, classWithActive(href, path)}) But this is just an idea. |
I'd add 'active' to a link if its
href.path
was an exact match for the livepath
. I'd addactive-parent
to a link if thepath.startsWith( href.path + '/' )
.Here's what I am playing with right now.
The text was updated successfully, but these errors were encountered: