From a0cbded0d700dcfe9b1d40fe83d9856d0e674986 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Sun, 29 Sep 2024 15:47:11 +0200 Subject: [PATCH] search bar finished --- .../WatchIt.Common.Query/QueryParameters.cs | 2 +- WatchIt.Website/WatchIt.Website/App.razor | 2 +- .../WatchIt.Website/Layout/MainLayout.razor | 18 +++++++++++++++++- .../Layout/MainLayout.razor.cs | 17 +++++++++++++++++ .../Layout/MainLayout.razor.css | 5 +++++ .../wwwroot/assets/icons/cancel.png | Bin 0 -> 581 bytes 6 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 WatchIt.Website/WatchIt.Website/wwwroot/assets/icons/cancel.png diff --git a/WatchIt.Common/WatchIt.Common.Query/QueryParameters.cs b/WatchIt.Common/WatchIt.Common.Query/QueryParameters.cs index 685da26..7934cdc 100644 --- a/WatchIt.Common/WatchIt.Common.Query/QueryParameters.cs +++ b/WatchIt.Common/WatchIt.Common.Query/QueryParameters.cs @@ -66,7 +66,7 @@ public abstract class QueryParameters ( !string.IsNullOrEmpty(property) && - new Regex(regexQuery).IsMatch(property) + Regex.IsMatch(property, regexQuery, RegexOptions.IgnoreCase) ) ); diff --git a/WatchIt.Website/WatchIt.Website/App.razor b/WatchIt.Website/WatchIt.Website/App.razor index 4492067..35cf53c 100644 --- a/WatchIt.Website/WatchIt.Website/App.razor +++ b/WatchIt.Website/WatchIt.Website/App.razor @@ -11,7 +11,7 @@ - + diff --git a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor index bacd53c..7473c33 100644 --- a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor +++ b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor @@ -20,7 +20,23 @@
- menu +
+ @if (_searchbarVisible) + { +
+ +
+ + + cancel_icon + + } + else + { + + + } +
diff --git a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor.cs b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor.cs index 941eb4f..db6a271 100644 --- a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor.cs @@ -1,3 +1,4 @@ +using System.Net; using Microsoft.AspNetCore.Components; using WatchIt.Common.Model.Accounts; using WatchIt.Common.Model.Photos; @@ -33,6 +34,9 @@ public partial class MainLayout : LayoutComponentBase private PhotoResponse? _defaultBackgroundPhoto; private AccountProfilePictureResponse? _userProfilePicture; + private bool _searchbarVisible; + private string _searchbarText = string.Empty; + #endregion @@ -108,6 +112,19 @@ public partial class MainLayout : LayoutComponentBase #endregion + #region Search + + private void SearchStart() + { + if (!string.IsNullOrWhiteSpace(_searchbarText)) + { + string query = WebUtility.UrlEncode(_searchbarText); + NavigationManager.NavigateTo($"/search/{query}"); + } + } + + #endregion + #region User menu private async Task UserMenuLogOut() diff --git a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor.css b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor.css index 443c860..9a467a1 100644 --- a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor.css +++ b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor.css @@ -10,4 +10,9 @@ h1 { #logo { font-size: 40px; +} + +#searchbarCancel { + cursor: pointer; + color: #6c757d; } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/wwwroot/assets/icons/cancel.png b/WatchIt.Website/WatchIt.Website/wwwroot/assets/icons/cancel.png new file mode 100644 index 0000000000000000000000000000000000000000..68a9cba1f6c158cf3d64d65037787f187100eca5 GIT binary patch literal 581 zcmeAS@N?(olHy`uVBq!ia0vp^DIm< zXBI`vQ=4YYL;|IpKQ@?juQFzw-;jS``clsW=?~Zowu>D3ajrOB(H;GVjK8OE&3kG1?p5~V z~JJ()=^_s=m11#%vcOB%6xjcK?7Dkq} zPh-7ra4=mHxLTdZk@O^o2Z#lda_+6TyEafjnVr?JC;**$<<0hbrv2{yA3s$et5i?b zc6(nP+!_!DREfZO63=6AaS62&AIMBD*P~| z@L+6oV3UE{qL`K0cIOYo$6HD$2gcpho&V*b=gET-os)isUYa}oh$2wb=)X+jb5Bm7 zAkd&$a;lukGi6l;lcT1j^t=qvO7Lk8;#_R&<=V4NW2)h;g(U|vnjd)^bk=Y_bAOP% z)Bo~Qb=CK#8>Iui5_4Qm9<^u;5_-(yWp_+)$|VW+fL94J3v5abSU9Zw{$9(iFkCKt i#bci|B(UwwZGCZJUFU?JyY;|y!QkoY=d#Wzp$P!&O7my{ literal 0 HcmV?d00001