Skip to content

Commit 37db88a

Browse files
feat(DateTimePicker): add Color parameter (#6342)
* feat(DateTimePicker):DateTimePicker增加Color样式属性 DateTimePicker增加Color样式属性,默认Color.None * test: 增加单元测试 --------- Co-authored-by: Argo Zhang <[email protected]>
1 parent 889410f commit 37db88a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public partial class DateTimePicker<TValue>
2727
/// </summary>
2828
private string? InputClassName => CssBuilder.Default("dropdown-toggle form-control datetime-picker-input")
2929
.AddClass("has-icon", ShowIcon)
30+
.AddClass($"border-{Color.ToDescriptionString()}", Color != Color.None && !IsDisabled && !IsValid.HasValue)
3031
.AddClass(ValidCss)
3132
.Build();
3233

@@ -105,6 +106,12 @@ public string? Format
105106
[Parameter]
106107
public bool ShowIcon { get; set; } = true;
107108

109+
/// <summary>
110+
/// 获得/设置 控件边框颜色样式 默认为 None 显示
111+
/// </summary>
112+
[Parameter]
113+
public Color Color { get; set; } = Color.None;
114+
108115
/// <summary>
109116
/// 获得/设置 组件显示模式 默认为显示年月日模式
110117
/// </summary>

test/UnitTest/Components/DateTimePickerTest.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ namespace UnitTest.Components;
1010
public class DateTimePickerTest : BootstrapBlazorTestBase
1111
{
1212
#region DateTimePicker
13+
[Fact]
14+
public void Color_Ok()
15+
{
16+
var cut = Context.RenderComponent<DateTimePicker<DateTime>>(pb =>
17+
{
18+
pb.Add(a => a.AutoToday, true);
19+
pb.Add(a => a.Value, DateTime.MinValue);
20+
pb.Add(a => a.Color, Color.Primary);
21+
});
22+
cut.Contains("border-primary");
23+
}
24+
1325
[Fact]
1426
public void AutoToday_DateTime()
1527
{

0 commit comments

Comments
 (0)