feat(Search) Search hotkey now working. CMD + K
This commit is contained in:
@@ -15,24 +15,24 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<SupportedPlatform Include="browser" />
|
||||
<SupportedPlatform Include="browser"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Markdig" Version="0.28.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.0-preview.2.22153.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="7.0.0-preview.2.22153.2" />
|
||||
<PackageReference Include="Markdig" Version="0.28.1"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.0-preview.2.22153.2"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="7.0.0-preview.2.22153.2"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Inputs\" />
|
||||
<Folder Include="Inputs\"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Model\Model.csproj" />
|
||||
<ProjectReference Include="..\Services\Services.csproj" />
|
||||
<ProjectReference Include="..\Model\Model.csproj"/>
|
||||
<ProjectReference Include="..\Services\Services.csproj"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Inputs\" />
|
||||
<None Remove="Inputs\"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -48,25 +48,25 @@
|
||||
|
||||
void OnInputChanged(ChangeEventArgs changeEventArgs)
|
||||
{
|
||||
int valueWas = Value;
|
||||
int newValue = int.Parse(changeEventArgs.Value!.ToString()!);
|
||||
|
||||
if (newValue > Max)
|
||||
{
|
||||
newValue = Max;
|
||||
}
|
||||
|
||||
if (newValue < Min)
|
||||
{
|
||||
newValue = Min;
|
||||
}
|
||||
var valueWas = Value;
|
||||
var newValue = int.Parse(changeEventArgs.Value!.ToString()!);
|
||||
|
||||
if (valueWas != newValue)
|
||||
{
|
||||
Value = newValue;
|
||||
changeEventArgs.Value = newValue;
|
||||
OnChange.InvokeAsync(changeEventArgs);
|
||||
}
|
||||
if (newValue > Max)
|
||||
{
|
||||
newValue = Max;
|
||||
}
|
||||
|
||||
if (newValue < Min)
|
||||
{
|
||||
newValue = Min;
|
||||
}
|
||||
|
||||
if (valueWas != newValue)
|
||||
{
|
||||
Value = newValue;
|
||||
changeEventArgs.Value = newValue;
|
||||
OnChange.InvokeAsync(changeEventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
placeholder="@Placeholder"
|
||||
type="text"
|
||||
value="@Value"
|
||||
id="@labelId"
|
||||
id="@Id"
|
||||
@oninput="OnChange"
|
||||
@onchange="OnChange"/>
|
||||
</div>
|
||||
@@ -51,6 +51,9 @@
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public string Id { get; set; } = "";
|
||||
|
||||
[Parameter]
|
||||
public string Label { get; set; } = "";
|
||||
|
||||
@@ -62,7 +65,7 @@
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<ChangeEventArgs> OnChange { get; set; }
|
||||
|
||||
|
||||
|
||||
[Parameter]
|
||||
public bool ReadOnly { get; set; }
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
@using System.Runtime.InteropServices
|
||||
@inject ISearchService searchService
|
||||
@inject ISearchService searchService
|
||||
@inject NavigationManager navigationManager
|
||||
@inject IJSRuntime jsRuntime
|
||||
|
||||
@@ -7,13 +6,9 @@
|
||||
<div class="searchText">
|
||||
Search...
|
||||
</div>
|
||||
@if (false)
|
||||
{
|
||||
<div class="searchHotkey">
|
||||
@CommandKey + K
|
||||
</div>
|
||||
|
||||
}
|
||||
<div class="searchHotkey">
|
||||
@CommandKey + K
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<style>
|
||||
@@ -35,6 +30,7 @@
|
||||
.searchHotkey {
|
||||
padding: 2px;
|
||||
|
||||
background-color: var(--info);
|
||||
border: 2px solid var(--primary-border);
|
||||
}
|
||||
|
||||
@@ -42,20 +38,22 @@
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public RenderFragment ChildContent { get; set; } = default!;
|
||||
|
||||
private string userAgent = "";
|
||||
|
||||
string CommandKey => userAgent.Contains("Mac OS") ? "CMD" : "Ctrl";
|
||||
|
||||
|
||||
private void ButtonClicked(EventArgs eventArgs)
|
||||
{
|
||||
searchService.Show();
|
||||
}
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
userAgent = await jsRuntime.InvokeAsync<string>("getUserAgent");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,31 +17,31 @@
|
||||
</NavLink>
|
||||
|
||||
<div class="sectionNavs">
|
||||
@foreach (var webSection in WebSections)
|
||||
{
|
||||
var isSelected = navigationService.GetNavigationSectionId().Equals(webSection.Id);
|
||||
var sectionButtonStyle = "sectionButton";
|
||||
if (isSelected)
|
||||
@foreach (var webSection in WebSections)
|
||||
{
|
||||
sectionButtonStyle += " sectionButtonSelected";
|
||||
}
|
||||
|
||||
<div class="sectionNav">
|
||||
<button onclick="@(() => { MenuClicked(webSection.Id); })" class="@sectionButtonStyle">@webSection.Name</button>
|
||||
|
||||
@if (isSelected)
|
||||
var isSelected = navigationService.GetNavigationSectionId().Equals(webSection.Id);
|
||||
var sectionButtonStyle = "sectionButton";
|
||||
if (isSelected)
|
||||
{
|
||||
<div class="navMenuPosition">
|
||||
<div class="navMenuContainer">
|
||||
<DesktopNavSectionComponent Section=webSection />
|
||||
</div>
|
||||
</div>
|
||||
sectionButtonStyle += " sectionButtonSelected";
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="sectionNav">
|
||||
<button onclick="@(() => { MenuClicked(webSection.Id); })" class="@sectionButtonStyle">@webSection.Name</button>
|
||||
|
||||
@if (isSelected)
|
||||
{
|
||||
<div class="navMenuPosition">
|
||||
<div class="navMenuContainer">
|
||||
<DesktopNavSectionComponent Section=webSection/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<SearchButtonComponent />
|
||||
|
||||
<SearchButtonComponent/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<NavLink @onclick="() => {
|
||||
navigationService.ChangeNavigationState(NavigationStateType.Default);
|
||||
navigationService.ChangeNavigationSectionId(-1); }" href="@Page.Href" class="desktopNavLink">
|
||||
<NavLink @onclick="() => { navigationService.ChangeNavigationState(NavigationStateType.Default); navigationService.ChangeNavigationSectionId(-1); }" href="@Page.Href" class="desktopNavLink">
|
||||
<div class="navName">
|
||||
@Page.Name
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user