Skip to content

Commit

Permalink
Added parameters: TextColor, CheckBoxCheckedColor, CheckBoxUnCheckedC…
Browse files Browse the repository at this point in the history
…olor, CheckBoxSize
  • Loading branch information
Jeffrey Jangli authored and Jeffrey Jangli committed Oct 23, 2023
1 parent 211e4e1 commit 0b9dd48
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
{
foreach (var item in CollectionsMarshal.AsSpan(collection))
{
<MudChip Class="@ChipClass" Value="@item.Value" Text="@(ToStringFunc is not null ? ToStringFunc.Invoke(item.Value) : string.IsNullOrWhiteSpace(item.Text) ? Converter.Set(item.Value) : item.Text)" Color="@Color" Size="@ChipSize" Variant="@ChipVariant" @onmousedown:stopPropagation />
<MudChip Class="@ChipClass" Value="@item.Value" Text="@(ToStringFunc is not null ? ToStringFunc.Invoke(item.Value) : string.IsNullOrWhiteSpace(item.Text) ? Converter.Set(item.Value) : item.Text)"
Color="@CheckBoxCheckedColor" Size="@ChipSize" Variant="@ChipVariant" @onmousedown:stopPropagation />
}
}
}
Expand Down Expand Up @@ -129,7 +130,8 @@
{
<div class="pa-2">
<MudTextFieldExtended id="@($"{_elementId}-autocomplete")" @ref="@_searchbox" T="string" @bind-Value="@_searchString" Margin="Margin.Dense"
Variant="Variant.Outlined" Immediate="true" OnKeyDown="@SearchBoxHandleKeyDown" OnKeyUp="@SearchBoxHandleKeyUp" Clearable="@SearchBoxClearable">
Variant="Variant.Outlined" Immediate="true" OnKeyDown="@SearchBoxHandleKeyDown" OnKeyUp="@SearchBoxHandleKeyUp"
Clearable="@SearchBoxClearable">
<AdornmentEnd>
<MudIcon Icon="@Icons.Material.Filled.Search" Color="@Color" />
</AdornmentEnd>
Expand All @@ -140,8 +142,13 @@
@if (SelectAll)
{
<div class="@($"mud-combobox-item mud-combobox-item-clickable mud-combobox-item-{Dense.ToDescriptionString()} mud-ripple d-flex")" @onclick="SelectAllItems" @onclick:stopPropagation="true">
<MudCheckBox Class="mx-4" @bind-Checked="@_allSelected" Color="@Color" @onclick="@SelectAllItems" Dense="true" />
<MudText Typo="GetTypo()">@SelectAllText</MudText>
<MudCheckBox Class="mx-4" Dense
@bind-Checked="@_allSelected" @onclick="@SelectAllItems"
Size="@CheckBoxSize"
Color="@CheckBoxCheckedColor"
UnCheckedColor="@CheckBoxUnCheckedColor" />

<MudText Typo="GetTypo()" Color="@TextColor">@SelectAllText</MudText>
</div>
<MudDivider />
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,38 @@ protected internal void SetSearchString(T value)
[Category(CategoryTypes.FormComponent.Appearance)]
public Color Color { get; set; } = Color.Primary;

/// <summary>
/// The color of the text. It supports the theme colors.
/// </summary>
/// <remarks>The default is <see cref="Color.Default"/></remarks>
[Parameter]
[Category(CategoryTypes.List.Behavior)]
public Color TextColor { get; set; } = Color.Default;

/// <summary>
/// The color of the checked checkbox. It supports the theme colors.
/// </summary>
/// <remarks>The default is <see cref="Color.Default"/></remarks>
[Parameter]
[Category(CategoryTypes.List.Behavior)]
public Color CheckBoxCheckedColor { get; set; } = Color.Default;

/// <summary>
/// The color of the unchecked checkbox. It supports the theme colors.
/// </summary>
/// <remarks>The default is <see cref="Color.Default"/></remarks>
[Parameter]
[Category(CategoryTypes.Radio.Appearance)]
public Color CheckBoxUnCheckedColor { get; set; } = Color.Default;

/// <summary>
/// The size of the checkbox.
/// </summary>
/// <remarks>The default is <see cref="Size.Medium"/></remarks>
[Parameter]
[Category(CategoryTypes.FormComponent.Appearance)]
public Size CheckBoxSize { get; set; } = Size.Medium;

/// <summary>
/// The input's visual.
/// </summary>
Expand Down Expand Up @@ -1449,7 +1481,7 @@ protected bool HasEligibleItems()

protected internal string GetSearchString() => _searchString;

protected Typo GetTypo() => Dense == Dense.Slim || Dense == Dense.Superslim ? Typo.body2 : Typo.body1;
protected internal Typo GetTypo() => Dense == Dense.Slim || Dense == Dense.Superslim ? Typo.body2 : Typo.body1;

protected internal ValueTask ScrollToMiddleAsync(MudComboBoxItem<T> item) => item is not null ? ScrollManagerExtended.ScrollToMiddleAsync(_popoverId, item.ItemId) : ValueTask.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@

@if (MudComboBox.MultiSelection && MudComboBox.ShowCheckbox)
{
<MudCheckBox Class="me-4" Color="@MudComboBox.Color" Disabled="@Disabled" @bind-Checked="@Selected" @onclick="@HandleOnClick" Dense="true" />
<MudCheckBox Class="me-4" Dense
@bind-Checked="@Selected" @onclick="@HandleOnClick"
Size="@(CheckBoxSize ?? MudComboBox.CheckBoxSize)"
Color="@(CheckBoxCheckedColor ?? MudComboBox.CheckBoxCheckedColor)"
UnCheckedColor="@(CheckBoxUnCheckedColor ?? MudComboBox.CheckBoxUnCheckedColor)"
Disabled="@Disabled" />
}

<MudText Typo="GetTypo()">
<MudText Typo="MudComboBox.GetTypo()" Color="@(TextColor ?? MudComboBox.TextColor)">
@if (ChildContent != null && MudComboBox.ItemPresenter == ValuePresenter.ItemContent)
{
@ChildContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,7 @@ public partial class MudComboBoxItem<T> : MudBaseSelectItem, IDisposable
/// The parent select component
/// </summary>
[CascadingParameter]
internal MudComboBox<T> MudComboBox { get; set; }

protected Typo GetTypo()
{
if (MudComboBox == null)
{
return Typo.body1;
}

if (MudComboBox.Dense == Dense.Slim || MudComboBox.Dense == Dense.Superslim)
{
return Typo.body2;
}

return Typo.body1;
}

///// <summary>
///// Functional items does not hold values. If a value set on Functional item, it ignores by the MudSelect. They cannot be subject of keyboard navigation and selection.
///// </summary>
//[Parameter]
//[Category(CategoryTypes.List.Behavior)]
//public bool IsFunctional { get; set; }
MudComboBox<T> MudComboBox { get; set; }

/// <summary>
/// The text to display
Expand All @@ -72,6 +50,39 @@ protected Typo GetTypo()
[Category(CategoryTypes.FormComponent.Behavior)]
public T Value { get; set; }

/// <summary>
/// The color of the text. It supports the theme colors.
/// </summary>
/// <remarks>The default is <see cref="MudComboBox.TextColor"/></remarks>
[Parameter]
[Category(CategoryTypes.List.Behavior)]
public Color? TextColor { get; set; } = null;

/// <summary>
/// The color of the checked checkbox. It supports the theme colors.
/// </summary>
/// <remarks>The default is <see cref="MudComboBox.CheckBoxCheckedColor"/></remarks>
[Parameter]
[Category(CategoryTypes.List.Behavior)]
public Color? CheckBoxCheckedColor { get; set; } = null;

/// <summary>
/// The color of the unchecked checkbox. It supports the theme colors.
/// </summary>
/// <remarks>The default is <see cref="MudComboBox.CheckBoxUnCheckedColor"/></remarks>
[Parameter]
[Category(CategoryTypes.Radio.Appearance)]
public Color? CheckBoxUnCheckedColor { get; set; } = null;

/// <summary>
/// The size of the checkbox.
/// </summary>
/// <remarks>The default is <see cref="MudComboBox.CheckBoxSize"/></remarks>
[Parameter]
[Category(CategoryTypes.FormComponent.Appearance)]
public Size? CheckBoxSize { get; set; } = null;


protected internal bool Selected { get; set; }
protected internal bool Active { get; set; }

Expand Down

0 comments on commit 0b9dd48

Please sign in to comment.