From 52b9ace08c4c42b89e9371f9c289bc79dc437ca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Pilgaard=20Gr=C3=B8ndahl?= Date: Sun, 11 Aug 2024 19:57:19 +0200 Subject: [PATCH] Add snacks for searches to indicate scrolling --- .../GroupSearch/GroupSearchForm.razor | 121 ++++++++++-------- .../Features/UserSearch/UserSearchForm.razor | 4 +- .../Pages/GroupSearch/GroupSearch.razor | 36 ++++-- .../Pages/UserSearch/UserSearch.razor | 27 +++- 4 files changed, 116 insertions(+), 72 deletions(-) diff --git a/src/web/Jordnaer/Features/GroupSearch/GroupSearchForm.razor b/src/web/Jordnaer/Features/GroupSearch/GroupSearchForm.razor index edddff47..3d79af97 100644 --- a/src/web/Jordnaer/Features/GroupSearch/GroupSearchForm.razor +++ b/src/web/Jordnaer/Features/GroupSearch/GroupSearchForm.razor @@ -1,60 +1,71 @@ @inject NavigationManager Navigation +@inject IJSRuntime JsRuntime - -

- Find Grupper nær dig -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ + + Gå til mine grupper + + + +

+ Find Grupper nær dig +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@code @@ -83,7 +94,7 @@ _recentlyClearedForm = true; - Navigation.NavigateTo(uriWithoutQuery); + await JsRuntime.NavigateTo(uriWithoutQuery); } private void LocationChanged(string location) diff --git a/src/web/Jordnaer/Features/UserSearch/UserSearchForm.razor b/src/web/Jordnaer/Features/UserSearch/UserSearchForm.razor index 3d7e8a12..0cc6e023 100644 --- a/src/web/Jordnaer/Features/UserSearch/UserSearchForm.razor +++ b/src/web/Jordnaer/Features/UserSearch/UserSearchForm.razor @@ -1,4 +1,5 @@ @inject NavigationManager Navigation +@inject IJSRuntime JsRuntime @@ -119,7 +120,6 @@ private async Task ClearFilter() { - Filter.Categories = []; Filter = new UserSearchFilter(); await FilterChanged.InvokeAsync(Filter); @@ -128,7 +128,7 @@ _recentlyClearedForm = true; - Navigation.NavigateTo(uriWithoutQuery); + await JsRuntime.NavigateTo(uriWithoutQuery); } private void LocationChanged(string location) diff --git a/src/web/Jordnaer/Pages/GroupSearch/GroupSearch.razor b/src/web/Jordnaer/Pages/GroupSearch/GroupSearch.razor index 2dc40dca..043b410a 100644 --- a/src/web/Jordnaer/Pages/GroupSearch/GroupSearch.razor +++ b/src/web/Jordnaer/Pages/GroupSearch/GroupSearch.razor @@ -9,15 +9,6 @@ - - Gå til mine grupper - - @@ -81,9 +72,30 @@ await UpdateQueryString(); - Snackbar.Add(message: $"{_searchResult.TotalCount} brugere matchede søgningen.", - severity: _searchResult.TotalCount is 0 ? Severity.Info : Severity.Success, - options => options.VisibleStateDuration = 3500); + if (_searchResult.TotalCount is 0) + { + Snackbar.Add( + message: "Ingen grupper matchede søgningen.", + severity: Severity.Info, + options => + { + options.VisibleStateDuration = 3500; + options.CloseAfterNavigation = true; + }, + key: nameof(GroupSearch)); + } + else + { + Snackbar.Add(message: $"{_searchResult.TotalCount} grupper matchede søgningen.", + severity: Severity.Success, + options => + { + options.VisibleStateDuration = 3500; + options.Icon = Icons.Material.Filled.ArrowDownward; + options.CloseAfterNavigation = true; + }, + key: nameof(GroupSearch)); + } _hasSearched = true; diff --git a/src/web/Jordnaer/Pages/UserSearch/UserSearch.razor b/src/web/Jordnaer/Pages/UserSearch/UserSearch.razor index 605ab0c3..eec2fc8f 100644 --- a/src/web/Jordnaer/Pages/UserSearch/UserSearch.razor +++ b/src/web/Jordnaer/Pages/UserSearch/UserSearch.razor @@ -74,9 +74,30 @@ _searchResult = await UserSearchService.GetUsersAsync(_filter); - Snackbar.Add(message: $"{_searchResult.TotalCount} brugere matchede søgningen.", - severity: _searchResult.TotalCount is 0 ? Severity.Info : Severity.Success, - options => options.VisibleStateDuration = 3500); + if (_searchResult.TotalCount is 0) + { + Snackbar.Add( + message: "Ingen brugere matchede søgningen.", + severity: Severity.Info, + options => + { + options.VisibleStateDuration = 3500; + options.CloseAfterNavigation = true; + }, + key: nameof(UserSearch)); + } + else + { + Snackbar.Add(message: $"{_searchResult.TotalCount} brugere matchede søgningen.", + severity: Severity.Success, + options => + { + options.VisibleStateDuration = 3500; + options.Icon = Icons.Material.Filled.ArrowDownward; + options.CloseAfterNavigation = true; + }, + key: nameof(UserSearch)); + } await UpdateQueryString();