Lerp doesn't work with SetAlpha

Hi, I am using a UI panel and this script in the main camera to make fade in/out effects, but the fade time is not in seconds. For example if it’s fadetime is 5f, the fade takes a lesser time.

I’ve been stuck here for the past three hours. Any help? I would appreciate it so much. Here is the piece of code I’ve written for it:

[SerializeField] private CanvasRenderer panel;
private void Awake() => maincamera = Camera.main;
private void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        Fadeout(15f);
    }
}

public void Fadein(float fadetime) => StartCoroutine(Fadi(fadetime, false));
public void Fadeout(float fadetime) => StartCoroutine(Fadi(fadetime, true));

private IEnumerator Fadi(float fadetime, bool fadeout)
{
    panel.gameObject.SetActive(true);
    float timma = 0f;
    float currentpanelalpha = fadeout ? 0f : 100f;
    float newpanelalpha = Mathf.Abs(currentpanelalpha - 100f);
    panel.SetAlpha(currentpanelalpha);
    while (timma < fadetime)
    {
        panel.SetAlpha(Mathf.Lerp(currentpanelalpha, newpanelalpha, timma / fadetime));
        timma += Time.deltaTime;
        yield return null;
    }
    panel.SetAlpha(newpanelalpha);

}

The only thing I find wrong with your code is that alpha should be between 0.0f and 1.0f. You should also guard against that the user can start multiple Fadeout() by clicking again before the fade is done.

float currentpanelalpha = fadeout ? 0f : 1f;
float newpanelalpha = fadeout ? 1f : 0f;