diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor new file mode 100644 index 0000000..97a356b --- /dev/null +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor @@ -0,0 +1,55 @@ +@if (IsVisible) +{ +
+} + +@code { + [Inject] private IJSRuntime Js { get; set; } = default!; + [Parameter] public EventCallback OnClick { get; set; } + [Parameter] public bool AllowBodyScroll { get; set; } + [Parameter] public BackdropFilterColor Color { get; set; } = BackdropFilterColor.Overlay; + [Parameter] public bool CloseOnClick { get; set; } = true; + [Parameter] public bool IsVisible { get; set; } + + public async Task Show() + { + IsVisible = true; + await HandleBodyOverflow(); + } + + public async Task Hide() + { + IsVisible = false; + await HandleBodyOverflow(); + } + + private async Task HandleBodyOverflow() + { + try + { + if (AllowBodyScroll) return; + + if (IsVisible) + { + await Js.InvokeVoidAsync("setBodyOverflow", "hidden"); + } + else + { + await Js.InvokeVoidAsync("setBodyOverflow", "auto"); + } + } + catch (Exception) + { + // ignored because js not loaded + } + } + + private async Task HandleBackdropClicked() + { + if (!CloseOnClick) return; + + await Hide(); + await OnClick.InvokeAsync(); + } + +} \ No newline at end of file diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor.css b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor.css new file mode 100644 index 0000000..5d089d1 --- /dev/null +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor.css @@ -0,0 +1,13 @@ +.backdrop-filter { + position: fixed; + inset: 0; + z-index: var(--index-backdrop); +} + + .backdrop-filter.overlay { + background-color: var(--grey-filter); + } + + .backdrop-filter.transparent { + background-color: transparent; + } diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor.js b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor.js new file mode 100644 index 0000000..3f2b25b --- /dev/null +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor.js @@ -0,0 +1,3 @@ +window.setBodyOverflow = (overflow) => { + document.getElementsByTagName('html')[0].style.overflow = overflow; +} diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilterColor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilterColor.cs new file mode 100644 index 0000000..16cddd2 --- /dev/null +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilterColor.cs @@ -0,0 +1,7 @@ +namespace GameIdeas.BlazorApp.Shared.Components.BackdropFilter; + +public enum BackdropFilterColor +{ + Overlay, + Transparent +} diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor index 911db66..8ceeca7 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor @@ -1,10 +1,12 @@ 
- + @bind:after=HandleTextChanged + @onfocusin=HandleFocusIn/> @if (!string.IsNullOrEmpty(Text)) { diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor.cs index 3e3f8e6..755f951 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor.cs @@ -9,8 +9,11 @@ public partial class SearchInput [Parameter] public EventCallback TextChanged { get; set; } [Parameter] public EventCallback ClearClicked { get; set; } [Parameter] public EventCallback SearchClicked { get; set; } + [Parameter] public EventCallback FocusIn { get; set; } [Parameter] public SearchInputIcon Icon { get; set; } + private ElementReference InputText; + protected override void OnInitialized() { Text = string.Empty; @@ -36,5 +39,10 @@ public partial class SearchInput { await TextChanged.InvokeAsync(Text); await SearchClicked.InvokeAsync(); + await InputText.FocusAsync(); + } + private async Task HandleFocusIn() + { + await FocusIn.InvokeAsync(); } } \ No newline at end of file diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/MultipleSelectList.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/MultipleSelectList.razor index 54c465f..0f91a06 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/MultipleSelectList.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/MultipleSelectList.razor @@ -1,21 +1,19 @@ -@using GameIdeas.BlazorApp.Shared.Components.Search +@using GameIdeas.BlazorApp.Shared.Components.BackdropFilter +@using GameIdeas.BlazorApp.Shared.Components.Search @using GameIdeas.BlazorApp.Shared.Components.Select.Components @typeparam TItem -
-
+
+
+ SearchClicked="HandleSearchClicked" + FocusIn="HandleTextFocusIn"/>
-
+
@if (IsContentOpen) { @@ -32,3 +30,6 @@
+ + diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/MultipleSelectList.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/MultipleSelectList.razor.cs index 4ecef67..7fb4b15 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/MultipleSelectList.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/MultipleSelectList.razor.cs @@ -13,60 +13,34 @@ public partial class MultipleSelectList [Parameter] public bool AlignRight { get; set; } [Parameter] public string? Placeholder { get; set; } - private bool IsContentOpen - { - get => InputFocus || ContentFocus; - } - - private bool InputFocus = false; - private bool ContentFocus = false; + private bool IsContentOpen = false; private SearchInput? SearchInput; - private ElementReference ContentElement; - private ElementReference BaseElement; private async Task HandleItemClicked(SelectElement selectedValue) { + selectedValue.IsSelected = !selectedValue.IsSelected; + Values = Items.Where(x => x.IsSelected && x.Item != null).Select(x => x.Item!); SearchInput?.SetText(string.Join(", ", Values)); + await ValuesChanged.InvokeAsync(Values); } - private async Task HandleTextChanged() + private void HandleTextChanged() { - await BaseElement.FocusAsync(); + IsContentOpen = false; } - private void HandleFocusIn() + private void HandleSearchClicked() { - InputFocus = true; + IsContentOpen = !IsContentOpen; } - - private void HandleContentFocusIn() + private void HandleContentClosed() { - ContentFocus = true; + IsContentOpen = false; } - - private async Task HandleContentFocusOut() + private void HandleTextFocusIn() { - await Task.Delay(TimeSpan.FromSeconds(0.3)); - ContentFocus = false; - } - - private async Task HandleFocusOut() - { - await Task.Delay(TimeSpan.FromSeconds(0.3)); - InputFocus = false; - } - - private async Task HandleSearchClicked() - { - if (!IsContentOpen) - { - await ContentElement.FocusAsync(); - } - else - { - await BaseElement.FocusAsync(); - } + IsContentOpen = true; } } \ No newline at end of file diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/MultipleSelectList.razor.css b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/MultipleSelectList.razor.css index bfdbc90..3f5a5d9 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/MultipleSelectList.razor.css +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/MultipleSelectList.razor.css @@ -47,5 +47,10 @@ height: 24px; width: 210px; border: 2px solid var(--input-selected); + background: var(--input-secondary); +} + +::deep .select-button.advancedfilter .search-container input::placeholder { + color: #ddd; } diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/wwwroot/css/app.css b/src/GameIdeas/Client/GameIdeas.BlazorApp/wwwroot/css/app.css index 0158695..c8e9eca 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/wwwroot/css/app.css +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/wwwroot/css/app.css @@ -25,8 +25,8 @@ --index-layout: 100; --index-component: 300; --index-floating: 500; - --index-dropdown: 700; - --index-backdrop: 900; + --index-backdrop: 700; + --index-dropdown: 900; --index-popup: 1000; }