From 84231bb485dd7a7c5cd6f7536532bd88a8c1995d Mon Sep 17 00:00:00 2001 From: Taylor Date: Thu, 9 Oct 2025 02:48:36 -0400 Subject: [PATCH] Upgrade to .NET 9 and support Blazor auto mode --- README.md | 6 +++++- .../TailBlazor.ProgressBar.csproj | 19 +++++++++---------- .../TailBlazorProgressBar.razor | 4 ++-- .../TailBlazorProgressBar.razor.cs | 11 +++++------ 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 4b55e8e..5224065 100644 --- a/README.md +++ b/README.md @@ -54,4 +54,8 @@ Using animation-pulse on the `class` parameter brings the bar into focus for the ### 4. Adjusting progress -Pass an int from 0-100 into the `Percentage` parameter to have it automatically update it's position. Adjust this percentage on the fly to have it update in real time. \ No newline at end of file +Pass an int from 0-100 into the `Percentage` parameter to have it automatically update it's position. Adjust this percentage on the fly to have it update in real time. + +### 5. Blazor auto render mode support + +The component library now targets .NET 9 and ships as a Razor class library, so it can be referenced from Blazor applications running in Auto render mode without any additional configuration. When the `Percentage` value changes on the server or in the browser, the component automatically clamps the value between 0 and 100 and re-renders correctly in both interactive server and WebAssembly contexts. diff --git a/src/TailBlazor.ProgressBar/TailBlazor.ProgressBar.csproj b/src/TailBlazor.ProgressBar/TailBlazor.ProgressBar.csproj index c933d93..8e3ef8a 100644 --- a/src/TailBlazor.ProgressBar/TailBlazor.ProgressBar.csproj +++ b/src/TailBlazor.ProgressBar/TailBlazor.ProgressBar.csproj @@ -1,6 +1,8 @@ - - - net5.0 + + + net9.0 + enable + enable TailBlazor.ProgressBar TailBlazor.ProgressBar 1.0.2 @@ -23,13 +25,10 @@ MIT - - - - - - - + + + + diff --git a/src/TailBlazor.ProgressBar/TailBlazorProgressBar.razor b/src/TailBlazor.ProgressBar/TailBlazorProgressBar.razor index 186c7d5..35805dc 100644 --- a/src/TailBlazor.ProgressBar/TailBlazorProgressBar.razor +++ b/src/TailBlazor.ProgressBar/TailBlazorProgressBar.razor @@ -1,5 +1,5 @@ @namespace TailBlazor.ProgressBar -
- +
+
diff --git a/src/TailBlazor.ProgressBar/TailBlazorProgressBar.razor.cs b/src/TailBlazor.ProgressBar/TailBlazorProgressBar.razor.cs index c40adc4..00a03e3 100644 --- a/src/TailBlazor.ProgressBar/TailBlazorProgressBar.razor.cs +++ b/src/TailBlazor.ProgressBar/TailBlazorProgressBar.razor.cs @@ -1,21 +1,20 @@ using System; -using System.Collections.Generic; using Microsoft.AspNetCore.Components; namespace TailBlazor.ProgressBar { public partial class TailBlazorProgressBar { - [Parameter] public string Class { get; set; } = "rounded bg-gradient-to-br animate-pulse from-purple-500 to-red-600"; + [Parameter] public string? Class { get; set; } = "rounded bg-gradient-to-br animate-pulse from-purple-500 to-red-600"; [Parameter] public int Percentage { get; set; } = 50; [Parameter] public int Height { get; set; } = 2; - [Parameter] public string BackgroundClass { get; set; } = "bg-gray-100 rounded"; + [Parameter] public string? BackgroundClass { get; set; } = "bg-gray-100 rounded"; private int _percentage = 50; - protected override void OnInitialized() { - _percentage = Percentage > 100 ? 100 : Percentage < 0 ? 0 : Percentage; - StateHasChanged(); + protected override void OnParametersSet() + { + _percentage = Math.Clamp(Percentage, 0, 100); } } }