Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FluentProgress] Update Stroke enumeration - v4 & v3 #1125

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h4>Stroke and Color</h4>

<FluentSelect Label="Width" Items="@(new [] { ProgressStrokes.Thin, ProgressStrokes.Normal, ProgressStrokes.Large })" @bind-SelectedOption="@Stroke" Width="60px" />
<FluentSelect Label="Width" Items="@(new [] { Microsoft.FluentUI.AspNetCore.Components.ProgressStroke.Small, Microsoft.FluentUI.AspNetCore.Components.ProgressStroke.Normal, Microsoft.FluentUI.AspNetCore.Components.ProgressStroke.Large })" @bind-SelectedOption="@Stroke" Width="60px" />
<FluentCheckbox Label="Indeterminate" @bind-Value="@Indeterminate" />
<FluentSelect Label="Color" Items="@(Enum.GetValues<OfficeColor>())" @bind-SelectedOption="@Color" Width="100px" Height="200px" />
<FluentSlider Min="0" Max="100" Step="5" @bind-Value="@Percentage" Style="max-width: 200px; margin: 20px 0px;" Disabled="@Indeterminate" />
Expand All @@ -16,7 +16,7 @@

@code
{
ProgressStrokes Stroke = ProgressStrokes.Normal;
ProgressStroke Stroke = Microsoft.FluentUI.AspNetCore.Components.ProgressStroke.Normal;
int Percentage = 30;
bool Indeterminate = false;
OfficeColor Color = OfficeColor.Default;
Expand Down
2 changes: 1 addition & 1 deletion examples/Demo/Shared/Pages/Progress/ProgressPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<DemoSection Title="Default" Component="@typeof(ProgressDefault)"></DemoSection>

<DemoSection Title="Stroke and Color" Component="@typeof(ProgressStroke)"></DemoSection>
<DemoSection Title="Stroke and Color" Component="@typeof(ProgressStrokeExample)"></DemoSection>

<DemoSection Title="Paused" Component="@typeof(ProgressPaused)"></DemoSection>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h4>Stroke and Color</h4>

<FluentSelect Label="Width" Items="@(new [] { ProgressStrokes.Thin, ProgressStrokes.Normal, ProgressStrokes.Large })" @bind-SelectedOption="@Stroke" Width="60px" />
<FluentSelect Label="Width" Items="@(new [] { ProgressStroke.Small, ProgressStroke.Normal, ProgressStroke.Large })" @bind-SelectedOption="@Stroke" Width="60px" />
<FluentCheckbox Label="Indeterminate" @bind-Value="@Indeterminate" />
<FluentSelect Label="Color" Items="@(Enum.GetValues<OfficeColor>())" @bind-SelectedOption="@Color" Width="100px" Height="200px" />
<FluentSlider Min="0" Max="100" Step="5" @bind-Value="@Percentage" Style="max-width: 200px; margin: 20px 0px;" Disabled="@Indeterminate" />
Expand All @@ -26,7 +26,7 @@

@code
{
ProgressStrokes Stroke = ProgressStrokes.Normal;
ProgressStroke Stroke = ProgressStroke.Normal;
int Percentage = 30;
bool Indeterminate = false;
OfficeColor Color = OfficeColor.Default;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Components/Progress/FluentProgress.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@inherits FluentComponentBase
@if (Visible)
{
if (Stroke != ProgressStrokes.Normal || !string.IsNullOrEmpty(Color) || !string.IsNullOrEmpty(BackgroundColor))
if (Stroke != ProgressStroke.Normal || !string.IsNullOrEmpty(Color) || !string.IsNullOrEmpty(BackgroundColor))
{
<style>
@if (Value == null)
Expand Down
8 changes: 4 additions & 4 deletions src/Core/Components/Progress/FluentProgress.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public FluentProgress()
/// Gets or sets the stroke width of the progress bar. If not set, the default theme stroke width is used.
/// </summary>
[Parameter]
public ProgressStrokes Stroke { get; set; } = ProgressStrokes.Normal;
public ProgressStroke Stroke { get; set; } = ProgressStroke.Normal;

/// <summary>
/// Gets or sets the color to be used for the progress bar. If not set, the default theme color is used.
Expand All @@ -79,9 +79,9 @@ public FluentProgress()

private (int BarHeight, int BackgroundHeight, string DefaultBackgroundColor) StrokeDetails => Stroke switch
{
ProgressStrokes.Thin => (2, 1, "--neutral-stroke-strong-rest"),
ProgressStrokes.Normal => (3, 1, "--neutral-stroke-strong-rest"),
ProgressStrokes.Large => (9, 6, "--neutral-stroke-rest"),
ProgressStroke.Small => (2, 1, "--neutral-stroke-strong-rest"),
ProgressStroke.Normal => (3, 1, "--neutral-stroke-strong-rest"),
ProgressStroke.Large => (9, 6, "--neutral-stroke-rest"),
_ => throw new NotImplementedException(),
};
private string StyleProgress => $"height: calc((var(--stroke-width) * {StrokeDetails.BackgroundHeight}) * 1px); " +
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Components/Progress/FluentProgressRing.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@inherits FluentComponentBase
@if (Visible)
{
if (Stroke != ProgressStrokes.Normal || !string.IsNullOrEmpty(Color))
if (Stroke != ProgressStroke.Normal || !string.IsNullOrEmpty(Color))
{
<style>
@($"#{Id}::part(background) {{ {StyleBackground} }}")
Expand Down
8 changes: 4 additions & 4 deletions src/Core/Components/Progress/FluentProgressRing.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public FluentProgressRing()
/// Gets or sets the stroke width of the progress ring. If not set, the default theme stroke width is used.
/// </summary>
[Parameter]
public ProgressStrokes Stroke { get; set; } = ProgressStrokes.Normal;
public ProgressStroke Stroke { get; set; } = ProgressStroke.Normal;

/// <summary>
/// Gets or sets the color to be used for the progress ring. If not set, the default theme color is used.
Expand All @@ -72,9 +72,9 @@ public FluentProgressRing()

private (int Width, int Radius, int Dashoffset) StrokeDetails => Stroke switch
{
ProgressStrokes.Thin => (1, 7, 0),
ProgressStrokes.Normal => (2, 7, 0),
ProgressStrokes.Large => (4, 6, (int)(0.066 * (Value ?? 0) + 0.22)),
ProgressStroke.Small => (1, 7, 0),
ProgressStroke.Normal => (2, 7, 0),
ProgressStroke.Large => (4, 6, (int)(0.066 * (Value ?? 0) + 0.22)),
_ => throw new NotImplementedException(),
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace Microsoft.FluentUI.AspNetCore.Components;

public enum ProgressStrokes
public enum ProgressStroke
{
Small,
Normal,
Thin,
Large,
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
</None>

<None Include="**\*.received.razor.html" />

<None Include="Progress\FluentProgressTests.razor" />
<None Update="**\*.received.razor.html">
<ParentFile>$([System.String]::Copy('%(FileName)').Split('.')[0])</ParentFile>
<DependentUpon>%(ParentFile).razor</DependentUpon>
Expand Down
4 changes: 2 additions & 2 deletions tests/Core/Progress/FluentProgressRingTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
public void FluentProgressRing_Stroke()
{
// Arrange && Act
var cut = Render(@<FluentProgressRing Min="0" Max="100" Value="30" Stroke="ProgressStrokes.Large" />);
var cut = Render(@<FluentProgressRing Min="0" Max="100" Value="30" Stroke="ProgressStroke.Large" />);

// Assert
cut.Verify();
Expand All @@ -68,7 +68,7 @@
public void FluentProgressRing_Stroke_Indeterminate()
{
// Arrange && Act
var cut = Render(@<FluentProgressRing Min="0" Max="100" Stroke="ProgressStrokes.Thin" />);
var cut = Render(@<FluentProgressRing Min="0" Max="100" Stroke="ProgressStroke.Small" />);

// Assert
cut.Verify();
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Progress/FluentProgressTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
public void FluentProgress_Stroke()
{
// Arrange && Act
var cut = Render(@<FluentProgress Min="0" Max="100" Value="30" Stroke="ProgressStrokes.Large" />);
var cut = Render(@<FluentProgress Min="0" Max="100" Value="30" Stroke="ProgressStroke.Large" />);

// Assert
cut.Verify();
Expand Down