Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7ab2d22
Add rating component
franklupo Jun 25, 2024
aaca1ed
Merge branch 'dev' into rating
vnbaaij Jun 25, 2024
9ef2f20
Fix IconVariant
franklupo Jun 25, 2024
1cebab9
Add IconColor
franklupo Jun 25, 2024
8715dd1
Merge branch 'rating' of https://github.com/franklupo/fluentui-blazor…
franklupo Jun 25, 2024
3b81877
Fix page name
franklupo Jun 25, 2024
fa89df7
Add support disabled
franklupo Jun 25, 2024
d3e007d
Add support label
franklupo Jun 25, 2024
0796e11
Remove area not overable
franklupo Jun 25, 2024
84de233
Imprve icona name
franklupo Jun 25, 2024
1cd1940
Add icon color
franklupo Jun 25, 2024
a099a81
Add support arrowup/arrowdown
franklupo Jun 25, 2024
868c559
Improve sample
franklupo Jun 25, 2024
ae7f412
Add event HoveredValueChanged
franklupo Jun 25, 2024
c3a0607
Add IconCustomColor
franklupo Jun 25, 2024
b379fd0
Fix aria-readonly
franklupo Jun 25, 2024
792ba8d
Fix LabelTemplate
franklupo Jun 25, 2024
56cee95
Improve code style
franklupo Jun 25, 2024
fd99146
Improve icon name
franklupo Jun 25, 2024
62d8475
Add IconWidth
franklupo Jun 25, 2024
833e18a
Fix label documentation
franklupo Jun 25, 2024
872de54
Fix default value
franklupo Jun 25, 2024
45e19ca
Fix HoveredValueChanged to OnPointerOver
franklupo Jun 25, 2024
3b91b0a
Add AllowReset and rewrite HandleKeyDownAsync
franklupo Jun 26, 2024
5fc5059
Add AllowReset
franklupo Jun 26, 2024
99040df
Rewrite key down event
franklupo Jun 26, 2024
111e0e4
Fix Style and Class
franklupo Jun 26, 2024
88a94e9
Component explanation
franklupo Jun 26, 2024
26a4b0f
Merge branch 'dev' into rating
vnbaaij Jun 26, 2024
6fc81f6
Merge branch 'microsoft:dev' into rating
franklupo Jun 26, 2024
37a800e
Improve code
franklupo Jun 26, 2024
dbb9479
Add Unit test
franklupo Jun 27, 2024
b7fbd45
Fix IconWidth like React Component
franklupo Jun 27, 2024
79d25d2
Merge branch 'dev' into rating
vnbaaij Jun 27, 2024
ce9637f
Merge branch 'dev' into rating
vnbaaij Jun 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve code style
  • Loading branch information
franklupo committed Jun 25, 2024
commit 56cee95daab2e803584f6f94dde97b771e884aa4
25 changes: 18 additions & 7 deletions src/Core/Components/Rating/FluentRating.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ public partial class FluentRating : FluentInputBase<int>
/// <summary>
/// Gets or sets the maximum value.
/// </summary>
[Parameter] public int MaxValue { get; set; } = 10;
[Parameter]
public int MaxValue { get; set; } = 10;

/// <summary>
/// Gets or sets the icon drawing and fill color.
/// Value comes from the <see cref="AspNetCore.Components.Color"/> enumeration. Defaults to Accent.
/// </summary>
[Parameter] public Color? IconColor { get; set; }
[Parameter]
public Color? IconColor { get; set; }

/// <summary>
/// Gets or sets the icon drawing and fill color to a custom value.
Expand All @@ -33,17 +35,20 @@ public partial class FluentRating : FluentInputBase<int>
/// <summary>
/// Selected or hovered icon.
/// </summary>
[Parameter] public Icon IconFull { get; set; } = new CoreIcons.Filled.Size20.Star();
[Parameter]
public Icon IconFull { get; set; } = new CoreIcons.Filled.Size20.Star();

/// <summary>
/// Non-selected item icon.
/// </summary>
[Parameter] public Icon IconEmpty { get; set; } = new CoreIcons.Regular.Size20.Star();
[Parameter]
public Icon IconEmpty { get; set; } = new CoreIcons.Regular.Size20.Star();

/// <summary>
/// Fires when hovered value changes. Value will be null if no rating item is hovered.
/// </summary>
[Parameter] public EventCallback<int?> HoveredValueChanged { get; set; }
[Parameter]
public EventCallback<int?> HoveredValueChanged { get; set; }

private Icon GetIcon(int index) => index <= (_mouseOverValue ?? Value) ? IconFull : IconEmpty;

Expand All @@ -66,7 +71,10 @@ protected override bool TryParseValueFromString(string? value, [MaybeNullWhen(fa

protected internal async Task HandleKeyDownAsync(KeyboardEventArgs keyboardEventArgs)
{
if (Disabled || ReadOnly) { return; }
if (Disabled || ReadOnly)
{
return;
}

var value = keyboardEventArgs.Key switch
{
Expand Down Expand Up @@ -104,7 +112,10 @@ private async Task OnPointerOverAsync(int value)

private async Task OnClickAsync(int value)
{
if (value == Value) { value = 0; }
if (value == Value)
{
value = 0;
}
await SetCurrentValueAsync(value);
}
}