Skip to content

Commit 4423b55

Browse files
authored
[dev-v5][CounterBadge] Change Count type to int (#4465)
* - Change Count type to int - Allow specifying OverflowCount in example - Update some test * Process review comments
1 parent 2a5dcba commit 4423b55

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

examples/Demo/FluentUI.Demo.Client/Documentation/Components/Badges/CounterBadge/Examples/CounterBadgeAttached.razor

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@
1515
<FluentStack VerticalAlignment="VerticalAlignment.Top">
1616
<span>
1717
<FluentStack HorizontalAlignment="HorizontalAlignment.Left" Orientation="Orientation.Vertical">
18-
<FluentTextInput InputMode="TextInputMode.Numeric" @bind-Value="@count" Label="Count" AutoComplete="off" />
19-
<FluentTextInput InputMode="TextInputMode.Numeric" @bind-Value="@offsetX" Label="Offset X" AutoComplete="off" />
18+
<FluentTextInput InputMode="TextInputMode.Numeric" @bind-Value="@count" Label="Count" AutoComplete="off" />
19+
<FluentTextInput InputMode="TextInputMode.Numeric" @bind-Value="@overflowCount" Label="Overflow count" AutoComplete="off" />
20+
<FluentTextInput InputMode="TextInputMode.Numeric" @bind-Value="@offsetX" Label="Offset X" AutoComplete="off" />
2021
<FluentTextInput InputMode="TextInputMode.Numeric" @bind-Value="@offsetY" Label="Offset Y" AutoComplete="off" />
2122
</FluentStack>
2223
</span>
2324
<div class="grid">
2425
<div style="grid-area:contents">
2526
<FluentCounterBadge Color="BadgeColor.Danger"
26-
Count="@(UInt16.TryParse(count, out ushort c) ? c : null)"
27+
Count="@(int.TryParse(count, out int c) ? c : null)"
28+
OverflowCount="@(int.TryParse(overflowCount, out int oc) ? oc : null)"
2729
OffsetX="@(SByte.TryParse(offsetX, out sbyte x) ? x : null)"
2830
OffsetY="@(SByte.TryParse(offsetY, out sbyte y) ? y : null)"
2931
Size="BadgeSize.Small"

examples/Demo/FluentUI.Demo.Client/Documentation/Components/Badges/CounterBadge/Examples/CounterBadgeAttached.razor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace FluentUI.Demo.Client.Documentation.Components.Badges.CounterBadge.Exam
88
public partial class CounterBadgeAttached
99
{
1010
private string? count = "3";
11+
private string? overflowCount = string.Empty;
1112
private string? offsetX;
1213
private string? offsetY;
1314

src/Core/Components/Badge/FluentCounterBadge.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public FluentCounterBadge(LibraryConfiguration configuration) : base(configurati
5353
/// With ShowZero being false by default, the default result will be an empty counter badge
5454
/// </summary>
5555
[Parameter]
56-
public ushort? Count { get; set; }
56+
public int? Count { get; set; }
5757

5858
/// <summary>
5959
/// Gets or sets the badge's overflow count.

tests/Core/Components/Badge/FluentCounterBadgeTests.razor

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,22 @@
3030

3131
// Assert
3232
var cb = cut.FindComponent<FluentCounterBadge>();
33-
Assert.Equal((ushort?)3, cb.Instance.Count);
33+
Assert.Equal(3, cb.Instance.Count);
3434
}
3535

3636
[Fact]
3737
public void FluentCounterBadge_CountOutOfRange()
3838
{
39-
// Arrange && Act
40-
var cut = Render(@<FluentCounterBadge Count="256" />);
39+
// Arrange
40+
long c = (long)int.MaxValue + 1;
41+
42+
// Act
43+
var cut = Render(@<FluentCounterBadge Count="@((int)c)" />);
4144

4245
// Assert
4346
Assert.NotNull(cut.Find("fluent-counter-badge"));
4447
var count = cut.Find("fluent-counter-badge").GetAttribute("count");
45-
Assert.Equal("256", count);
48+
Assert.Null(count);
4649
}
4750

4851
[Theory]
@@ -227,6 +230,7 @@
227230
var cut = Render(@<FluentCounterBadge Count="11" OverflowCount="10" />);
228231
// Assert
229232
Assert.Equal("10", cut.Find("fluent-counter-badge").GetAttribute("overflow-count"));
233+
Assert.Equal("11", cut.Find("fluent-counter-badge").GetAttribute("count"));
230234
}
231235

232236
[Fact]
@@ -403,6 +407,3 @@
403407
Assert.NotNull(cb);
404408
}
405409
}
406-
407-
408-

0 commit comments

Comments
 (0)