Skip to content

Commit da655c5

Browse files
authored
fix(Checkbox): redesign checkbox style compatible InputGroup (#5168)
* refactor: 代码格式化 * fix: 修复 DisplayText 丢失问题 * doc: 更新示例 * test: 更新单元测试 * refactor: 精简代码适配 InputGroup * style: 增加适配样式
1 parent 278aada commit da655c5

File tree

2 files changed

+34
-35
lines changed

2 files changed

+34
-35
lines changed

src/BootstrapBlazor/Components/Checkbox/Checkbox.razor

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,22 @@
66
{
77
<BootstrapLabel required="@Required" for="@Id" ShowLabelTooltip="ShowLabelTooltip" Value="@DisplayText" />
88
}
9-
@if(InputGroup == null)
10-
{
11-
@RenderCheckbox
12-
}
13-
else
14-
{
15-
<div class="form-control">
16-
@RenderCheckbox
17-
</div>
18-
}
19-
20-
@code {
21-
RenderFragment RenderCheckbox =>
22-
@<div @attributes="AdditionalAttributes" class="@ClassString">
23-
<input type="checkbox" id="@Id" class="@InputClassString" disabled="@Disabled" checked="@CheckedString"
24-
@onclick="OnToggleClick" @onclick:stopPropagation="StopPropagation" @onclick:preventDefault="false" />
25-
@if (IsShowAfterLabel)
26-
{
27-
@RenderLabel
28-
}
29-
</div>;
30-
31-
RenderFragment RenderLabel =>
32-
@<label class="form-check-label" for="@Id">
33-
@if(ShowLabelTooltip is true)
34-
{
35-
<Tooltip Title="@DisplayText">
9+
<div @attributes="AdditionalAttributes" class="@ClassString">
10+
<input type="checkbox" id="@Id" class="@InputClassString" disabled="@Disabled" checked="@CheckedString"
11+
@onclick="OnToggleClick" @onclick:stopPropagation="StopPropagation" @onclick:preventDefault="false" />
12+
@if (IsShowAfterLabel)
13+
{
14+
<label class="form-check-label" for="@Id">
15+
@if (ShowLabelTooltip is true)
16+
{
17+
<Tooltip Title="@DisplayText">
18+
@DisplayText
19+
</Tooltip>
20+
}
21+
else
22+
{
3623
@DisplayText
37-
</Tooltip>
38-
}
39-
else
40-
{
41-
@DisplayText
42-
}
43-
</label>;
44-
}
24+
}
25+
</label>
26+
}
27+
</div>

src/BootstrapBlazor/Components/Input/BootstrapInputGroup.razor.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@
5858
> .form-label {
5959
display: none;
6060
}
61+
62+
> .form-check {
63+
--bb-form-check-padding: 0.375rem 0.75rem;
64+
border: 1px solid var(--bs-border-color);
65+
border-radius: var(--bs-border-radius);
66+
flex-grow: 1;
67+
width: 1%;
68+
min-width: 0;
69+
display: flex;
70+
align-items: center;
71+
padding: var(--bb-form-check-padding);
72+
73+
&:hover {
74+
border: 1px solid var(--bb-border-hover-color);
75+
}
76+
}
6177
}
6278

6379
.input-group-xs {

0 commit comments

Comments
 (0)