Skip to content
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
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.2.7-beta03</Version>
<Version>9.2.7-beta04</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 8 additions & 1 deletion src/BootstrapBlazor/Components/Timeline/Timeline.razor
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@
@item.Component.Render()
}
<div class="timeline-item-timestamp">
@item.Description
@if(item.DescriptionTemplate != null)
{
@item.DescriptionTemplate
}
else
{
@item.Description
}
</div>
</div>
</li>
Expand Down
7 changes: 6 additions & 1 deletion src/BootstrapBlazor/Components/Timeline/TimelineItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ public class TimelineItem
public string? Content { get; set; }

/// <summary>
/// 获得/设置 时间线时间
/// 获得/设置 时间线描述
/// </summary>
public string? Description { get; set; }

/// <summary>
/// 获得/设置 时间线描述模板
/// </summary>
public RenderFragment? DescriptionTemplate { get; set; }

/// <summary>
/// 获得/设置 时间线颜色
/// </summary>
Expand Down
27 changes: 27 additions & 0 deletions test/UnitTest/Components/TimelineTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TimelineItem>()
{
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<Timeline>(pb =>
{
pb.Add(x => x.Items, items);
});
Assert.Contains("first description template", cut.Markup);
}
}
Loading