@using OpenArchival.DataAccess
@using MudBlazor

@if (File is not null)
{
    <MudImage Fluid="true" Src="@File.Path" Alt="Swedish Farm House" Class="rounded-lg"/>
}

@code {
    [Parameter]
    public required FilePathListing File { get; set; }

    /// <summary>
    /// Sets the width of the image box while it loads 
    /// </summary>
    [Parameter]
    public int Width { get; set; } = 600;

    /// <summary>
    /// Sets the height of the image box while it loads 
    /// </summary>
    [Parameter]
    public int Height { get; set; } = 400;

    [Parameter]
    public string AltText { get; set; } = "";

    protected override Task OnParametersSetAsync()
    {
        if (File is not null || !string.IsNullOrEmpty(AltText))
        {
            StateHasChanged();
        }

        return base.OnParametersSetAsync();
    }
}
