Skip to content

Commit

Permalink
🐛 fix(SimpleCheckbox): incorrect behavior of color (#2279)
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem committed Dec 18, 2024
1 parent dc28423 commit 1b8bdad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/Masa.Blazor/Components/Checkbox/MSimpleCheckbox.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@namespace Masa.Blazor
@using StyleBuilder = Masa.Blazor.Core.StyleBuilder
@inherits MasaComponentBase

<CascadingValue Value="IsDark" Name="IsDark">
Expand All @@ -8,7 +7,7 @@
@onclick="@HandleOnClickAsync"
@onclick:stopPropagation>
<div class="@_selectionBlock.Element("input")" ripple="@(Ripple && !Disabled)">
<MIcon Color="@(Value ? Color : null)"
<MIcon Color="@ComputedColor"
Disabled="@Disabled"
Dark="@Dark"
Light="@Light">
Expand Down
9 changes: 8 additions & 1 deletion src/Masa.Blazor/Components/Checkbox/MSimpleCheckbox.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ public partial class MSimpleCheckbox : MasaComponentBase
private ModifierBuilder _modifierBuilder = _block.CreateModifierBuilder();
private static Block _selectionBlock = new("m-input--selection-controls");

private string? ComputedColor => Disabled || !Value ? null : Color;

protected override IEnumerable<string> BuildComponentClass()
{
yield return _modifierBuilder.Add(Disabled).Build();
yield return _modifierBuilder.Add(Disabled).AddTextColor(ComputedColor).Build();
}

protected override IEnumerable<string?> BuildComponentStyle()
{
yield return new StyleBuilder().AddTextColor(ComputedColor).ToString();
}

public bool IsDark
Expand Down

0 comments on commit 1b8bdad

Please sign in to comment.