Created more components

This commit is contained in:
2026-05-04 18:58:48 +05:00
parent fb1cb8e834
commit 40a7d9018c
52 changed files with 2526 additions and 11 deletions
@@ -0,0 +1,26 @@
namespace Htmx.ApiDemo.Templates.Components;
/// <summary>
/// shadcn-style Progress bar. Value is clamped to 0100.
/// Size: sm (h-2) | default (h-4) | lg (h-6)
/// </summary>
public sealed class Progress : ProgressBase
{
private readonly byte[] _valueNowData;
private readonly byte[] _heightClassData;
public Progress(int value = 0, string size = "default")
{
var clamped = Math.Clamp(value, 0, 100);
_valueNowData = clamped.ToString().ToUtf8Bytes();
_heightClassData = size switch
{
"sm" => "h-2".ToUtf8Bytes(),
"lg" => "h-6".ToUtf8Bytes(),
_ => "h-4".ToUtf8Bytes(),
};
}
protected override void RenderValueNow(HtmxRenderContext ctx) => ctx.Writer.WriteUtf8(_valueNowData);
protected override void RenderHeightClass(HtmxRenderContext ctx) => ctx.Writer.WriteUtf8(_heightClassData);
}