From ed0cedaa0226a8210986debac735ade7704df2fe Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 10 Jan 2025 15:23:15 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20DescriptionTem?= =?UTF-8?q?plate=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Timeline/Timeline.razor | 9 ++++++++- src/BootstrapBlazor/Components/Timeline/TimelineItem.cs | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor/Components/Timeline/Timeline.razor b/src/BootstrapBlazor/Components/Timeline/Timeline.razor index 9ab92aacfd5..22d21c54555 100644 --- a/src/BootstrapBlazor/Components/Timeline/Timeline.razor +++ b/src/BootstrapBlazor/Components/Timeline/Timeline.razor @@ -24,7 +24,14 @@ @item.Component.Render() }
- @item.Description + @if(item.DescriptionTemplate != null) + { + @item.DescriptionTemplate + } + else + { + @item.Description + }
diff --git a/src/BootstrapBlazor/Components/Timeline/TimelineItem.cs b/src/BootstrapBlazor/Components/Timeline/TimelineItem.cs index ee392bbe71b..c6ca35a6e91 100644 --- a/src/BootstrapBlazor/Components/Timeline/TimelineItem.cs +++ b/src/BootstrapBlazor/Components/Timeline/TimelineItem.cs @@ -16,10 +16,15 @@ public class TimelineItem public string? Content { get; set; } /// - /// 获得/设置 时间线时间 + /// 获得/设置 时间线描述 /// public string? Description { get; set; } + /// + /// 获得/设置 时间线描述模板 + /// + public RenderFragment? DescriptionTemplate { get; set; } + /// /// 获得/设置 时间线颜色 /// From 8e70490508a5dc09cc186827601edfa7cd64b57d Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 10 Jan 2025 15:23:28 +0800 Subject: [PATCH 2/3] chore: bump version 9.2.7-beta04 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 8ac671bda8d..0c05999a6fb 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 9.2.7-beta03 + 9.2.7-beta04 From 69d51fe55f20785a2822ab23266a1d133b4a6978 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 10 Jan 2025 15:23:36 +0800 Subject: [PATCH 3/3] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/TimelineTest.cs | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/UnitTest/Components/TimelineTest.cs b/test/UnitTest/Components/TimelineTest.cs index 804a4b6ce42..ad381a8b600 100644 --- a/test/UnitTest/Components/TimelineTest.cs +++ b/test/UnitTest/Components/TimelineTest.cs @@ -62,4 +62,31 @@ public void Items_Ok() Assert.Contains("card-body", html); Assert.Matches("bg-dark(.*?)text-danger", html.Replace("\r", "").Replace("\n", "")); } + + [Fact] + public void ItemDescriptionTemplate_Ok() + { + var items = new List() + { + new() + { + Color = Color.Danger, Content = "first item", Icon = "fa-solid fa-house", DescriptionTemplate = pb => + { + pb.OpenElement(0, "div"); + pb.AddContent(1, "first description template"); + pb.CloseElement(); + } + }, + new() + { + Color = Color.None, Content = "no color item", Description = "first description", Icon = "fa-solid fa-house" + } + }; + + var cut = Context.RenderComponent(pb => + { + pb.Add(x => x.Items, items); + }); + Assert.Contains("first description template", cut.Markup); + } }