@namespace Lumeo

<img class="@CssClass" src="@Src" alt="@Alt" @attributes="AdditionalAttributes" @onerror="HandleError" />

@code {
    [Parameter] public string? Src { get; set; }
    [Parameter] public string? Alt { get; set; }
    [Parameter] public string? Class { get; set; }
    [Parameter] public EventCallback OnError { get; set; }
    [Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object>? AdditionalAttributes { get; set; }

    private string CssClass => $"aspect-square h-full w-full object-cover {Class}".Trim();

    private async Task HandleError()
    {
        await OnError.InvokeAsync();
    }
}
