search bar finished

This commit is contained in:
2024-09-29 15:47:11 +02:00
Unverified
parent b449135896
commit a0cbded0d7
6 changed files with 41 additions and 3 deletions

View File

@@ -66,7 +66,7 @@ public abstract class QueryParameters
( (
!string.IsNullOrEmpty(property) !string.IsNullOrEmpty(property)
&& &&
new Regex(regexQuery).IsMatch(property) Regex.IsMatch(property, regexQuery, RegexOptions.IgnoreCase)
) )
); );

View File

@@ -11,7 +11,7 @@
<!-- CSS --> <!-- CSS -->
<link rel="stylesheet" href="css/general.css?version=0.2.0.3"/> <link rel="stylesheet" href="css/general.css?version=0.2.0.3"/>
<link rel="stylesheet" href="css/main_button.css?version=0.2.0.0"/> <link rel="stylesheet" href="css/main_button.css?version=0.2.0.0"/>
<link rel="stylesheet" href="WatchIt.Website.styles.css?version=0.2.0.9"/> <link rel="stylesheet" href="WatchIt.Website.styles.css?version=0.2.0.11"/>
<!-- BOOTSTRAP --> <!-- BOOTSTRAP -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>

View File

@@ -20,7 +20,23 @@
</a> </a>
</div> </div>
<div class="col-auto"> <div class="col-auto">
menu <div class="d-flex gap-2 align-items-center">
@if (_searchbarVisible)
{
<div class="input-group input-group-sm">
<InputText class="form-control" placeholder="Search with regex" @bind-Value="@(_searchbarText)"/>
</div>
<button type="button" class="btn btn-sm btn-outline-secondary" @onclick="@(SearchStart)">⌕</button>
<a id="searchbarCancel" @onclick="@(() => _searchbarVisible = false)">
<img src="assets/icons/cancel.png" alt="cancel_icon" height="20" width="20"/>
</a>
}
else
{
<button type="button" class="btn btn-sm">Rankings</button>
<button type="button" class="btn btn-sm" @onclick="@(() => _searchbarVisible = true)">⌕</button>
}
</div>
</div> </div>
<div class="col"> <div class="col">
<div class="float-end"> <div class="float-end">

View File

@@ -1,3 +1,4 @@
using System.Net;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using WatchIt.Common.Model.Accounts; using WatchIt.Common.Model.Accounts;
using WatchIt.Common.Model.Photos; using WatchIt.Common.Model.Photos;
@@ -33,6 +34,9 @@ public partial class MainLayout : LayoutComponentBase
private PhotoResponse? _defaultBackgroundPhoto; private PhotoResponse? _defaultBackgroundPhoto;
private AccountProfilePictureResponse? _userProfilePicture; private AccountProfilePictureResponse? _userProfilePicture;
private bool _searchbarVisible;
private string _searchbarText = string.Empty;
#endregion #endregion
@@ -108,6 +112,19 @@ public partial class MainLayout : LayoutComponentBase
#endregion #endregion
#region Search
private void SearchStart()
{
if (!string.IsNullOrWhiteSpace(_searchbarText))
{
string query = WebUtility.UrlEncode(_searchbarText);
NavigationManager.NavigateTo($"/search/{query}");
}
}
#endregion
#region User menu #region User menu
private async Task UserMenuLogOut() private async Task UserMenuLogOut()

View File

@@ -10,4 +10,9 @@ h1 {
#logo { #logo {
font-size: 40px; font-size: 40px;
}
#searchbarCancel {
cursor: pointer;
color: #6c757d;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 B