dotnet/aspnetcore

NavLink should have a core set of classes and inactive ones rather than just tacking on "Active" ones.

Open

#37,765 创建于 2021年10月21日

在 GitHub 查看
 (11 评论) (5 反应) (0 负责人)C# (10,653 fork)batch import
area-blazorenhancementfeature-blazor-builtin-componentshelp wanted

仓库指标

Star
 (37,933 star)
PR 合并指标
 (平均合并 16天 9小时) (30 天内合并 258 个 PR)

描述

Currently the NavLink (https://github.com/dotnet/aspnetcore/blob/main/src/Components/Web/src/Routing/NavLink.cs) has a property called "ActiveClass". It should also have a property named "InactiveClass" so you can have a "core set" and then your inactive and active classes.

Here is an example. Say I have a link that would look like this when inactive

<a class="text-gray bg-dark-gray" />

But when active I want it to look like

<a class="text-white bg-dark-gray" />

In other words, I would like to change the color of the text depending if it is active or not. I am proposing the following look of component.

<NavLink class="bg-dark-gray" ActiveClass="text-white" InactiveClass="text-gray" />

This is easily acomplishable by the following changes to NavLink.

  1. Adding a parameter image
  2. changing UpdateCssClass image

This does NOT break any current functionality as people would likely just be tacking on the classes to the end. The issue with taking them on at the end is if you are using a CSS file, order matters within that for application.

I am happy to make a PR with this small change, that can help the NavLink be better!

Doesn't look any tests (that are currently written) are applicable to this. So only the component would need to be changed.

贡献者指南