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 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; } + /// /// 获得/设置 时间线颜色 /// 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); + } }