Skip to content

Commit 8d2c0b2

Browse files
authored
[MenuButton] Add an optional start icon (#2707)
* Add an optional start icon for the FluentMenuButton * Add missing file
1 parent 30aaf09 commit 8d2c0b2

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
lines changed

examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5800,6 +5800,11 @@
58005800
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentPersona.GetDefaultInitials(System.String)">
58015801
<summary />
58025802
</member>
5803+
<member name="F:Microsoft.FluentUI.AspNetCore.Components.FluentSelect`1.RequiredAriaLabel">
5804+
<summary>
5805+
Gets the `Required` aria label.
5806+
</summary>
5807+
</member>
58035808
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentSelect`1.InlineStyleValue">
58045809
<summary />
58055810
</member>
@@ -6049,6 +6054,11 @@
60496054
Gets or sets the texts shown on th button.
60506055
</summary>
60516056
</member>
6057+
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenuButton.IconStart">
6058+
<summary>
6059+
Gets or sets the <see cref="T:Microsoft.FluentUI.AspNetCore.Components.Icon"/> displayed at the start of button content.
6060+
</summary>
6061+
</member>
60526062
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenuButton.ButtonStyle">
60536063
<summary>
60546064
Gets or sets the button style.

examples/Demo/Shared/Pages/MenuButton/Examples/MenuButtonAppearance.razor

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<span>
1212
Stealth: <FluentMenuButton @ref=menubutton ButtonAppearance="@Appearance.Stealth" Text="Select an item" Items="@items"></FluentMenuButton>
1313
</span>
14+
<span>
15+
With Icon: <FluentMenuButton @ref=menubutton ButtonAppearance="@Appearance.Stealth" Text="Select an item" IconStart="new Icons.Regular.Size16.Globe()" Items="@items"></FluentMenuButton>
16+
</span>
1417
</FluentStack>
1518
@code {
1619

src/Core/Components/MenuButton/FluentMenuButton.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@inherits FluentComponentBase
44

55
<div class="fluent-menubutton-container">
6-
<FluentButton Id="@_buttonId" @ref="Button" Appearance="@ButtonAppearance" Style=@ButtonStyle aria-haspopup="true" aria-expanded="@_visible" @onclick=ToggleMenu @onkeydown=OnKeyDown>
6+
<FluentButton Id="@_buttonId" @ref="Button" Appearance="@ButtonAppearance" Style=@ButtonStyle IconStart="@IconStart" aria-haspopup="true" aria-expanded="@_visible" @onclick=ToggleMenu @onkeydown=OnKeyDown>
77
@Text
88
<FluentIcon Value="@(new CoreIcons.Regular.Size12.ChevronDown())" Slot="end" Color="@_iconColor" />
99
</FluentButton>

src/Core/Components/MenuButton/FluentMenuButton.razor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ public partial class FluentMenuButton : FluentComponentBase
3838
[Parameter]
3939
public string? Text { get; set; }
4040

41+
/// <summary>
42+
/// Gets or sets the <see cref="Icon"/> displayed at the start of button content.
43+
/// </summary>
44+
[Parameter]
45+
public Icon? IconStart { get; set; }
46+
4147
/// <summary>
4248
/// Gets or sets the button style.
4349
/// </summary>
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11

22
<div class="fluent-menubutton-container" b-nrgns4mio7="">
3-
<fluent-button type="button" id="xxx" appearance="accent" blazor:onclick="1" aria-haspopup="true" blazor:onkeydown="2" b-x1200685t0="" blazor:elementreference="xxx">
4-
<svg slot="end" style="width: 12px; fill: var(--neutral-fill-rest);" focusable="false" viewBox="0 0 12 12" aria-hidden="true" blazor:onkeydown="3" blazor:onclick="4">
5-
<path d="M2.15 4.65c.2-.2.5-.2.7 0L6 7.79l3.15-3.14a.5.5 0 1 1 .7.7l-3.5 3.5a.5.5 0 0 1-.7 0l-3.5-3.5a.5.5 0 0 1 0-.7Z"></path>
6-
</svg>
7-
</fluent-button>
8-
</div>
3+
<fluent-button type="button" id="xxx" appearance="accent" blazor:onclick="1" aria-haspopup="true" blazor:onkeydown="2" b-x1200685t0="" blazor:elementreference="xxx">
4+
<svg slot="start" style="width: 24px; fill: var(--neutral-layer-1);" focusable="false" viewBox="0 0 24 24" aria-hidden="true" blazor:onkeydown="3" blazor:onclick="4">
5+
<path d="M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm0 8.25a1 1 0 0 0-1 .88v5.74a1 1 0 0 0 2 0v-5.62l-.01-.12a1 1 0 0 0-1-.88Zm0-3.75A1.25 1.25 0 1 0 12 9a1.25 1.25 0 0 0 0-2.5Z"></path>
6+
</svg>
7+
<svg slot="end" style="width: 12px; fill: var(--neutral-fill-rest);" focusable="false" viewBox="0 0 12 12" aria-hidden="true" blazor:onkeydown="5" blazor:onclick="6">
8+
<path d="M2.15 4.65c.2-.2.5-.2.7 0L6 7.79l3.15-3.14a.5.5 0 1 1 .7.7l-3.5 3.5a.5.5 0 0 1-.7 0l-3.5-3.5a.5.5 0 0 1 0-.7Z"></path>
9+
</svg>
10+
</fluent-button>
11+
</div>

tests/Core/_ToDo/MenuButton/FluentMenuButtonTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Bunit;
22
using Microsoft.Extensions.DependencyInjection;
3+
using Microsoft.FluentUI.AspNetCore.Components.Tests.Extensions;
34
using Xunit;
45

56
namespace Microsoft.FluentUI.AspNetCore.Components.Tests.MenuButton;
@@ -30,6 +31,7 @@ public void FluentMenuButton_Default()
3031
.Add(p => p.MenuStyle, menuStyle)
3132
.Add(p => p.Items, items)
3233
.Add(p => p.OnMenuChanged, onMenuChanged)
34+
.Add(p => p.IconStart, SampleIcons.Info)
3335
);
3436
//Act
3537

0 commit comments

Comments
 (0)