namespace RobotNet.WebApp.Charts.Enums;

public static class EnumExtensions
{

    public static string? ToChartDatasetDataLabelAlignmentString(this DataLabelsAlignment alignment) =>
        alignment switch
        {
            DataLabelsAlignment.Start => "start",
            DataLabelsAlignment.Center or DataLabelsAlignment.None => "center", // default
            DataLabelsAlignment.End => "end",
            _ => null
        };

    public static string? ToChartDatasetDataLabelAnchorString(this DataLabelsAnchoring anchor) =>
        anchor switch
        {
            DataLabelsAnchoring.Start => "start",
            DataLabelsAnchoring.Center or DataLabelsAnchoring.None => "center", // default
            DataLabelsAnchoring.End => "end",
            _ => null
        };

    public static string ToCssString(this Unit unit) =>
        unit switch
        {
            Unit.Em => "em",
            Unit.Percentage => "%",
            Unit.Pt => "pt",
            Unit.Px => "px",
            Unit.Rem => "rem",
            Unit.Vh => "vh",
            Unit.VMax => "vmax",
            Unit.VMin => "vmin",
            Unit.Vw => "vw",
            _ => string.Empty
        };
}
