Skip to content

Commit 64e861a

Browse files
committed
add missing features to BitToggleButton #10536
1 parent 486341a commit 64e861a

File tree

6 files changed

+339
-184
lines changed

6 files changed

+339
-184
lines changed

src/BlazorUI/Bit.BlazorUI/Components/Buttons/ToggleButton/BitToggleButton.razor.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,23 @@ public partial class BitToggleButton : BitComponentBase
4545
/// </summary>
4646
[Parameter] public bool? DefaultIsChecked { get; set; }
4747

48+
/// <summary>
49+
/// Preserves the foreground color of the toggle button through hover and focus.
50+
/// </summary>
51+
[Parameter, ResetClassBuilder]
52+
public bool FixedColor { get; set; }
53+
4854
/// <summary>
4955
/// The icon name that renders inside the toggle button.
5056
/// </summary>
5157
[Parameter] public string? IconName { get; set; }
5258

59+
/// <summary>
60+
/// Determines that only the icon should be rendered and changes the styles accordingly.
61+
/// </summary>
62+
[Parameter, ResetClassBuilder]
63+
public bool IconOnly { get; set; }
64+
5365
/// <summary>
5466
/// Determines if the toggle button is in the checked state.
5567
/// </summary>
@@ -133,6 +145,10 @@ protected override void RegisterCssClasses()
133145

134146
ClassBuilder.Register(() => IsChecked ? $"bit-tgb-chk {Classes?.Checked}" : string.Empty);
135147

148+
ClassBuilder.Register(() => ((ChildContent is null && (Text ?? OnText ?? OffText) is null) || IconOnly) ? $"bit-tgb-ntx" : string.Empty);
149+
150+
ClassBuilder.Register(() => FixedColor ? "bit-tgb-fxc" : string.Empty);
151+
136152
ClassBuilder.Register(() => Color switch
137153
{
138154
BitColor.Primary => "bit-tgb-pri",

src/BlazorUI/Bit.BlazorUI/Components/Buttons/ToggleButton/BitToggleButton.scss

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,27 @@
77
align-items: center;
88
display: inline-flex;
99
text-decoration: none;
10-
1110
box-sizing: border-box;
1211
justify-content: center;
1312
font-family: $tg-font-family;
1413
font-weight: $tg-font-weight;
1514
border-width: $shp-border-width;
1615
border-style: $shp-border-style;
1716
border-radius: $shp-border-radius;
17+
font-size: var(--bit-tgb-fontsize);
18+
--bit-tgb-icn-margin: #{spacing(0.5)};
1819

1920
&.bit-dis {
2021
cursor: default;
21-
pointer-events: none;
2222
color: $clr-fg-dis;
23+
pointer-events: none;
2324
}
2425
}
2526

2627
.bit-tgb-ico {
2728
flex-shrink: 0;
2829
text-align: center;
29-
margin: 0 spacing(0.5);
30+
margin-inline-end: var(--bit-tgb-icn-margin);
3031
}
3132

3233
.bit-tgb-btx {
@@ -290,16 +291,36 @@
290291

291292

292293
.bit-tgb-sm {
293-
font-size: spacing(1.5);
294294
padding: spacing(0.5) spacing(1.5);
295+
--bit-tgb-fontsize: #{spacing(1.5)};
296+
--bit-tgb-ntx-pad: #{spacing(0.5)};
297+
--bit-tgb-ntx-icn-size: #{spacing(2.00)};
295298
}
296299

297300
.bit-tgb-md {
298-
font-size: spacing(1.75);
299301
padding: spacing(0.75) spacing(2);
302+
--bit-tgb-fontsize: #{spacing(1.75)};
303+
--bit-tgb-ntx-pad: #{spacing(0.75)};
304+
--bit-tgb-ntx-icn-size: #{spacing(2.35)};
300305
}
301306

302307
.bit-tgb-lg {
303-
font-size: spacing(2);
304308
padding: spacing(1) spacing(2.5);
309+
--bit-tgb-fontsize: #{spacing(2)};
310+
--bit-tgb-ntx-pad: #{spacing(1.0)};
311+
--bit-tgb-ntx-icn-size: #{spacing(3.35)};
312+
}
313+
314+
315+
316+
// important: these need to be here at the end!
317+
318+
.bit-tgb-fxc {
319+
color: var(--bit-tgb-clr-txt);
320+
}
321+
322+
.bit-tgb-ntx {
323+
padding: var(--bit-tgb-ntx-pad);
324+
--bit-tgb-icn-margin: 0;
325+
--bit-tgb-fontsize: var(--bit-tgb-ntx-icn-size);
305326
}

0 commit comments

Comments
 (0)