Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(TableFilter): support Icon theme #778

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/BootstrapBlazor/Components/Filters/TableFilter.razor
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ else
<div class="d-flex flex-fill">
@if (ShowMoreButton)
{
<Button Color="Color.None" OnClick="OnClickPlus" Icon="fa-fw fa-solid fa-plus" IsDisabled="@(Count == 1)"></Button>
<Button Color="Color.None" OnClick="OnClickMinus" Icon="fa-fw fa-solid fa-minus" IsDisabled="@(Count == 0)"></Button>
<Button Color="Color.None" OnClick="OnClickPlus" Icon="@PlusIcon" IsDisabled="@(Count == 1)"></Button>
<Button Color="Color.None" OnClick="OnClickMinus" Icon="@MinusIcon" IsDisabled="@(Count == 0)"></Button>
}
</div>
<Button Color="Color.None" class="filter-dismiss" OnClick="OnClickReset" Text="@ClearButtonText"></Button>
Expand Down
19 changes: 19 additions & 0 deletions src/BootstrapBlazor/Components/Filters/TableFilter.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ public partial class TableFilter : IFilter
[Parameter]
public string? Icon { get; set; }

/// <summary>
/// 获得/设置 增加过滤条件图标
/// </summary>
[Parameter]
public string? PlusIcon { get; set; }

/// <summary>
/// 获得/设置 减少过滤条件图标
/// </summary>
[Parameter]
public string? MinusIcon { get; set; }

/// <summary>
/// 获得/设置 不支持过滤类型提示信息 默认 null 读取资源文件内容
/// </summary>
Expand Down Expand Up @@ -117,6 +129,10 @@ public partial class TableFilter : IFilter
[NotNull]
private IStringLocalizer<TableFilter>? Localizer { get; set; }

[Inject]
[NotNull]
private IIconTheme? IconTheme { get; set; }

private string? Step => Column.Step?.ToString() ?? "0.01";

/// <summary>
Expand All @@ -141,6 +157,9 @@ protected override void OnParametersSet()
FilterButtonText ??= Localizer[nameof(FilterButtonText)];
ClearButtonText ??= Localizer[nameof(ClearButtonText)];
NotSupportedMessage ??= Localizer[nameof(NotSupportedMessage)];

PlusIcon ??= IconTheme.GetIconByKey(ComponentIcons.TableFilterPlusIcon);
MinusIcon ??= IconTheme.GetIconByKey(ComponentIcons.TableFilterMinusIcon);
}

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions src/BootstrapBlazor/Enums/ComponentIcons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ public enum ComponentIcons
/// </summary>
FilterButtonClearIcon,

/// <summary>
/// TableFilter 组件 PlusIcon 图标
/// </summary>
TableFilterPlusIcon,

/// <summary>
/// TableFilter 组件 MinusIcon 图标
/// </summary>
TableFilterMinusIcon,

/// <summary>
/// Button 组件 LoadingIcon 图标
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions src/BootstrapBlazor/Services/DefaultIconTheme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public DefaultIconTheme()
{ ComponentIcons.FilterButtonFilterIcon, "fa-solid fa-filter" },
{ ComponentIcons.FilterButtonClearIcon, "fa-solid fa-ban" },

{ ComponentIcons.TableFilterPlusIcon, "fa-solid fa-plus" },
{ ComponentIcons.TableFilterMinusIcon, "fa-solid fa-minus" },

{ ComponentIcons.LoadingIcon, "fa-solid fa-fw fa-spin fa-spinner" },

{ ComponentIcons.PopConfirmButtonConfirmIcon, "fa-solid fa-circle-exclamation text-info" },
Expand Down