// Copyright © Selmo Technology GmbH. All Rights Reserved

using Microsoft.AspNetCore.Components;
using SelmoStudio.Hmi.Server.SelmoHmi.Shared.Component;
using SelmoStudio.Hmi.Server.SelmoHmi.Shared.Model;

namespace SelmoStudio.Hmi.Server.Shared.Components.BaseComponents
{
    public partial class ButtonWithStatusComponent : ButtonBaseComponent
    {
        [Parameter]
        public List<string> Icons { get; set; } = new();

        [Parameter]
        public OperationMode Led { get; set; }

        [Parameter]
        public EventCallback Click { get; set; }

        protected override async Task OnClick()
        {
            await Click.InvokeAsync();
        }

        protected override void OnInitialized()
        {
            ShowAdditionalContent = true;

            AdditionalContent = __builder =>
            {
                __builder.OpenComponent<StatusComponent>(0);
                __builder.AddAttribute(1, "Icons", Icons);
                __builder.AddAttribute(2, "Led", Led);
                __builder.CloseComponent();
            };

            base.OnInitialized();
        }
    }
}