This repository has been archived by the owner on Jan 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
5,914 additions
and
3,916 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
doc/TDesign.Docs.Shared/Pages/Components/TimelinePage.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
@page "/components/timeline" | ||
|
||
<PageHeader Title="Timeline 时间轴"> | ||
用于时间轴展示 | ||
</PageHeader> | ||
|
||
<Example Title="基础时间轴"> | ||
<Description> | ||
使用 <code>TimelineItem</code> 作为子项。 | ||
</Description> | ||
<RunContent> | ||
<TTimeline> | ||
<TTimelineItem Label="2022-10-1">事件1</TTimelineItem> | ||
<TTimelineItem Label="2022-10-11">事件2</TTimelineItem> | ||
<TTimelineItem Label="2022-10-21">事件3</TTimelineItem> | ||
</TTimeline> | ||
<br /> | ||
<TTimeline Horizontal> | ||
<TTimelineItem Label="2022-10-1">事件1</TTimelineItem> | ||
<TTimelineItem Label="2022-10-11">事件2</TTimelineItem> | ||
<TTimelineItem Label="2022-10-21">事件3</TTimelineItem> | ||
</TTimeline> | ||
</RunContent> | ||
<CodeContent> | ||
@Code.Create(@" | ||
```html | ||
<TTimeline> | ||
<TTimelineItem Label=""2022-10-1"">事件1</TTimelineItem> | ||
<TTimelineItem Label=""2022-10-11"">事件2</TTimelineItem> | ||
<TTimelineItem Label=""2022-10-21"">事件3</TTimelineItem> | ||
</TTimeline> | ||
|
||
<TTimeline Horizontal> | ||
<TTimelineItem Label=""2022-10-1"">事件1</TTimelineItem> | ||
<TTimelineItem Label=""2022-10-11"">事件2</TTimelineItem> | ||
<TTimelineItem Label=""2022-10-21"">事件3</TTimelineItem> | ||
</TTimeline> | ||
``` | ||
") | ||
</CodeContent> | ||
</Example> | ||
<Example Title="点状时间轴"> | ||
<Description></Description> | ||
<RunContent> | ||
<TTimeline Theme="TimelineTheme.Dot"> | ||
<TTimelineItem Label="2022-10-1">事件1</TTimelineItem> | ||
<TTimelineItem Label="2022-10-11">事件2</TTimelineItem> | ||
<TTimelineItem Label="2022-10-21">事件3</TTimelineItem> | ||
</TTimeline> | ||
<br /> | ||
<TTimeline Horizontal Theme="TimelineTheme.Dot"> | ||
<TTimelineItem Label="2022-10-1">事件1</TTimelineItem> | ||
<TTimelineItem Label="2022-10-11">事件2</TTimelineItem> | ||
<TTimelineItem Label="2022-10-21">事件3</TTimelineItem> | ||
</TTimeline> | ||
</RunContent> | ||
<CodeContent> | ||
@Code.Create(@" | ||
```html | ||
<TTimeline Theme=""TimelineTheme.Dot""> | ||
<TTimelineItem Label=""2022-10-1"">事件1</TTimelineItem> | ||
<TTimelineItem Label=""2022-10-11"">事件2</TTimelineItem> | ||
<TTimelineItem Label=""2022-10-21"">事件3</TTimelineItem> | ||
</TTimeline> | ||
|
||
<TTimeline Horizontal Theme=""TimelineTheme.Dot""> | ||
<TTimelineItem Label=""2022-10-1"">事件1</TTimelineItem> | ||
<TTimelineItem Label=""2022-10-11"">事件2</TTimelineItem> | ||
<TTimelineItem Label=""2022-10-21"">事件3</TTimelineItem> | ||
</TTimeline> | ||
``` | ||
") | ||
</CodeContent> | ||
</Example> | ||
<Example Title="自定义节点图标"> | ||
<Description></Description> | ||
<RunContent> | ||
<TTimeline> | ||
<TTimelineItem IconName="IconName.Pin" Label="2022-10-1">事件1</TTimelineItem> | ||
<TTimelineItem IconName="IconName.Heart"Label="2022-10-11">事件2</TTimelineItem> | ||
<TTimelineItem IconName="IconName.User" Label="2022-10-21">事件3</TTimelineItem> | ||
</TTimeline> | ||
<br /> | ||
<TTimeline Horizontal> | ||
<TTimelineItem IconName="IconName.Pin" Label="2022-10-1">事件1</TTimelineItem> | ||
<TTimelineItem IconName="IconName.Heart" Label="2022-10-11">事件2</TTimelineItem> | ||
<TTimelineItem IconName="IconName.User" Label="2022-10-21">事件3</TTimelineItem> | ||
</TTimeline> | ||
</RunContent> | ||
<CodeContent> | ||
@Code.Create(@" | ||
```html | ||
<TTimeline> | ||
<TTimelineItem IconName=""IconName.Pin"" Label=""2022-10-1"">事件1</TTimelineItem> | ||
<TTimelineItem IconName=""IconName.Heart""Label=""2022-10-11"">事件2</TTimelineItem> | ||
<TTimelineItem IconName=""IconName.User"" Label=""2022-10-21"">事件3</TTimelineItem> | ||
</TTimeline> | ||
<br /> | ||
<TTimeline Horizontal> | ||
<TTimelineItem IconName=""IconName.Pin"" Label=""2022-10-1"">事件1</TTimelineItem> | ||
<TTimelineItem IconName=""IconName.Heart"" Label=""2022-10-11"">事件2</TTimelineItem> | ||
<TTimelineItem IconName=""IconName.User"" Label=""2022-10-21"">事件3</TTimelineItem> | ||
</TTimeline> | ||
``` | ||
") | ||
</CodeContent> | ||
</Example> | ||
|
||
<Example Title="主题色"> | ||
<Description></Description> | ||
<RunContent> | ||
<TTimeline> | ||
<TTimelineItem Label="2022-10-1" Color="Color.Primary">事件1</TTimelineItem> | ||
<TTimelineItem Label="2022-10-11" Color="Color.Warning">事件2</TTimelineItem> | ||
<TTimelineItem Label="2022-10-21" Color="Color.Success">事件3</TTimelineItem> | ||
<TTimelineItem Label="2022-10-21" Color="Color.Error">事件4</TTimelineItem> | ||
</TTimeline> | ||
<br /> | ||
<TTimeline Horizontal> | ||
<TTimelineItem Label="2022-10-1" Color="Color.Primary">事件1</TTimelineItem> | ||
<TTimelineItem Label="2022-10-11" Color="Color.Warning">事件2</TTimelineItem> | ||
<TTimelineItem Label="2022-10-21" Color="Color.Success">事件3</TTimelineItem> | ||
<TTimelineItem Label="2022-10-21" Color="Color.Error">事件4</TTimelineItem> | ||
</TTimeline> | ||
</RunContent> | ||
<CodeContent> | ||
@Code.Create(@" | ||
```html | ||
<TTimeline> | ||
<TTimelineItem Label=""2022-10-1"" Color=""Color.Primary"">事件1</TTimelineItem> | ||
<TTimelineItem Label=""2022-10-11"" Color=""Color.Warning"">事件2</TTimelineItem> | ||
<TTimelineItem Label=""2022-10-21"" Color=""Color.Success"">事件3</TTimelineItem> | ||
<TTimelineItem Label=""2022-10-21"" Color=""Color.Error"">事件4</TTimelineItem> | ||
</TTimeline> | ||
|
||
<TTimeline Horizontal> | ||
<TTimelineItem Label=""2022-10-1"" Color=""Color.Primary"">事件1</TTimelineItem> | ||
<TTimelineItem Label=""2022-10-11"" Color=""Color.Warning"">事件2</TTimelineItem> | ||
<TTimelineItem Label=""2022-10-21"" Color=""Color.Success"">事件3</TTimelineItem> | ||
<TTimelineItem Label=""2022-10-21"" Color=""Color.Error"">事件4</TTimelineItem> | ||
</TTimeline> | ||
``` | ||
") | ||
</CodeContent> | ||
</Example> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"tdesign-vue": "^0.46.1" | ||
"tdesign-vue": "^0.50.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using ComponentBuilder; | ||
|
||
namespace TDesign.Test.Components; | ||
public class TimelineTest : TestBase<TTimeline> | ||
{ | ||
[Fact(DisplayName = "Timeline - 渲染")] | ||
public void Test_Render() | ||
{ | ||
var component = GetComponent(m => m.AddChildContent(builder => | ||
{ | ||
builder.CreateComponent<TTimelineItem>(0, "事件一", new { Label = "2022-01-01" }); | ||
})); | ||
|
||
component.Should().HaveTag("ul").And.HaveClass("t-timeline").And.HaveClass("t-timeline-left").And.HaveClass("t-timeline-vertical") | ||
.And.HaveClass("t-timeline-label--same").And.HaveClass("t-timeline-label"); | ||
|
||
|
||
var item = component.FindComponent<TTimelineItem>(); | ||
|
||
item.Should().NotBeNull().And.HaveTag("li").And.HaveClass("t-timeline-item").And.HaveClass("t-timeline-item-left"); | ||
|
||
var wrapper = item.Find(".t-timeline-item__wrapper"); | ||
wrapper.Should().NotBeNull().And.HaveTag("div"); | ||
|
||
var dot = wrapper.Children[0]; | ||
dot.Should().NotBeNull().And.HaveClass("t-timeline-item__dot").And.HaveClass("t-timeline-item__dot--primary"); | ||
|
||
NotEmpty(dot.Children); | ||
|
||
dot.Children[0].Should().NotBeNull().And.HaveClass("t-timeline-item__dot-content"); | ||
|
||
var tail = wrapper.LastElementChild; | ||
tail.Should().NotBeNull().And.HaveClass("t-timeline-item__tail").And.HaveClass("t-timeline-item__tail--theme-default") | ||
.And.HaveClass("t-timeline-item__tail--status-primary"); | ||
|
||
|
||
var content = item.Find(".t-timeline-item__content"); | ||
content.Should().NotBeNull(); | ||
|
||
content.FirstElementChild.Should().NotBeNull().And.HaveClass("t-timeline-item__label").And.HaveClass("t-timeline-item__label--same") | ||
; | ||
|
||
|
||
|
||
|
||
component.MarkupMatches(@" | ||
<ul class=""t-timeline t-timeline-left t-timeline-vertical t-timeline-label--same t-timeline-label""> | ||
<li class=""t-timeline-item t-timeline-item-left ""> | ||
<div class=""t-timeline-item__wrapper""> | ||
<div class=""t-timeline-item__dot t-timeline-item__dot--primary""> | ||
<div class=""t-timeline-item__dot-content""></div> | ||
</div> | ||
<div class=""t-timeline-item__tail t-timeline-item__tail--theme-default t-timeline-item__tail--status-primary""> | ||
</div> | ||
</div> | ||
<div class=""t-timeline-item__content""> | ||
事件一 | ||
<div class=""t-timeline-item__label t-timeline-item__label--same"">2022-01-01</div> | ||
</div> | ||
</li> | ||
</ul> | ||
"); | ||
|
||
|
||
} | ||
|
||
[Fact(DisplayName = "Timeline - 基础时间轴 - 垂直")] | ||
public void Test_Basic_Timeline_Vertical() | ||
{ | ||
GetComponent().Should().HaveClass("t-timeline-vertical"); | ||
} | ||
|
||
[Fact(DisplayName = "Timeline - 基础时间轴 - 水平")] | ||
public void Test_Basic_Timeline_Horizontal() | ||
{ | ||
GetComponent(m => m.Add(p => p.Horizontal, true)).Should().HaveClass("t-timeline-horizontal"); | ||
} | ||
|
||
[Theory(DisplayName = "Timeline - 不同的颜色 Color")] | ||
[InlineData(new object[] { Color.Primary })] | ||
[InlineData(new object[] { Color.Success })] | ||
[InlineData(new object[] { Color.Warning })] | ||
[InlineData(new object[] { Color.Error })] | ||
public void Test_Timeline_With_Different_Color(Color color) | ||
{ | ||
var item = GetComponent(m => m.AddChildContent(builder => | ||
{ | ||
builder.CreateComponent<TTimelineItem>(0, attributes: new { Color = color }); | ||
})).FindComponent<TTimelineItem>().Find(".t-timeline-item__dot"); | ||
|
||
|
||
item.Should().HaveClass($"t-timeline-item__dot--{color.ToString().ToLower()}"); | ||
} | ||
} |
Oops, something went wrong.