Skip to content

Commit b008908

Browse files
authored
feat(CheckboxList): add outline style (#6538)
* chore: 更新 CheckboxList 实现逻辑 * refactor: 微调样式 * refactor: 开发模式不使用后台服务 * Revert "chore: 更新 CheckboxList 实现逻辑" This reverts commit 312fad3. # Conflicts: # src/BootstrapBlazor/Components/Checkbox/CheckboxList.razor.cs * Revert "refactor: 微调样式" This reverts commit 061ca85. # Conflicts: # src/BootstrapBlazor/Components/Checkbox/CheckboxList.razor.cs * feat: 同步 bs 实现 * doc: 更新示例 * style: 微调样式 * style: 调整样式
1 parent 184b491 commit b008908

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/BootstrapBlazor.Server/Components/Samples/CheckboxLists.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
<BootstrapInput @bind-Value="@Model.Name" />
129129
</div>
130130
<div class="col-12 col-sm-6">
131-
<CheckboxList @bind-Value="@SelectedItems" IsButton="true" Items="FooItems" />
131+
<CheckboxList @bind-Value="@SelectedItems" IsButton="true" Items="FooItems" ShowLabel="true" DisplayText="Hobby" />
132132
</div>
133133
</div>
134134
</ValidateForm>

src/BootstrapBlazor/Components/Checkbox/CheckboxList.razor

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
<div class="@ButtonGroupClassString" role="group">
1414
@foreach (var item in Items)
1515
{
16-
<DynamicElement TagName="span" TriggerClick="!IsDisabled" OnClick="() => OnClick(item)" class="@GetButtonItemClassString(item)">
16+
<DynamicElement TagName="span" TriggerClick="!IsDisabled" OnClick="() => OnClick(item)"
17+
class="@GetButtonItemClassString(item)">
1718
@item.Text
1819
</DynamicElement>
1920
}

src/BootstrapBlazor/Components/Checkbox/CheckboxList.razor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public partial class CheckboxList<TValue> : ValidateBase<TValue>
3838
.Build();
3939

4040
private string? GetButtonItemClassString(SelectedItem item) => CssBuilder.Default("btn")
41-
.AddClass($"active bg-{Color.ToDescriptionString()}", CurrentValueAsString.Split(',', StringSplitOptions.RemoveEmptyEntries).Contains(item.Value))
41+
.AddClass($"btn-outline-{Color.ToDescriptionString()}")
42+
.AddClass($"active", CurrentValueAsString.Split(',', StringSplitOptions.RemoveEmptyEntries).Contains(item.Value))
4243
.Build();
4344

4445
/// <summary>

src/BootstrapBlazor/Components/Checkbox/CheckboxList.razor.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.checkbox-list {
1+
.checkbox-list {
22
--bb-checkbox-item-width: #{$bb-checkbox-item-width};
33
min-height: var(--bb-height);
44
height: auto;
@@ -38,7 +38,6 @@
3838
}
3939

4040
.btn-group {
41-
border: var(--bs-border-width) solid var(--bs-border-color);
4241
display: inline-flex;
4342
flex: 0 !important;
4443
flex-wrap: nowrap;
@@ -54,13 +53,19 @@
5453

5554
&.disabled {
5655
> span {
56+
--bs-btn-hover-color: var(--bs-btn-color);
57+
--bs-btn-active-color: var(--bs-btn-color);
5758
opacity: var(--bs-btn-disabled-opacity);
5859

5960
&:not(.active) {
6061
background-color: var(--bs-secondary-bg);
6162
}
6263
}
6364
}
65+
66+
.btn-outline-info {
67+
--bs-btn-active-color: #fff;
68+
}
6469
}
6570
}
6671

0 commit comments

Comments
 (0)