@inject IGlossaryService glossaryService
@inject IGlossaryDialogService glossaryDialogService

@if (TermId == null)
{
    <span>Missing term</span>
}
else
{
    var term = glossaryService.GetTerm(TermId);
    if (term != null)
    {
        <button class="glossaryLabel @term.Category.ToLowerInvariant()" @onclick="TermLabelClicked"
                title="@term.ShortDefinition">
            @term.Term
        </button>
    }
}

@code {

    [Parameter] public string TermId { get; set; } = default!;

    void TermLabelClicked()
    {
        glossaryDialogService.AddDialog(TermId);
    }

}
