Test
This commit is contained in:
@@ -0,0 +1,454 @@
|
||||
@using System.Text.RegularExpressions
|
||||
@using Microsoft.AspNetCore.Components.Rendering
|
||||
@namespace Chrono.Components
|
||||
|
||||
@if (Card != null)
|
||||
{
|
||||
<div class="modal-backdrop" @onclick="HandleBackdropClick"></div>
|
||||
<div class="card-detail @(!HasImage ? "card-detail-noimg" : "")">
|
||||
<button class="detail-close" @onclick="HandleClose"><i class="bi bi-x-lg"></i></button>
|
||||
<div class="detail-layout @(!HasImage ? "layout-noimg" : "")">
|
||||
@if (HasImage)
|
||||
{
|
||||
<div class="detail-image">
|
||||
<img src="@Card.ImagePath" alt="@Card.Name"
|
||||
onerror="this.src='@Card.SmallImagePath';this.onerror=null;"/>
|
||||
</div>
|
||||
}
|
||||
<div class="detail-info">
|
||||
<div class="detail-header">
|
||||
<h2>@Card.Name</h2>
|
||||
<div class="detail-meta">
|
||||
<span class="meta-badge category @Card.Category?.ToLowerInvariant()">@Card.Category</span>
|
||||
@if (Card.Cost.HasValue)
|
||||
{
|
||||
<span class="meta-badge cost"><i class="bi bi-lightning-fill"></i> @Card.Cost</span>
|
||||
}
|
||||
@if (Card.Attack.HasValue)
|
||||
{
|
||||
<span class="meta-badge attack"><i class="bi bi-crosshair"></i> @Card.Attack</span>
|
||||
}
|
||||
@if (Card.Health.HasValue)
|
||||
{
|
||||
<span class="meta-badge health"><i class="bi bi-heart-fill"></i> @Card.Health</span>
|
||||
}
|
||||
@if (Card.Speed != null)
|
||||
{
|
||||
<span class="meta-badge speed"><i class="bi bi-wind"></i> @Card.Speed</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (Card.Syndicate != null)
|
||||
{
|
||||
<div class="detail-field">
|
||||
<span class="field-label"><i class="bi bi-diagram-3-fill"></i> Syndicate</span>
|
||||
<span class="field-value">@Card.Syndicate</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (Card.Description != null)
|
||||
{
|
||||
<div class="detail-field description">
|
||||
<span class="field-label"><i class="bi bi-chat-quote-fill"></i></span>
|
||||
<div class="markdown-content">
|
||||
@RenderDescription(Card.Description)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (Card.Set != null)
|
||||
{
|
||||
<div class="detail-field">
|
||||
<span class="field-label"><i class="bi bi-collection"></i> Set</span>
|
||||
<span class="field-value">@Card.Set</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (Card.Archetypes is { Count: > 0 })
|
||||
{
|
||||
<div class="detail-field">
|
||||
<span class="field-label"><i class="bi bi-layers-fill"></i> Archetypes</span>
|
||||
<span class="field-value">@string.Join(", ", Card.Archetypes)</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (Card.ImmortalizeWhen != null)
|
||||
{
|
||||
<div class="detail-field">
|
||||
<span class="field-label"><i class="bi bi-star-fill"></i> Immortalize When</span>
|
||||
<span class="field-value">@Card.ImmortalizeWhen</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (Card.HasImmortalize)
|
||||
{
|
||||
<div class="detail-field">
|
||||
<span class="field-label"><i class="bi bi-arrow-right-circle-fill"></i> Immortalizes To</span>
|
||||
<span class="field-value">
|
||||
@foreach (var name in Card.ImmortalizeTo!)
|
||||
{
|
||||
var targetName = name;
|
||||
var target = LookupCard(targetName);
|
||||
if (target != null)
|
||||
{
|
||||
<button class="inline-card-btn"
|
||||
@onclick="() => Navigate(targetName)">@targetName</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
@targetName
|
||||
}
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (Card.ImmortalizeFrom != null)
|
||||
{
|
||||
<div class="detail-field">
|
||||
<span class="field-label"><i class="bi bi-arrow-left-circle-fill"></i> Immortalizes From</span>
|
||||
<span class="field-value">
|
||||
@{
|
||||
var fromCard = LookupCard(Card.ImmortalizeFrom);
|
||||
if (fromCard != null)
|
||||
{
|
||||
<button class="inline-card-btn"
|
||||
@onclick="() => Navigate(Card.ImmortalizeFrom)">@Card.ImmortalizeFrom</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
@Card.ImmortalizeFrom
|
||||
}
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (ShowNotes && Card.IsAgent)
|
||||
{
|
||||
<div class="detail-field note">
|
||||
<span class="field-label"><i class="bi bi-pencil-fill"></i> Personal Note</span>
|
||||
<textarea class="form-control note-input" @bind="currentNote" @onblur="SaveNote"
|
||||
placeholder="Add a private note about this agent..."></textarea>
|
||||
@if (isSaving)
|
||||
{
|
||||
<span class="saving-indicator">Saving...</span>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public CardData? Card { get; set; }
|
||||
[Parameter] public EventCallback OnClose { get; set; }
|
||||
[Parameter] public EventCallback<string> OnNavigate { get; set; }
|
||||
[Parameter] public bool ShowNotes { get; set; }
|
||||
|
||||
[Inject] private HttpClient Http { get; set; } = default!;
|
||||
|
||||
private bool HasImage => Card?.ImageFile is { Length: > 0 } && Card.ImageFile != "placeholder.png";
|
||||
|
||||
private string currentNote = "";
|
||||
private bool isSaving;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (Card != null && Card.IsAgent)
|
||||
{
|
||||
currentNote = "";
|
||||
_ = LoadNote();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadNote()
|
||||
{
|
||||
if (Card == null || !Card.IsAgent) return;
|
||||
try
|
||||
{
|
||||
var note = await Http.GetFromJsonAsync<CardNote>($"api/notes/{Uri.EscapeDataString(Card.Name)}");
|
||||
currentNote = note?.Note ?? "";
|
||||
}
|
||||
catch
|
||||
{
|
||||
currentNote = "";
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveNote()
|
||||
{
|
||||
if (Card == null || !Card.IsAgent) return;
|
||||
|
||||
isSaving = true;
|
||||
try
|
||||
{
|
||||
await Http.PostAsJsonAsync("api/notes", new CardNote { CardName = Card.Name, Note = currentNote });
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
isSaving = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleClose()
|
||||
{
|
||||
_ = OnClose.InvokeAsync();
|
||||
}
|
||||
|
||||
private void HandleBackdropClick()
|
||||
{
|
||||
_ = OnClose.InvokeAsync();
|
||||
}
|
||||
|
||||
private void Navigate(string name)
|
||||
{
|
||||
var card = LookupCard(name);
|
||||
if (card != null)
|
||||
{
|
||||
Card = card;
|
||||
_ = LoadNote();
|
||||
StateHasChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = OnNavigate.InvokeAsync(name);
|
||||
}
|
||||
}
|
||||
|
||||
private static CardData? LookupCard(string cardName)
|
||||
{
|
||||
return CardDatabase.Cards.FirstOrDefault(c =>
|
||||
string.Equals(c.Name, cardName, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
private static DocData? LookupDoc(string title)
|
||||
{
|
||||
return DocDatabase.Docs.FirstOrDefault(d =>
|
||||
string.Equals(d.Title, title, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
private RenderFragment RenderDescription(string content)
|
||||
{
|
||||
return builder =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(content)) return;
|
||||
|
||||
var seq = 0;
|
||||
var lines = content.Split(['\r', '\n'], StringSplitOptions.None);
|
||||
var inList = false;
|
||||
var tableLines = new List<string>();
|
||||
var inTable = false;
|
||||
|
||||
for (var i = 0; i < lines.Length; i++)
|
||||
{
|
||||
var line = lines[i];
|
||||
var trimmedLine = line.Trim();
|
||||
|
||||
// Handle Tables
|
||||
if (trimmedLine.StartsWith("|") && trimmedLine.EndsWith("|"))
|
||||
{
|
||||
inTable = true;
|
||||
tableLines.Add(trimmedLine);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inTable)
|
||||
{
|
||||
RenderTable(builder, ref seq, tableLines);
|
||||
tableLines.Clear();
|
||||
inTable = false;
|
||||
}
|
||||
|
||||
// Handle Lists
|
||||
if (trimmedLine.StartsWith("- ") || trimmedLine.StartsWith("* "))
|
||||
{
|
||||
if (!inList)
|
||||
{
|
||||
builder.OpenElement(seq++, "ul");
|
||||
inList = true;
|
||||
}
|
||||
|
||||
var isCardListItem = trimmedLine.Contains("[[") && trimmedLine.Contains("]]");
|
||||
builder.OpenElement(seq++, "li");
|
||||
RenderInlines(builder, ref seq, trimmedLine[2..], true);
|
||||
builder.CloseElement();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inList)
|
||||
{
|
||||
builder.CloseElement(); // Close ul
|
||||
inList = false;
|
||||
}
|
||||
|
||||
// Handle Headings
|
||||
if (trimmedLine.StartsWith("### "))
|
||||
{
|
||||
builder.OpenElement(seq++, "h4");
|
||||
RenderInlines(builder, ref seq, trimmedLine[4..], false);
|
||||
builder.CloseElement();
|
||||
}
|
||||
else if (trimmedLine.StartsWith("## "))
|
||||
{
|
||||
builder.OpenElement(seq++, "h3");
|
||||
RenderInlines(builder, ref seq, trimmedLine[3..], false);
|
||||
builder.CloseElement();
|
||||
}
|
||||
else if (trimmedLine.StartsWith("# "))
|
||||
{
|
||||
builder.OpenElement(seq++, "h2");
|
||||
RenderInlines(builder, ref seq, trimmedLine[2..], false);
|
||||
builder.CloseElement();
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(trimmedLine))
|
||||
{
|
||||
builder.OpenElement(seq++, "p");
|
||||
RenderInlines(builder, ref seq, line, false);
|
||||
builder.CloseElement();
|
||||
}
|
||||
}
|
||||
|
||||
if (inTable) RenderTable(builder, ref seq, tableLines);
|
||||
if (inList) builder.CloseElement();
|
||||
};
|
||||
}
|
||||
|
||||
private void RenderTable(RenderTreeBuilder builder, ref int seq, List<string> lines)
|
||||
{
|
||||
if (lines.Count < 2) return;
|
||||
|
||||
builder.OpenElement(seq++, "div");
|
||||
builder.AddAttribute(seq++, "class", "table-responsive");
|
||||
builder.OpenElement(seq++, "table");
|
||||
builder.AddAttribute(seq++, "class", "markdown-table");
|
||||
|
||||
var hasHeader = lines.Count > 2 && lines[1].Contains("---");
|
||||
var startIdx = 0;
|
||||
|
||||
if (hasHeader)
|
||||
{
|
||||
builder.OpenElement(seq++, "thead");
|
||||
builder.OpenElement(seq++, "tr");
|
||||
var cells = lines[0].Split('|', StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (var cell in cells)
|
||||
{
|
||||
builder.OpenElement(seq++, "th");
|
||||
RenderInlines(builder, ref seq, cell.Trim(), false);
|
||||
builder.CloseElement();
|
||||
}
|
||||
|
||||
builder.CloseElement();
|
||||
builder.CloseElement();
|
||||
startIdx = 2;
|
||||
}
|
||||
|
||||
builder.OpenElement(seq++, "tbody");
|
||||
for (var i = startIdx; i < lines.Count; i++)
|
||||
{
|
||||
if (i == 1 && hasHeader) continue;
|
||||
builder.OpenElement(seq++, "tr");
|
||||
var cells = lines[i].Split('|', StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (var cell in cells)
|
||||
{
|
||||
builder.OpenElement(seq++, "td");
|
||||
RenderInlines(builder, ref seq, cell.Trim(), false);
|
||||
builder.CloseElement();
|
||||
}
|
||||
|
||||
builder.CloseElement();
|
||||
}
|
||||
|
||||
builder.CloseElement();
|
||||
builder.CloseElement();
|
||||
builder.CloseElement();
|
||||
}
|
||||
|
||||
private void RenderInlines(RenderTreeBuilder builder, ref int seq, string text, bool renderAsImage)
|
||||
{
|
||||
var remaining = text;
|
||||
|
||||
while (!string.IsNullOrEmpty(remaining))
|
||||
{
|
||||
var boldMatch = Regex.Match(remaining, @"\*\*(.*?)\*\*");
|
||||
var italicMatch = Regex.Match(remaining, @"\*(.*?)\*");
|
||||
var cardMatch = Regex.Match(remaining, @"\[\[(.*?)\]\]");
|
||||
|
||||
var bestIdx = int.MaxValue;
|
||||
Match? bestMatch = null;
|
||||
var matchType = 0; // 1: bold, 2: italic, 3: card
|
||||
|
||||
if (boldMatch.Success && boldMatch.Index < bestIdx)
|
||||
{
|
||||
bestIdx = boldMatch.Index;
|
||||
bestMatch = boldMatch;
|
||||
matchType = 1;
|
||||
}
|
||||
|
||||
if (italicMatch.Success && italicMatch.Index < bestIdx)
|
||||
{
|
||||
bestIdx = italicMatch.Index;
|
||||
bestMatch = italicMatch;
|
||||
matchType = 2;
|
||||
}
|
||||
|
||||
if (cardMatch.Success && cardMatch.Index < bestIdx)
|
||||
{
|
||||
bestIdx = cardMatch.Index;
|
||||
bestMatch = cardMatch;
|
||||
matchType = 3;
|
||||
}
|
||||
|
||||
if (bestMatch != null)
|
||||
{
|
||||
if (bestIdx > 0)
|
||||
builder.AddContent(seq++, remaining[..bestIdx]);
|
||||
|
||||
var innerText = bestMatch.Groups[1].Value;
|
||||
|
||||
if (matchType == 1) // Bold
|
||||
{
|
||||
builder.OpenElement(seq++, "strong");
|
||||
builder.AddContent(seq++, innerText);
|
||||
builder.CloseElement();
|
||||
}
|
||||
else if (matchType == 2) // Italic
|
||||
{
|
||||
builder.OpenElement(seq++, "em");
|
||||
builder.AddContent(seq++, innerText);
|
||||
builder.CloseElement();
|
||||
}
|
||||
else if (matchType == 3) // Card Link / Doc Link
|
||||
{
|
||||
var card = LookupCard(innerText);
|
||||
var doc = LookupDoc(innerText);
|
||||
if (card != null || doc != null)
|
||||
{
|
||||
builder.OpenElement(seq++, "button");
|
||||
builder.AddAttribute(seq++, "class", "inline-card-btn");
|
||||
builder.AddAttribute(seq++, "onclick", EventCallback.Factory.Create(this, () => Navigate(innerText)));
|
||||
builder.AddContent(seq++, innerText);
|
||||
builder.CloseElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AddContent(seq++, innerText);
|
||||
}
|
||||
}
|
||||
|
||||
remaining = remaining[(bestIdx + bestMatch.Length)..];
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AddContent(seq++, remaining);
|
||||
remaining = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1060;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
backdrop-filter: blur(4px);
|
||||
animation: fade-in 0.2s ease-out;
|
||||
}
|
||||
|
||||
@keyframes fade-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.card-detail {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 1070;
|
||||
background: var(--bg-surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 16px;
|
||||
padding: 0;
|
||||
max-width: 850px;
|
||||
width: 92vw;
|
||||
max-height: 88vh;
|
||||
overflow-y: auto;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
|
||||
color: var(--text-primary);
|
||||
animation: detail-enter 0.25s ease-out;
|
||||
}
|
||||
|
||||
@keyframes detail-enter {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translate(-50%, -50%) scale(0.92);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translate(-50%, -50%) scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
.detail-close {
|
||||
position: absolute;
|
||||
top: 0.75rem;
|
||||
right: 0.75rem;
|
||||
z-index: 1;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
color: var(--text-primary);
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
font-size: 0.8rem;
|
||||
transition: all var(--transition);
|
||||
}
|
||||
|
||||
.detail-close:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
.detail-layout {
|
||||
display: flex;
|
||||
gap: 1.5rem;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.detail-image {
|
||||
flex: 0 0 320px;
|
||||
}
|
||||
|
||||
.detail-image img {
|
||||
width: 100%;
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow);
|
||||
max-height: 80vh;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
/* ── No-image layout ── */
|
||||
.card-detail-noimg {
|
||||
max-width: 460px;
|
||||
}
|
||||
|
||||
.layout-noimg {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.detail-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.detail-header {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.detail-header h2 {
|
||||
margin: 0 0 0.75rem;
|
||||
font-size: 1.4rem;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.detail-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.meta-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
padding: 0.25rem 0.6rem;
|
||||
border-radius: 100px;
|
||||
background: var(--bg-hover);
|
||||
color: var(--text-secondary);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.meta-badge.category.agent,
|
||||
.meta-badge.category.immortalized {
|
||||
background: rgba(79, 195, 247, 0.15);
|
||||
color: #4fc3f7;
|
||||
border-color: rgba(79, 195, 247, 0.3);
|
||||
}
|
||||
|
||||
.meta-badge.category.spell {
|
||||
background: rgba(206, 147, 216, 0.15);
|
||||
color: #ce93d8;
|
||||
border-color: rgba(206, 147, 216, 0.3);
|
||||
}
|
||||
|
||||
.meta-badge.cost {
|
||||
background: rgba(255, 215, 0, 0.12);
|
||||
color: var(--gold);
|
||||
border-color: rgba(255, 215, 0, 0.3);
|
||||
}
|
||||
|
||||
.meta-badge.attack {
|
||||
background: rgba(239, 83, 80, 0.15);
|
||||
color: #ef5350;
|
||||
border-color: rgba(239, 83, 80, 0.3);
|
||||
}
|
||||
|
||||
.meta-badge.health {
|
||||
background: rgba(102, 187, 106, 0.15);
|
||||
color: #66bb6a;
|
||||
border-color: rgba(102, 187, 106, 0.3);
|
||||
}
|
||||
|
||||
.meta-badge.speed {
|
||||
background: rgba(79, 195, 247, 0.12);
|
||||
color: #4fc3f7;
|
||||
border-color: rgba(79, 195, 247, 0.3);
|
||||
}
|
||||
|
||||
.detail-field {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.6rem;
|
||||
font-size: 0.88rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.detail-field.description {
|
||||
padding: 0;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.field-label {
|
||||
flex-shrink: 0;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.8rem;
|
||||
font-weight: 500;
|
||||
min-width: 7.5rem;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.3rem;
|
||||
}
|
||||
|
||||
.detail-field.description .field-label {
|
||||
min-width: auto;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.field-value {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.markdown-content {
|
||||
color: var(--text-primary);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.markdown-content p {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.markdown-content ul {
|
||||
margin-bottom: 0.75rem;
|
||||
padding-left: 1.25rem;
|
||||
}
|
||||
|
||||
.markdown-content li {
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.markdown-content h2, .markdown-content h3, .markdown-content h4 {
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 0.75rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.markdown-content h2 {
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
|
||||
.markdown-content h3 {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.markdown-content h4 {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
margin-bottom: 1rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.markdown-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.markdown-table th, .markdown-table td {
|
||||
padding: 0.5rem;
|
||||
border: 1px solid var(--border);
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.markdown-table th {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
.card-detail::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
.card-detail::-webkit-scrollbar-thumb {
|
||||
background: var(--border);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.inline-card-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
font-weight: 600;
|
||||
color: var(--accent);
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 2px;
|
||||
text-decoration-color: rgba(108, 99, 255, 0.3);
|
||||
transition: color var(--transition), text-decoration-color var(--transition);
|
||||
}
|
||||
|
||||
.inline-card-btn:hover {
|
||||
color: #7b73ff;
|
||||
text-decoration-color: #7b73ff;
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.detail-layout {
|
||||
flex-direction: column;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.detail-image {
|
||||
flex: 0 0 auto;
|
||||
max-width: 180px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.card-detail,
|
||||
.card-detail-noimg {
|
||||
max-height: 90vh;
|
||||
}
|
||||
|
||||
.card-detail-noimg {
|
||||
max-width: 92vw;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
@using System.Text.RegularExpressions
|
||||
@using Microsoft.AspNetCore.Components.Rendering
|
||||
@namespace Chrono.Components
|
||||
|
||||
@if (Doc != null)
|
||||
{
|
||||
<div class="modal-backdrop" @onclick="HandleBackdropClick"></div>
|
||||
<div class="generic-detail">
|
||||
<button class="detail-close" @onclick="HandleClose"><i class="bi bi-x-lg"></i></button>
|
||||
<div class="detail-layout">
|
||||
<div class="detail-info">
|
||||
<div class="detail-header">
|
||||
@if (!string.IsNullOrEmpty(Doc.Category))
|
||||
{
|
||||
<span class="category-badge">@Doc.Category</span>
|
||||
}
|
||||
<h2>@Doc.Title</h2>
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(Doc.Content))
|
||||
{
|
||||
<div class="detail-field description">
|
||||
<div class="markdown-content">
|
||||
@RenderDescription(Doc.Content)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public DocData? Doc { get; set; }
|
||||
[Parameter] public EventCallback OnClose { get; set; }
|
||||
|
||||
private void HandleClose()
|
||||
{
|
||||
_ = OnClose.InvokeAsync();
|
||||
}
|
||||
|
||||
private void HandleBackdropClick()
|
||||
{
|
||||
_ = OnClose.InvokeAsync();
|
||||
}
|
||||
|
||||
private RenderFragment RenderDescription(string content)
|
||||
{
|
||||
return builder =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(content)) return;
|
||||
|
||||
var seq = 0;
|
||||
var lines = content.Split(['\r', '\n'], StringSplitOptions.None);
|
||||
var inList = false;
|
||||
|
||||
for (var i = 0; i < lines.Length; i++)
|
||||
{
|
||||
var line = lines[i];
|
||||
var trimmedLine = line.Trim();
|
||||
|
||||
// Handle Lists
|
||||
if (trimmedLine.StartsWith("- ") || trimmedLine.StartsWith("* "))
|
||||
{
|
||||
if (!inList)
|
||||
{
|
||||
builder.OpenElement(seq++, "ul");
|
||||
inList = true;
|
||||
}
|
||||
|
||||
builder.OpenElement(seq++, "li");
|
||||
RenderInlines(builder, ref seq, trimmedLine[2..]);
|
||||
builder.CloseElement();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inList)
|
||||
{
|
||||
builder.CloseElement();
|
||||
inList = false;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(trimmedLine))
|
||||
{
|
||||
builder.OpenElement(seq++, "p");
|
||||
RenderInlines(builder, ref seq, line);
|
||||
builder.CloseElement();
|
||||
}
|
||||
}
|
||||
|
||||
if (inList) builder.CloseElement();
|
||||
};
|
||||
}
|
||||
|
||||
private void RenderInlines(RenderTreeBuilder builder, ref int seq, string text)
|
||||
{
|
||||
var remaining = text;
|
||||
while (!string.IsNullOrEmpty(remaining))
|
||||
{
|
||||
var boldMatch = Regex.Match(remaining, @"\*\*(.*?)\*\*");
|
||||
var italicMatch = Regex.Match(remaining, @"\*(.*?)\*");
|
||||
|
||||
var bestIdx = int.MaxValue;
|
||||
Match? bestMatch = null;
|
||||
var matchType = 0; // 1: bold, 2: italic
|
||||
|
||||
if (boldMatch.Success && boldMatch.Index < bestIdx)
|
||||
{
|
||||
bestIdx = boldMatch.Index;
|
||||
bestMatch = boldMatch;
|
||||
matchType = 1;
|
||||
}
|
||||
|
||||
if (italicMatch.Success && italicMatch.Index < bestIdx)
|
||||
{
|
||||
bestIdx = italicMatch.Index;
|
||||
bestMatch = italicMatch;
|
||||
matchType = 2;
|
||||
}
|
||||
|
||||
if (bestMatch != null)
|
||||
{
|
||||
if (bestIdx > 0) builder.AddContent(seq++, remaining[..bestIdx]);
|
||||
var innerText = bestMatch.Groups[1].Value;
|
||||
builder.OpenElement(seq++, matchType == 1 ? "strong" : "em");
|
||||
builder.AddContent(seq++, innerText);
|
||||
builder.CloseElement();
|
||||
remaining = remaining[(bestIdx + bestMatch.Length)..];
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AddContent(seq++, remaining);
|
||||
remaining = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1060;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
backdrop-filter: blur(4px);
|
||||
}
|
||||
|
||||
.generic-detail {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 1070;
|
||||
background: var(--bg-surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 20px;
|
||||
padding: 2rem;
|
||||
max-width: 600px;
|
||||
width: 90vw;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.detail-close {
|
||||
position: absolute;
|
||||
top: 1rem;
|
||||
right: 1rem;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
color: var(--text-primary);
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.detail-close:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.detail-header {
|
||||
text-align: center;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.category-badge {
|
||||
display: inline-block;
|
||||
padding: 0.2rem 0.6rem;
|
||||
background: var(--accent);
|
||||
color: white;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 0.5rem;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.detail-header h2 {
|
||||
margin: 0;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.markdown-content {
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.markdown-content p {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
@inherits LayoutComponentBase
|
||||
@inject CardPreviewService PreviewService
|
||||
<div class="page">
|
||||
<div class="sidebar">
|
||||
<NavMenu/>
|
||||
</div>
|
||||
|
||||
<main>
|
||||
<NavigationTracker/>
|
||||
<article class="content px-4">
|
||||
<TelerikRootComponent>
|
||||
@Body
|
||||
<Shared.Components.CardPreview />
|
||||
<Shared.Components.DocDetailModal Doc="@PreviewService.SelectedDoc"
|
||||
OnClose="@(() => PreviewService.SelectDoc(null))" />
|
||||
</TelerikRootComponent>
|
||||
</article>
|
||||
</main>
|
||||
</div>
|
||||
@@ -0,0 +1,77 @@
|
||||
.page {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
main {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
|
||||
}
|
||||
|
||||
.top-row {
|
||||
background-color: #f7f7f7;
|
||||
border-bottom: 1px solid #d6d5d5;
|
||||
justify-content: flex-end;
|
||||
height: 3.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.top-row ::deep a, .top-row ::deep .btn-link {
|
||||
white-space: nowrap;
|
||||
margin-left: 1.5rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.top-row ::deep a:first-child {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
@media (max-width: 640.98px) {
|
||||
.top-row {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.top-row ::deep a, .top-row ::deep .btn-link {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 641px) {
|
||||
.page {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 250px;
|
||||
height: 100vh;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.top-row {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.top-row.auth ::deep a:first-child {
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.top-row, article {
|
||||
padding-left: 2rem !important;
|
||||
padding-right: 1.5rem !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<div class="top-row ps-3 pe-3 navbar navbar-dark">
|
||||
<div class="container-fluid d-flex align-items-center justify-content-between p-0">
|
||||
<a class="navbar-brand" href="">
|
||||
<i class="bi bi-hourglass-split me-2 text-warning"></i> Chrono CCG
|
||||
</a>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<NetworkStatusChip />
|
||||
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="@NavMenuCssClass nav-scrollable" @onclick="ToggleNavMenu">
|
||||
<nav class="nav flex-column">
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="home">
|
||||
<i class="bi bi-house-door-fill nav-icon"></i> Home
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
|
||||
<i class="bi bi-collection-fill nav-icon"></i> Cards
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="agents">
|
||||
<i class="bi bi-people-fill nav-icon"></i> Agents
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="decks">
|
||||
<i class="bi bi-journal-text nav-icon"></i> Decks
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="syndicates">
|
||||
<i class="bi bi-diagram-2-fill nav-icon"></i> Syndicates
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="docs">
|
||||
<i class="bi bi-book-fill nav-icon"></i> Docs
|
||||
</NavLink>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private bool collapseNavMenu = true;
|
||||
|
||||
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
|
||||
|
||||
private void ToggleNavMenu()
|
||||
{
|
||||
collapseNavMenu = !collapseNavMenu;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
.navbar-toggler {
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.top-row {
|
||||
min-height: 3.5rem;
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.nav-icon {
|
||||
margin-right: 0.75rem;
|
||||
font-size: 1.05rem;
|
||||
width: 1.25rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
font-size: 0.9rem;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.nav-item:first-of-type {
|
||||
padding-top: 1rem;
|
||||
}
|
||||
|
||||
.nav-item:last-of-type {
|
||||
padding-bottom: 1rem;
|
||||
}
|
||||
|
||||
.nav-item ::deep a {
|
||||
color: #d7d7d7;
|
||||
border-radius: 4px;
|
||||
height: 3rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
line-height: 3rem;
|
||||
}
|
||||
|
||||
.nav-item ::deep a.active {
|
||||
background-color: rgba(255, 255, 255, 0.37);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.nav-item ::deep a:hover {
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
color: white;
|
||||
}
|
||||
|
||||
@media (min-width: 641px) {
|
||||
.navbar-toggler {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.collapse {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.nav-scrollable {
|
||||
height: calc(100vh - 3.5rem);
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
@inject NetworkStatusService NetworkStatus
|
||||
@implements IDisposable
|
||||
|
||||
<div class="network-status-chip @(NetworkStatus.IsOnline ? "online" : "offline")"
|
||||
title="@(NetworkStatus.IsOnline ? "Connected - App is online" : "Offline - Running from local cache")">
|
||||
<span class="status-dot"></span>
|
||||
<i class="bi @(NetworkStatus.IsOnline ? "bi-wifi" : "bi-wifi-off") status-icon"></i>
|
||||
<span class="status-text">@(NetworkStatus.IsOnline ? "Online" : "Offline")</span>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
NetworkStatus.StatusChanged += OnStatusChanged;
|
||||
await NetworkStatus.InitializeAsync();
|
||||
}
|
||||
|
||||
private void OnStatusChanged(bool isOnline)
|
||||
{
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
NetworkStatus.StatusChanged -= OnStatusChanged;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
.network-status-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
padding: 0.2rem 0.55rem;
|
||||
border-radius: 9999px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
user-select: none;
|
||||
transition: all 0.25s ease-in-out;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.network-status-chip.online {
|
||||
background-color: rgba(16, 185, 129, 0.15);
|
||||
border-color: rgba(16, 185, 129, 0.35);
|
||||
color: #34d399;
|
||||
}
|
||||
|
||||
.network-status-chip.offline {
|
||||
background-color: rgba(245, 158, 11, 0.18);
|
||||
border-color: rgba(245, 158, 11, 0.45);
|
||||
color: #fbbf24;
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.network-status-chip.online .status-dot {
|
||||
background-color: #10b981;
|
||||
box-shadow: 0 0 6px rgba(16, 185, 129, 0.8);
|
||||
}
|
||||
|
||||
.network-status-chip.offline .status-dot {
|
||||
background-color: #f59e0b;
|
||||
box-shadow: 0 0 6px rgba(245, 158, 11, 0.8);
|
||||
animation: pulse 2s infinite ease-in-out;
|
||||
}
|
||||
|
||||
.status-icon {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.status-text {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
50% {
|
||||
opacity: 0.4;
|
||||
transform: scale(0.85);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user