Agent code and restructuring
This commit is contained in:
@@ -0,0 +1,140 @@
|
||||
@implements IDisposable;
|
||||
@inject IMyDialogService MyDialogService
|
||||
@inject IJSRuntime JsRuntime
|
||||
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
@if (MyDialogService.IsVisible)
|
||||
{
|
||||
<div class="dialogOverlay" onclick="@CloseDialog">
|
||||
<div class="dialogContainer dialogConfirm"
|
||||
@onclick:preventDefault="true"
|
||||
@onclick:stopPropagation="true">
|
||||
|
||||
<div class="dialogHeader">
|
||||
<div class="dialogTitle">@MyDialogService.GetDialogContents().Title</div>
|
||||
<button class="dialogCloseBtn" @onclick="CloseDialog">×</button>
|
||||
</div>
|
||||
|
||||
<div class="dialogBody">
|
||||
@MyDialogService.GetDialogContents().Message
|
||||
</div>
|
||||
|
||||
<div class="dialogFooter">
|
||||
<ButtonComponent MyButtonType="MyButtonType.Secondary"
|
||||
OnClick="MyDialogService.GetDialogContents().OnCancel">
|
||||
Cancel
|
||||
</ButtonComponent>
|
||||
<ButtonComponent MyButtonType="MyButtonType.Primary"
|
||||
OnClick="MyDialogService.GetDialogContents().OnConfirm">
|
||||
@MyDialogService.GetDialogContents().ConfirmButtonLabel
|
||||
</ButtonComponent>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.dialogOverlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: rgba(0, 0, 0, 0.6);
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
padding-top: 64px;
|
||||
}
|
||||
|
||||
.dialogContainer {
|
||||
background-color: var(--paper);
|
||||
border-radius: var(--dialog-radius);
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: calc(100vh - 128px);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.dialogConfirm {
|
||||
width: 480px;
|
||||
}
|
||||
|
||||
.dialogHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid var(--paper-border);
|
||||
background-color: var(--accent);
|
||||
border-radius: var(--dialog-radius) var(--dialog-radius) 0 0;
|
||||
min-height: 56px;
|
||||
}
|
||||
|
||||
.dialogTitle {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.dialogCloseBtn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
font-size: 1.5rem;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
line-height: 1;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 6px;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
|
||||
.dialogCloseBtn:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.dialogBody {
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
color: var(--text-primary, #ddd);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.dialogFooter {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
justify-content: flex-end;
|
||||
padding: 16px 20px;
|
||||
border-top: 1px solid var(--paper-border);
|
||||
background-color: var(--background);
|
||||
border-radius: 0 0 var(--dialog-radius) var(--dialog-radius);
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
@code {
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
MyDialogService.Subscribe(() => InvokeAsync(StateHasChanged));
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
MyDialogService.Unsubscribe(() => InvokeAsync(StateHasChanged));
|
||||
}
|
||||
|
||||
public void CloseDialog()
|
||||
{
|
||||
MyDialogService.Hide();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
@implements IDisposable;
|
||||
@inject IEntityDialogService entityDialogService
|
||||
|
||||
<div class="dialogOverlay" onclick="@CloseDialog">
|
||||
<div class="dialogContainer entityDialog"
|
||||
@onclick:preventDefault="true"
|
||||
@onclick:stopPropagation="true">
|
||||
@if (entity == null)
|
||||
{
|
||||
<div class="dialogBody">Entity is null</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="dialogHeader">
|
||||
<div class="dialogHeaderLeft">
|
||||
@if (entityDialogService.HasHistory())
|
||||
{
|
||||
<button class="dialogBackBtn" @onclick="entityDialogService.BackDialog" title="Back">
|
||||
←
|
||||
</button>
|
||||
}
|
||||
<div class="dialogTitle">@entity.Info().Name</div>
|
||||
</div>
|
||||
<button class="dialogCloseBtn" @onclick="CloseDialog">×</button>
|
||||
</div>
|
||||
|
||||
<div class="dialogBody">
|
||||
<CascadingValue Value="@entity">
|
||||
<EntityVanguardAddedComponent/>
|
||||
<EntityInfoComponent/>
|
||||
<EntityVanguardsComponent/>
|
||||
<EntityProductionComponent/>
|
||||
<EntityStatsComponent/>
|
||||
<EntityMechanicsComponent/>
|
||||
<EntityPassivesComponent/>
|
||||
<EntityPyreSpellsComponent/>
|
||||
<EntityUpgradesComponent/>
|
||||
<EntityWeaponsComponent/>
|
||||
<EntityAbilitiesComponent/>
|
||||
</CascadingValue>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.dialogOverlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: rgba(0, 0, 0, 0.6);
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
padding-top: 64px;
|
||||
}
|
||||
|
||||
.dialogContainer {
|
||||
background-color: var(--paper);
|
||||
border-radius: var(--dialog-radius);
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: calc(100vh - 128px);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.entityDialog {
|
||||
width: 800px;
|
||||
max-width: calc(100% - 32px);
|
||||
}
|
||||
|
||||
.dialogHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid var(--paper-border);
|
||||
background-color: var(--accent);
|
||||
border-radius: var(--dialog-radius) var(--dialog-radius) 0 0;
|
||||
min-height: 52px;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.dialogHeaderLeft {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.dialogBackBtn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
font-size: 1.4rem;
|
||||
cursor: pointer;
|
||||
padding: 4px 8px;
|
||||
line-height: 1;
|
||||
border-radius: 6px;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
|
||||
.dialogBackBtn:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.dialogTitle {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: white;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.dialogCloseBtn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
font-size: 1.5rem;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
line-height: 1;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 6px;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
|
||||
.dialogCloseBtn:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.dialogBody {
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
color: var(--text-primary, #ddd);
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
EntityModel entity = default!;
|
||||
|
||||
private int refresh;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
entity = EntityData.Get()[entityDialogService.GetEntityId() ?? string.Empty];
|
||||
entityDialogService.Subscribe(OnUpdate);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
entityDialogService.Unsubscribe(OnUpdate);
|
||||
}
|
||||
|
||||
void OnUpdate()
|
||||
{
|
||||
entity = EntityData.Get()[entityDialogService.GetEntityId() ?? string.Empty];
|
||||
refresh++;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
public void CloseDialog()
|
||||
{
|
||||
entityDialogService.CloseDialog();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
@implements IDisposable;
|
||||
@inject IGlossaryService glossaryService
|
||||
@inject IGlossaryDialogService glossaryDialogService
|
||||
|
||||
<div class="dialogOverlay" onclick="@CloseDialog">
|
||||
<div class="dialogContainer glossaryDialog"
|
||||
@onclick:preventDefault="true"
|
||||
@onclick:stopPropagation="true">
|
||||
|
||||
@if (term == null)
|
||||
{
|
||||
<div class="dialogBody">Term is null</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="dialogHeader">
|
||||
<div class="dialogHeaderLeft">
|
||||
@if (glossaryDialogService.HasHistory())
|
||||
{
|
||||
<button class="dialogBackBtn" @onclick="glossaryDialogService.BackDialog" title="Back">
|
||||
←
|
||||
</button>
|
||||
}
|
||||
<div class="dialogTitle">@term.Term</div>
|
||||
</div>
|
||||
<div class="dialogHeaderRight">
|
||||
<span class="glossaryCategory">@term.Category</span>
|
||||
<button class="dialogCloseBtn" @onclick="CloseDialog">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dialogBody">
|
||||
<div class="glossaryDefinition">@((MarkupString)RenderMarkdown(term.LongDefinition))</div>
|
||||
|
||||
@if (term.RelatedEntityIds.Count > 0)
|
||||
{
|
||||
<div class="glossaryRelatedSection">
|
||||
<div class="glossaryRelatedTitle">Related Entities</div>
|
||||
<div class="glossaryRelatedList">
|
||||
@foreach (var entityId in term.RelatedEntityIds)
|
||||
{
|
||||
<EntityLabelComponent EntityId="@entityId"/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (term.RelatedTermIds.Count > 0)
|
||||
{
|
||||
<div class="glossaryRelatedSection">
|
||||
<div class="glossaryRelatedTitle">Related Terms</div>
|
||||
<div class="glossaryRelatedList">
|
||||
@foreach (var relatedId in term.RelatedTermIds)
|
||||
{
|
||||
<GlossaryLabelComponent TermId="@relatedId"/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.dialogOverlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: rgba(0, 0, 0, 0.6);
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
padding-top: 64px;
|
||||
}
|
||||
|
||||
.dialogContainer {
|
||||
background-color: var(--paper);
|
||||
border-radius: var(--dialog-radius);
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: calc(100vh - 128px);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.glossaryDialog {
|
||||
max-width: 600px;
|
||||
width: calc(100% - 32px);
|
||||
}
|
||||
|
||||
.dialogHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid var(--paper-border);
|
||||
background-color: var(--accent);
|
||||
border-radius: var(--dialog-radius) var(--dialog-radius) 0 0;
|
||||
min-height: 52px;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.dialogHeaderLeft {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.dialogHeaderRight {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.dialogBackBtn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
font-size: 1.4rem;
|
||||
cursor: pointer;
|
||||
padding: 4px 8px;
|
||||
line-height: 1;
|
||||
border-radius: 6px;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
|
||||
.dialogBackBtn:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.dialogTitle {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: white;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.dialogCloseBtn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
font-size: 1.5rem;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
line-height: 1;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 6px;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
|
||||
.dialogCloseBtn:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.glossaryCategory {
|
||||
font-size: 0.75rem;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.dialogBody {
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
color: var(--text-primary, #ddd);
|
||||
}
|
||||
|
||||
.glossaryDefinition {
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.glossaryDefinition p {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.glossaryRelatedSection {
|
||||
margin-top: 24px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid var(--info-secondary-border);
|
||||
}
|
||||
|
||||
.glossaryRelatedTitle {
|
||||
font-weight: 700;
|
||||
font-size: 0.95rem;
|
||||
margin-bottom: 8px;
|
||||
color: var(--text-primary, #ddd);
|
||||
}
|
||||
|
||||
.glossaryRelatedList {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
private GlossaryTermModel? term;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
glossaryDialogService.Subscribe(OnUpdate);
|
||||
LoadTerm();
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
glossaryDialogService.Unsubscribe(OnUpdate);
|
||||
}
|
||||
|
||||
void OnUpdate()
|
||||
{
|
||||
LoadTerm();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
void LoadTerm()
|
||||
{
|
||||
var id = glossaryDialogService.GetTermId();
|
||||
term = id != null ? glossaryService.GetTerm(id) : null;
|
||||
}
|
||||
|
||||
void CloseDialog()
|
||||
{
|
||||
glossaryDialogService.CloseDialog();
|
||||
}
|
||||
|
||||
string RenderMarkdown(string text)
|
||||
{
|
||||
return Markdown.ToHtml(text);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
@implements IDisposable;
|
||||
@inject ISearchService searchService
|
||||
@inject IJSRuntime jsRuntime
|
||||
|
||||
@inject NavigationManager navigationManager
|
||||
|
||||
@if (searchService.IsLoaded() && searchService.IsVisible)
|
||||
{
|
||||
<div class="dialogOverlay" onclick="@CloseDialog">
|
||||
<div class="dialogContainer searchDialog"
|
||||
@onclick:preventDefault="true"
|
||||
@onclick:stopPropagation="true">
|
||||
|
||||
<div class="dialogHeader">
|
||||
<div class="dialogTitle">Search</div>
|
||||
<button class="dialogCloseBtn" @onclick="CloseDialog">×</button>
|
||||
</div>
|
||||
|
||||
<div class="dialogBody">
|
||||
<div class="searchInputWrapper">
|
||||
<FormTextComponent OnFocus="OnFocus" Id="searchInput" Placeholder="Type to search..."
|
||||
OnInput="SearchChanged"></FormTextComponent>
|
||||
</div>
|
||||
|
||||
<div class="searchResults">
|
||||
@if (SearchText.Length > 0)
|
||||
{
|
||||
foreach (var searchSection in searchService.Searches)
|
||||
{
|
||||
var searchPoints = searchSection.Value.FindAll(x => x.Title.ToLower().Contains(SearchText.ToLower()));
|
||||
|
||||
if (searchPoints.Count > 0)
|
||||
{
|
||||
<div class="searchSection">
|
||||
<div class="searchSectionTitle">@searchSection.Key</div>
|
||||
<div class="searchSectionItems">
|
||||
@foreach (var searchPoint in searchPoints)
|
||||
{
|
||||
<button class="searchItem @searchPoint.PointType.ToLower()"
|
||||
@onclick="() => OnSearch(searchPoint)">
|
||||
<span class="searchItemTitle">@searchPoint.Title</span>
|
||||
@if (!string.IsNullOrWhiteSpace(searchPoint.Summary))
|
||||
{
|
||||
<span class="searchItemSummary"> - @searchPoint.Summary</span>
|
||||
}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.dialogOverlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: rgba(0, 0, 0, 0.6);
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
padding-top: 64px;
|
||||
}
|
||||
|
||||
.dialogContainer {
|
||||
background-color: var(--paper);
|
||||
border-radius: var(--dialog-radius);
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: calc(100vh - 128px);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.searchDialog {
|
||||
width: 600px;
|
||||
max-width: calc(100% - 32px);
|
||||
}
|
||||
|
||||
.dialogHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 20px;
|
||||
border-bottom: 1px solid var(--paper-border);
|
||||
background-color: var(--accent);
|
||||
border-radius: var(--dialog-radius) var(--dialog-radius) 0 0;
|
||||
min-height: 52px;
|
||||
}
|
||||
|
||||
.dialogTitle {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.dialogCloseBtn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
font-size: 1.5rem;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
line-height: 1;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 6px;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
|
||||
.dialogCloseBtn:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.dialogBody {
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.searchInputWrapper {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.searchResults {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.searchSection {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.searchSectionTitle {
|
||||
font-weight: 700;
|
||||
font-size: 0.85rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: var(--info-secondary-border);
|
||||
margin-bottom: 8px;
|
||||
padding-bottom: 4px;
|
||||
border-bottom: 1px solid var(--paper-border);
|
||||
}
|
||||
|
||||
.searchSectionItems {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.searchItem {
|
||||
display: block;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
padding: 8px 12px;
|
||||
color: var(--text-primary, #ddd);
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
.searchItem:hover {
|
||||
background: var(--paper-hover);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.searchItemTitle {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.searchItemSummary {
|
||||
color: var(--info-secondary-border);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
@code {
|
||||
private string SearchText { get; set; } = "";
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
searchService.Subscribe(OnSearchChanged);
|
||||
|
||||
timer = new Timer(200);
|
||||
timer.Elapsed += FocusTimer;
|
||||
timer.Enabled = false;
|
||||
}
|
||||
|
||||
private void FocusTimer(object? sender, ElapsedEventArgs e)
|
||||
{
|
||||
jsRuntime.InvokeVoidAsync("SetFocusToElement", "searchInput");
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private Timer timer = null!;
|
||||
|
||||
private void OnSearchChanged()
|
||||
{
|
||||
if (timer.Enabled != searchService.IsVisible)
|
||||
{
|
||||
timer.Enabled = searchService.IsVisible;
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
searchService.Unsubscribe(OnSearchChanged);
|
||||
timer.Elapsed -= FocusTimer;
|
||||
}
|
||||
|
||||
public void CloseDialog()
|
||||
{
|
||||
searchService.Hide();
|
||||
}
|
||||
|
||||
public void NavigateTo(string url)
|
||||
{
|
||||
if (url.Contains("#"))
|
||||
{
|
||||
navigationManager.NavigateTo(url,
|
||||
navigationManager.Uri.Split("#").First().Contains(url.Split("#").First()));
|
||||
}
|
||||
else
|
||||
{
|
||||
navigationManager.NavigateTo(url);
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchChanged(ChangeEventArgs obj)
|
||||
{
|
||||
SearchText = obj.Value!.ToString()!;
|
||||
}
|
||||
|
||||
private void OnSearch(SearchPointModel searchPoint)
|
||||
{
|
||||
NavigateTo(searchPoint.Href);
|
||||
searchService.Hide();
|
||||
}
|
||||
|
||||
private void OnFocus(object obj)
|
||||
{
|
||||
timer.Enabled = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user