Files
IGP-Fan-Reference/Pages/Dialog/EntityDialogComponent.razor
T
2026-06-04 14:08:20 -04:00

180 lines
4.6 KiB
Plaintext

@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">
&#8592;
</button>
}
<div class="dialogTitle">@entity.Info().Name</div>
</div>
<button class="dialogCloseBtn" @onclick="CloseDialog">&times;</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();
}
}