Files
IGP-Fan-Reference/Pages/Dialog/GlossaryDialogComponent.razor
T

249 lines
6.3 KiB
Plaintext

@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">
&#8592;
</button>
}
<div class="dialogTitle">@term.Term</div>
</div>
<div class="dialogHeaderRight">
<span class="glossaryCategory">@term.Category</span>
<button class="dialogCloseBtn" @onclick="CloseDialog">&times;</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);
}
}