Add game header #5

Merged
Egamorf merged 14 commits from feature/add-game-header into main 2025-03-20 18:33:28 +01:00
2 changed files with 38 additions and 9 deletions
Showing only changes of commit 237c88d38b - Show all commits

View File

@@ -3,16 +3,17 @@
@typeparam TItem @typeparam TItem
<div class="select-list"> <div class="select-list">
<div class="select-button" @onfocusin=HandleFocusIn> <div class="select-button" @onfocusin=HandleFocusIn @onfocusout=HandleFocusOut>
<SearchInput @ref=SearchInput <SearchInput @ref=SearchInput
Icon="SearchInputIcon.Dropdown" Icon="SearchInputIcon.Dropdown"
TextChanged="HandleTextChanged" TextChanged="HandleTextChanged"
ClearClicked="HandleTextChanged" ClearClicked="HandleTextChanged"
SearchClicked="Toggle" /> SearchClicked="HandleSearchClicked" />
</div> </div>
<div @onfocusout=HandleFocusOut <div class="select-container @(AlignRight ? "align-right" : "")"
class="select-container @(AlignRight ? "align-right" : "")" tabindex="1000"
tabindex="1000"> @onfocusin=HandleContentFocusIn
@onfocusout=HandleContentFocusOut>
@if (ContentVisile) @if (ContentVisile)
{ {

View File

@@ -14,14 +14,24 @@ public partial class MultipleSelectList<TItem>
private bool ContentVisile = false; private bool ContentVisile = false;
private SearchInput? SearchInput; private SearchInput? SearchInput;
private bool ShouldClose = false;
public void Open() => ContentVisile = true; public void Open() => ContentVisile = true;
public void Close() => ContentVisile = false; public async Task Close()
{
await Task.Delay(TimeSpan.FromSeconds(0.2));
if (ShouldClose)
{
ContentVisile = false;
ShouldClose = false;
}
}
public void Toggle() => ContentVisile = !ContentVisile; public void Toggle() => ContentVisile = !ContentVisile;
private void HandleFocusOut() => Close(); private async Task HandleFocusOut() => await Close();
private void HandleFocusIn() => Open(); private void HandleFocusIn() => Open();
@@ -33,13 +43,31 @@ public partial class MultipleSelectList<TItem>
await ValuesChanged.InvokeAsync(Values); await ValuesChanged.InvokeAsync(Values);
} }
private void HandleTextChanged() private async Task HandleTextChanged()
{ {
foreach (var item in Items) foreach (var item in Items)
{ {
item.IsSelected = false; item.IsSelected = false;
} }
Close(); await Close();
}
private void HandleContentFocusOut(Microsoft.AspNetCore.Components.Web.FocusEventArgs args)
{
ShouldClose = true;
ContentVisile = false;
}
private void HandleContentFocusIn(Microsoft.AspNetCore.Components.Web.FocusEventArgs args)
{
ShouldClose = true;
}
private void HandleSearchClicked()
{
if (ContentVisile)
{
ShouldClose = false;
}
ContentVisile = !ContentVisile;
} }
} }