Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
release: 发布 0.6.2 版本 (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
teacher-zhou authored Jun 20, 2023
2 parents 7e93f18 + ad3bdf5 commit 4ce80cf
Show file tree
Hide file tree
Showing 13 changed files with 710 additions and 206 deletions.
8 changes: 5 additions & 3 deletions Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@
**如果你还没有成为贡献者,需要通过联系方式通知仓库所有者将你添加到贡献者名单中**

项目采用采用 `dev/main` 的形式进行分支开发
项目采用采用【分支开发,主干发布】的模式进行开发

- `dev/version`:作为正在开发的版本
- `main`:最新的稳定版本,并且历史版本将用 `tag` 作为标记
- `release/version`:作为发布后的稳定版本

分支开发时,以 issue 号作为命名:
- `feature/{任务号}`:新功能
- `bugfix/{任务号}`:修复的bug
- `hotfix/{任务号}`:紧急修复的问题

> 没有 Issue 号的,请使用合适的分支名称,参照动宾短语的语法

**分支开发流程**
1. 拉取指定分支获取最新代码
Expand Down Expand Up @@ -110,7 +112,7 @@
## 组件开发规范
* 组件名称要以 **“T”** 字母作为开头,例如 `TButton``TTable``TTab``TInputText` 等,以最大限度避免与其他组件的命名出现冲突(项目中可能会有多个组件框架出现)
> 如何判断是组件类?组件类必须继承 `TDesignComponentBase` 以及会以 `TDesignComponentBase` 结尾的组件基类
> 如何判断是组件类?组件类必须继承 `TDesignComponentBase` 或以 `TDesign...ComponentBase` 命名的组件基类
* 可输入组件要以 `Input` 开头,例如 `TInputText``TInputCheckBox`
* 分组或容器组件以 `Group``Container` 作为后缀命名,如 `TAvatarGroup``TInputGroup`
* 组件的参数名称,不用与官方保持一致,命名规范参照开发语言规范即可
Expand Down
18 changes: 13 additions & 5 deletions doc/TDesign.Docs.ServerSide/TDesign.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

265 changes: 217 additions & 48 deletions doc/TDesign.Docs.Shared/Pages/Components/Basic/ButtonPage.razor

Large diffs are not rendered by default.

18 changes: 13 additions & 5 deletions doc/TDesign.Docs.WebAssembly/wwwroot/TDesign.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dependencies": {
"tdesign-vue": "^1.0.8"
"tdesign-vue": "^1.4.0"
}
}
67 changes: 42 additions & 25 deletions src/TDesign.Test/Components/Basic/ButtonTest.cs
Original file line number Diff line number Diff line change
@@ -1,86 +1,103 @@
namespace TDesign.Test.Components.Basic;
using ComponentBuilder.FluentRenderTree;

public class ButtonTest : TestBase
namespace TDesign.Test.Components.Basic;
public class ButtonTest : TestBase<TButton>
{
[Fact(DisplayName = "按钮 - 渲染 button 元素标记")]
public void Test_Render_Button_Tag()
{
TestContext.RenderComponent<TButton>().Should().HaveTag("button");
RenderComponent().Should().HaveTag("button");
}

[Fact(DisplayName = "按钮 - Theme 参数 ")]
public void Test_Theme_Parameter()
{
TestContext.RenderComponent<TButton>(m => m.Add(p => p.Theme, Theme.Primary)).Should().HaveClass("t-button--theme-primary");
RenderComponent(m => m.Add(p => p.Theme, Theme.Primary)).Should().HaveClass("t-button--theme-primary");

TestContext.RenderComponent<TButton>(m => m.Add(p => p.Theme, Theme.Success)).Should().HaveClass("t-button--theme-success");
RenderComponent(m => m.Add(p => p.Theme, Theme.Success)).Should().HaveClass("t-button--theme-success");

TestContext.RenderComponent<TButton>(m => m.Add(p => p.Theme, Theme.Danger)).Should().HaveClass("t-button--theme-danger");
RenderComponent(m => m.Add(p => p.Theme, Theme.Danger)).Should().HaveClass("t-button--theme-danger");

TestContext.RenderComponent<TButton>(m => m.Add(p => p.Theme, Theme.Warning)).Should().HaveClass("t-button--theme-warning");
RenderComponent(m => m.Add(p => p.Theme, Theme.Warning)).Should().HaveClass("t-button--theme-warning");
}

[Fact(DisplayName = "按钮 - HtmlType 参数渲染 HTML 的 type 属性")]
public void Test_HtmlType_Parameter()
{
TestContext.RenderComponent<TButton>(m => m.Add(p => p.HtmlType, ButtonHtmlType.Button)).Should().HaveAttribute("type", "button");
RenderComponent(m => m.Add(p => p.HtmlType, ButtonHtmlType.Button)).Should().HaveAttribute("type", "button");

TestContext.RenderComponent<TButton>(m => m.Add(p => p.HtmlType, ButtonHtmlType.Submit)).Should().HaveAttribute("type", "submit");
RenderComponent(m => m.Add(p => p.HtmlType, ButtonHtmlType.Submit)).Should().HaveAttribute("type", "submit");

TestContext.RenderComponent<TButton>(m => m.Add(p => p.HtmlType, ButtonHtmlType.Reset)).Should().HaveAttribute("type", "reset");
RenderComponent(m => m.Add(p => p.HtmlType, ButtonHtmlType.Reset)).Should().HaveAttribute("type", "reset");
}

[Fact(DisplayName = "按钮 - Varient 参数")]
public void Test_Type_Parameter()
{
TestContext.RenderComponent<TButton>(m => m.Add(p => p.Varient, ButtonVarient.Dashed)).Should().HaveClass("t-button--variant-dashed");
RenderComponent(m => m.Add(p => p.Varient, ButtonVarient.Dashed)).Should().HaveClass("t-button--variant-dashed");

TestContext.RenderComponent<TButton>(m => m.Add(p => p.Varient, ButtonVarient.Base)).Should().HaveClass("t-button--variant-base");
RenderComponent(m => m.Add(p => p.Varient, ButtonVarient.Base)).Should().HaveClass("t-button--variant-base");

TestContext.RenderComponent<TButton>(m => m.Add(p => p.Varient, ButtonVarient.Outline)).Should().HaveClass("t-button--variant-outline");
RenderComponent(m => m.Add(p => p.Varient, ButtonVarient.Outline)).Should().HaveClass("t-button--variant-outline");

TestContext.RenderComponent<TButton>(m => m.Add(p => p.Varient, ButtonVarient.Text)).Should().HaveClass("t-button--variant-text");
RenderComponent(m => m.Add(p => p.Varient, ButtonVarient.Text)).Should().HaveClass("t-button--variant-text");
}

[Fact(DisplayName = "按钮 - Ghost 参数")]
public void Test_Ghost_Parameter()
{
TestContext.RenderComponent<TButton>(m => m.Add(p => p.Ghost, true)).Should().HaveClass("t-button--ghost");
RenderComponent(m => m.Add(p => p.Ghost, true)).Should().HaveClass("t-button--ghost");
}

[Fact(DisplayName = "按钮 - Size 参数")]
public void Test_Size_Parameter()
{
TestContext.RenderComponent<TButton>(m => m.Add(p => p.Size, Size.Small)).Should().HaveClass("t-size-s");
TestContext.RenderComponent<TButton>(m => m.Add(p => p.Size, Size.Medium)).Should().HaveClass("t-size-m");
TestContext.RenderComponent<TButton>(m => m.Add(p => p.Size, Size.Large)).Should().HaveClass("t-size-l");
RenderComponent(m => m.Add(p => p.Size, Size.Small)).Should().HaveClass("t-size-s");
RenderComponent(m => m.Add(p => p.Size, Size.Medium)).Should().HaveClass("t-size-m");
RenderComponent(m => m.Add(p => p.Size, Size.Large)).Should().HaveClass("t-size-l");
}

[Fact(DisplayName = "按钮 - Block 参数")]
public void Test_Block_Parameter()
{
TestContext.RenderComponent<TButton>(m => m.Add(p => p.Block, true)).Should().HaveClass("t-size-full-width");
RenderComponent(m => m.Add(p => p.Block, true)).Should().HaveClass("t-size-full-width");
}

[Fact(DisplayName = "按钮 - Shape 参数")]
public void Test_Shape_Parameter()
{
TestContext.RenderComponent<TButton>(m => m.Add(p => p.Shape, ButtonShape.Rectangle)).Should().HaveClass("t-button--shape-rectangle");
TestContext.RenderComponent<TButton>(m => m.Add(p => p.Shape, ButtonShape.Square)).Should().HaveClass("t-button--shape-square");
TestContext.RenderComponent<TButton>(m => m.Add(p => p.Shape, ButtonShape.Circle)).Should().HaveClass("t-button--shape-circle");
TestContext.RenderComponent<TButton>(m => m.Add(p => p.Shape, ButtonShape.Round)).Should().HaveClass("t-button--shape-round");
RenderComponent(m => m.Add(p => p.Shape, ButtonShape.Rectangle)).Should().HaveClass("t-button--shape-rectangle");
RenderComponent(m => m.Add(p => p.Shape, ButtonShape.Square)).Should().HaveClass("t-button--shape-square");
RenderComponent(m => m.Add(p => p.Shape, ButtonShape.Circle)).Should().HaveClass("t-button--shape-circle");
RenderComponent(m => m.Add(p => p.Shape, ButtonShape.Round)).Should().HaveClass("t-button--shape-round");
}

[Fact(DisplayName = "按钮 - Disabled 参数")]
public void Test_Disabled_Parameter()
{
TestContext.RenderComponent<TButton>(m => m.Add(p => p.Disabled, true)).Should().HaveClass("t-is-disabled").And.HaveAttribute("disabled","disabled");
RenderComponent(m => m.Add(p => p.Disabled, true)).Should().HaveClass("t-is-disabled").And.HaveAttribute("disabled","disabled");
}


[Fact(DisplayName = "按钮 - Loading 参数")]
public void Test_Loading_Parameter()
{
TestContext.RenderComponent<TButton>(m => m.Add(p => p.Loading, true)).Should().HaveClass("t-is-loading");
RenderComponent(m => m.Add(p => p.Loading, true)).Should().HaveClass("t-is-loading");
}

[Fact(DisplayName ="按钮 - 有图标和文字一起适配")]
public void Test_Icon_With_Text()
{
var button= RenderComponent(m => m.Add(p => p.Icon, IconName.Add));
button.FindComponent<TIcon>().MarkupMatches(b => b.Component<TIcon>().Attribute(m => m.Name, IconName.Add).Close());
}

[Theory(DisplayName ="按钮 - 不同的 HTML 标记渲染按钮")]
[InlineData(new object[] { "div"})]
[InlineData(new object[] { "a" })]
[InlineData(new object[] { "span" })]
public void Test_Button_With_TagName(string tag)
{
RenderComponent(m => m.Add(p => p.TagName, tag)).Should().HaveTag(tag);
}
}
26 changes: 16 additions & 10 deletions src/TDesign/Components/TButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@ namespace TDesign;
/// <summary>
/// 表示用于开启一个闭环的操作任务的按钮。
/// </summary>
[HtmlTag("button")]
[CssClass("t-button")]
public class TButton : TDesignComponentBase, IHasChildContent
public class TButton : TDesignAdditionParameterWithChildContentComponentBase
{
/// <summary>
/// <inheritdoc/>
/// </summary>
[Parameter][HtmlAttribute("onclick")] public EventCallback<MouseEventArgs?> OnClick { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
[Parameter] public RenderFragment? ChildContent { get; set; }

/// <summary>
/// 设置按钮的 HTML 类型。默认时 <see cref="ButtonHtmlType.Button"/> 类型。
Expand Down Expand Up @@ -57,17 +52,28 @@ public class TButton : TDesignComponentBase, IHasChildContent
/// </summary>
[Parameter][CssClass("t-is-loading")] public bool Loading { get; set; }

/// <summary>
/// 设置按钮风格的 HTML 元素名称。默认是 button。
/// </summary>
[Parameter] public string? TagName { get; set; } = "button";

/// <summary>
/// 图标的名称。
/// </summary>
[Parameter]public object? Icon { get; set; }

/// <inheritdoc/>
public override string GetTagName() => TagName;

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="builder"></param>
/// <param name="sequence"></param>
protected override void AddContent(RenderTreeBuilder builder, int sequence)
{
builder.CreateElement(sequence, "span", content =>
{
base.AddContent(content, sequence);
}, new { @class = "t-button__text" });
builder.Component<TIcon>(Icon is not null).Attribute(m => m.Name, Icon).Close();
builder.Span("t-button__text",ChildContent is not null).Content(ChildContent).Close();
}
}

Expand Down
Loading

0 comments on commit 4ce80cf

Please sign in to comment.