diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNav.razor.internal.cs b/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNav.razor.internal.cs index 4752100592..b22316c812 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNav.razor.internal.cs +++ b/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNav.razor.internal.cs @@ -1,4 +1,4 @@ -namespace Bit.BlazorUI; +namespace Bit.BlazorUI; public partial class BitNav { @@ -217,6 +217,43 @@ internal bool GetForceAnchor(TItem item) return item.GetValueFromProperty(NameSelectors.ForceAnchor.Name, false); } + internal BitIconInfo? GetIcon(TItem item) + { + if (item is BitNavItem navItem) + { + return BitIconInfo.From(navItem.Icon, navItem.IconName); + } + + if (item is BitNavOption navOption) + { + return BitIconInfo.From(navOption.Icon, navOption.IconName); + } + + if (NameSelectors is null) return null; + + BitIconInfo? icon = null; + if (NameSelectors.Icon.Selector is not null) + { + icon = NameSelectors.Icon.Selector!(item); + } + else + { + icon = item.GetValueFromProperty(NameSelectors.Icon.Name); + } + + string? iconName = null; + if (NameSelectors.IconName.Selector is not null) + { + iconName = NameSelectors.IconName.Selector!(item); + } + else + { + iconName = item.GetValueFromProperty(NameSelectors.IconName.Name); + } + + return BitIconInfo.From(icon, iconName); + } + internal string? GetIconName(TItem item) { if (item is BitNavItem navItem) diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNav.razor.parameters.cs b/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNav.razor.parameters.cs index f9eb458d98..9e646a62a8 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNav.razor.parameters.cs +++ b/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNav.razor.parameters.cs @@ -1,4 +1,4 @@ -namespace Bit.BlazorUI; +namespace Bit.BlazorUI; public partial class BitNav { @@ -13,10 +13,18 @@ public partial class BitNav /// [Parameter] public bool AllExpanded { get; set; } + /// + /// The icon for the chevron-down element of each nav item. + /// Takes precedence over when both are set. + /// Use this property to render icons from external libraries like FontAwesome, Material Icons, or Bootstrap Icons. + /// For built-in Fluent UI icons, use instead. + /// + [Parameter] public BitIconInfo? ChevronDownIcon { get; set; } + /// /// The custom icon name of the chevron-down element of each nav item. /// - [Parameter] public string? ChevronDownIcon { get; set; } + [Parameter] public string? ChevronDownIconName { get; set; } /// /// Items to render as children. diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavItem.cs b/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavItem.cs index 635f43e122..99c5b6b4c5 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavItem.cs +++ b/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavItem.cs @@ -47,6 +47,19 @@ public class BitNavItem /// public bool ForceAnchor { get; set; } + /// + /// Icon to render next to the nav item. + /// Takes precedence over when both are set. + /// Use this property to render icons from external libraries like FontAwesome, Material Icons, or Bootstrap Icons. + /// For built-in Fluent UI icons, use instead. + /// + /// + /// Bootstrap: Icon=BitIconInfo.Bi("gear-fill") + /// FontAwesome: Icon=BitIconInfo.Fa("solid house") + /// Custom CSS: Icon=BitIconInfo.Css("my-icon-class") + /// + public BitIconInfo? Icon { get; set; } + /// /// Name of an icon to render next to the nav item. /// diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavNameSelectors.cs b/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavNameSelectors.cs index 3d3a816801..2d8d21926d 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavNameSelectors.cs +++ b/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavNameSelectors.cs @@ -47,6 +47,11 @@ public class BitNavNameSelectors /// public BitNameSelectorPair ForceAnchor { get; set; } = new(nameof(BitNavItem.ForceAnchor)); + /// + /// The Icon field name and selector of the custom input class (see ). + /// + public BitNameSelectorPair Icon { get; set; } = new(nameof(BitNavItem.Icon)); + /// /// The IconName field name and selector of the custom input class (see ). /// diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavOption.razor.cs b/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavOption.razor.cs index c553645173..e48897a683 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavOption.razor.cs +++ b/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavOption.razor.cs @@ -61,6 +61,19 @@ public partial class BitNavOption : ComponentBase, IDisposable /// [Parameter] public bool ForceAnchor { get; set; } + /// + /// Icon to render next to the nav option. + /// Takes precedence over when both are set. + /// Use this property to render icons from external libraries like FontAwesome, Material Icons, or Bootstrap Icons. + /// For built-in Fluent UI icons, use instead. + /// + /// + /// Bootstrap: Icon=BitIconInfo.Bi("gear-fill") + /// FontAwesome: Icon=BitIconInfo.Fa("solid house") + /// Custom CSS: Icon=BitIconInfo.Css("my-icon-class") + /// + [Parameter] public BitIconInfo? Icon { get; set; } + /// /// Name of an icon to render next to the nav option. /// diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/_BitNavChild.razor b/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/_BitNavChild.razor index 13b479a432..3ee519234e 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/_BitNavChild.razor +++ b/src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/_BitNavChild.razor @@ -1,4 +1,4 @@ -@namespace Bit.BlazorUI +@namespace Bit.BlazorUI @typeparam TItem
  • @@ -13,7 +13,8 @@ var text = Nav.GetText(Item); var childItems = Nav.GetChildItems(Item); var description = Nav.GetDescription(Item); - var iconName = Nav.GetIconName(Item); + var chevronIcon = BitIconInfo.From(Nav.ChevronDownIcon, Nav.ChevronDownIconName ?? $"ChevronRight {(isExpanded ? "bit-nav-exp" : "bit-ico-r90")}"); + var icon = Nav.GetIcon(Item); var url = Nav.GetUrl(Item); var title = Nav.GetTitle(Item); var target = Nav.GetTarget(Item); @@ -66,7 +67,7 @@
    @if (Nav.NoCollapse is false) { -