@namespace Lumeo

<code class="@CssClass" @attributes="AdditionalAttributes">@ChildContent</code>

@code {
    [Parameter] public string Variant { get; set; } = "inline";
    [Parameter] public string? Size { get; set; }
    [Parameter] public RenderFragment? ChildContent { get; set; }
    [Parameter] public string? Class { get; set; }
    [Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object>? AdditionalAttributes { get; set; }

    private string BaseClasses => Variant switch
    {
        "block" => "block rounded-lg bg-muted p-4 font-mono text-sm overflow-x-auto",
        _ => "relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold"
    };

    private string CssClass
    {
        get
        {
            var classes = new List<string> { BaseClasses };

            if (!string.IsNullOrEmpty(Size))
                classes.Add($"text-{Size}");

            if (!string.IsNullOrEmpty(Class))
                classes.Add(Class);

            return string.Join(" ", classes);
        }
    }
}
