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
8 changes: 8 additions & 0 deletions src/BootstrapBlazor.Server/Components/Samples/Cards.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ private AttributeItem[] GetAttributes() =>
DefaultValue = " — "
},
new()
{
Name = nameof(Card.HeaderPaddingY),
Description = Localizer["HeaderPaddingY"],
Type = "string?",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "Color",
Description = Localizer["Color"],
Expand Down
3 changes: 2 additions & 1 deletion src/BootstrapBlazor.Server/Locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -3803,7 +3803,8 @@
"CollapsibleTitle": "Collapsible",
"CollapsibleHeaderTemplate": "Header Template",
"CollapsibleBody": "Click card hader for collapse/expand card body",
"ShadowBody": "Shadow effect sample"
"ShadowBody": "Shadow effect sample",
"HeaderPaddingY": "Header top and bottom padding"
},
"BootstrapBlazor.Server.Components.Samples.Calendars": {
"Title": "Calendar",
Expand Down
3 changes: 2 additions & 1 deletion src/BootstrapBlazor.Server/Locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -3803,7 +3803,8 @@
"CollapsibleTitle": "可以收缩展开的卡片",
"CollapsibleBody": "点击 Header 收缩/展开",
"CollapsibleHeaderTemplate": "这里是模板",
"ShadowBody": "阴影特效示例"
"ShadowBody": "阴影特效示例",
"HeaderPaddingY": "Header 上下内边距"
},
"BootstrapBlazor.Server.Components.Samples.Calendars": {
"Title": "Calendar 日历框",
Expand Down
4 changes: 2 additions & 2 deletions src/BootstrapBlazor/Components/Card/Card.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@inherits BootstrapModuleComponentBase
@attribute [BootstrapModuleAutoLoader(JSObjectReference = true)]

<div @attributes="@AdditionalAttributes" class="@ClassString" id="@Id">
<div @attributes="@AdditionalAttributes" id="@Id" class="@ClassString" style="@HeaderStyleString">
@if (HeaderTemplate != null || !string.IsNullOrEmpty(HeaderText))
{
<div class="card-header">
Expand Down Expand Up @@ -33,7 +33,7 @@
}
</div>
}
<div class="@BodyClassName" id="@BodyId">
<div id="@BodyId" class="@BodyClassName">
@if (IsCollapsible)
{
<div class="card-body-wrapper">
Expand Down
11 changes: 11 additions & 0 deletions src/BootstrapBlazor/Components/Card/Card.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ public partial class Card
.AddClass("text-muted", IsCenter)
.Build();

/// <summary>
/// 获得/设置 Card Header 高度 padding Y轴值 默认 null
/// <para>单位需自行给定 如 0.25rem</para>
/// </summary>
[Parameter]
public string? HeaderPaddingY { get; set; }

/// <summary>
/// 获得/设置 收缩展开箭头图标 默认 fa-solid fa-circle-chevron-right
/// </summary>
Expand Down Expand Up @@ -119,6 +126,10 @@ public partial class Card
[NotNull]
private IIconTheme? IconTheme { get; set; }

private string? HeaderStyleString => CssBuilder.Default()
.AddStyle("--bs-card-cap-padding-y", HeaderPaddingY)
.Build();
Comment thread
ArgoZhang marked this conversation as resolved.

/// <summary>
/// <inheritdoc/>
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions test/UnitTest/Components/CardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public void Header_Ok()
{
var cut = Context.RenderComponent<Card>(builder => builder.Add(a => a.HeaderTemplate, CreateComponent()));
Assert.Contains(Content, cut.Markup);

cut.SetParametersAndRender(pb =>
{
pb.Add(a => a.HeaderPaddingY, "0.25rem");
});
cut.Contains("--bs-card-cap-padding-y: 0.25rem;");
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion test/UnitTest/Components/DisplayTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void Bind_Ok()
});
});
});
Assert.Contains("<div class=\"input-group\"><div class=\"form-control is-display\">test-name</div><div class=\"input-group-text\"><span>姓名</span></div><div class=\"input-group-text\"><span></span></div></div>", cut.Markup);
Assert.Contains("<div class=\"input-group\"><div class=\"form-control is-display\">test-name</div><div class=\"input-group-text\">姓名</div><div class=\"input-group-text\"></div></div>", cut.Markup);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion test/UnitTest/Components/InputTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public void InputGroup_Width()
}));
});

cut.MarkupMatches("<div class=\"input-group\"><div class=\"input-group-text\" required=\"true\" style=\"--bb-input-group-label-width: 120px;\"><span>BootstrapInputGroup</span></div></div>");
cut.MarkupMatches("<div class=\"input-group\"><div class=\"input-group-text\" style=\"--bb-input-group-label-width: 120px;\" required=\"true\">BootstrapInputGroup</div></div>");
}

[Fact]
Expand Down