<section class="@BuildCssClass()">
    @if (!string.IsNullOrWhiteSpace(Title) || HeaderContent is not null)
    {
        <header class="inspector-section-header">
            <div>
                @if (!string.IsNullOrWhiteSpace(Title))
                {
                    <h3 class="inspector-section-title">@Title</h3>
                }

                @if (!string.IsNullOrWhiteSpace(Description))
                {
                    <p class="inspector-section-copy">@Description</p>
                }
            </div>

            @HeaderContent
        </header>
    }

    <div class="inspector-section-body">
        @ChildContent
    </div>
</section>

@code {
    [Parameter]
    public string? Title { get; set; }

    [Parameter]
    public string? Description { get; set; }

    [Parameter]
    public RenderFragment? HeaderContent { get; set; }

    [Parameter]
    public RenderFragment? ChildContent { get; set; }

    [Parameter]
    public string? CssClass { get; set; }

    private string BuildCssClass() =>
        string.IsNullOrWhiteSpace(CssClass)
            ? "inspector-section"
            : $"inspector-section {CssClass}";
}
