Skip to content

Commit

Permalink
Merge pull request #656 from vaclavek/feature/HxSearchBox_InputWithCl…
Browse files Browse the repository at this point in the history
…earIcon

HxSearchBox - fix clear button padding if there is delete icon
  • Loading branch information
hakenr authored Nov 29, 2023
2 parents 6c1e7e0 + 2d5f760 commit 61d1048
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
14 changes: 13 additions & 1 deletion BlazorAppTest/Pages/HxSearchBoxTest.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
@page "/HxSearchBoxTest"

<HxSearchBox DataProvider="ProvideSearchResults" Label="Search" ItemTitleSelector="(i) => i.Title" ItemSubtitleSelector="(i) => i.Subtitle" ItemIconSelector="(i) => i.Icon" TItem="SearchBoxItem" >
<HxSearchBox DataProvider="ProvideSearchResults" Label="Search needle in a haystack" InputSize="InputSize.Small" ItemTitleSelector="(i) => i.Title" ItemSubtitleSelector="(i) => i.Subtitle" ItemIconSelector="(i) => i.Icon" TItem="SearchBoxItem">
<DefaultContentTemplate>
<div class="small py-2 px-3 text-muted">Search for Mouse, Table or Door...</div>
</DefaultContentTemplate>
</HxSearchBox>

<HxSearchBox DataProvider="ProvideSearchResults" Label="Search regular stuff" InputSize="InputSize.Regular" ItemTitleSelector="(i) => i.Title" ItemSubtitleSelector="(i) => i.Subtitle" ItemIconSelector="(i) => i.Icon" TItem="SearchBoxItem">
<DefaultContentTemplate>
<div class="small py-2 px-3 text-muted">Search for Mouse, Table or Door...</div>
</DefaultContentTemplate>
</HxSearchBox>

<HxSearchBox DataProvider="ProvideSearchResults" Label="Search huge things" InputSize="InputSize.Large" ItemTitleSelector="(i) => i.Title" ItemSubtitleSelector="(i) => i.Subtitle" ItemIconSelector="(i) => i.Icon" TItem="SearchBoxItem">
<DefaultContentTemplate>
<div class="small py-2 px-3 text-muted">Search for Mouse, Table or Door...</div>
</DefaultContentTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
class="@CssClassHelper.Combine(
"form-control",
(!HasInputGroupEnd && HasInputGroups ? "hx-search-box-input-with-search-icon" : null),
(HasClearButton ? "hx-search-box-input-with-clear-icon" : null),
InputCssClassEffective)" />

@if (!string.IsNullOrEmpty(Label) && LabelType == Havit.Blazor.Components.Web.Bootstrap.LabelType.Floating)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ public partial class HxSearchBox<TItem> : IAsyncDisposable
protected bool HasInputGroups => HasInputGroupStart || HasInputGroupEnd;
private bool HasInputGroupStart => !String.IsNullOrWhiteSpace(InputGroupStartText) || (InputGroupStartTemplate is not null);
private bool HasInputGroupEnd => !String.IsNullOrWhiteSpace(InputGroupEndText) || (InputGroupEndTemplate is not null);
private bool HasClearButton => !HasInputGroupEnd
&& !dataProviderInProgress
&& !string.IsNullOrEmpty(TextQuery)
&& (ClearIconEffective is not null);

private string dropdownToggleElementId = "hx" + Guid.NewGuid().ToString("N");
private string dropdownId = "hx" + Guid.NewGuid().ToString("N");
Expand All @@ -239,6 +243,7 @@ public partial class HxSearchBox<TItem> : IAsyncDisposable
private DotNetObjectReference<HxSearchBox<TItem>> dotnetObjectReference;
private bool clickIsComing;
private bool disposed = false;

public HxSearchBox()
{
dotnetObjectReference = DotNetObjectReference.Create(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
}

::deep .hx-search-box-input-with-search-icon {
border-top-right-radius: 0.375rem !important;
border-bottom-right-radius: 0.375rem !important;
border-top-right-radius: 0.375rem !important;
border-bottom-right-radius: 0.375rem !important;
}

::deep .hx-search-box-input-with-clear-icon {
padding-right: 2.375rem;
}

.dropdown-item:not(:active) ::deep .hx-search-box-item-title {
Expand Down

0 comments on commit 61d1048

Please sign in to comment.