Skip to content

Commit

Permalink
Models and Extensions - Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gvreddy04 committed Jul 23, 2023
1 parent 21857fd commit 19bf33e
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 245 deletions.
174 changes: 75 additions & 99 deletions blazorbootstrap/Extensions/EnumExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,140 +7,119 @@ public static class EnumExtensions
/// </summary>
/// <param name="backgroundColor"></param>
/// <returns>string</returns>
public static string ToBackgroundClass(this BackgroundColor backgroundColor)
public static string ToBackgroundClass(this BackgroundColor backgroundColor) => backgroundColor switch
{
return backgroundColor switch
{
BackgroundColor.Primary => "bg-primary",
BackgroundColor.Secondary => "bg-secondary",
BackgroundColor.Success => "bg-success",
BackgroundColor.Danger => "bg-danger",
BackgroundColor.Warning => "bg-warning",
BackgroundColor.Info => "bg-info",
BackgroundColor.Light => "bg-light",
BackgroundColor.Dark => "bg-dark",
BackgroundColor.Body => "bg-body",
BackgroundColor.White => "bg-white",
BackgroundColor.Transparent => "bg-transparent",
BackgroundColor.Primary => "bg-primary",
BackgroundColor.Secondary => "bg-secondary",
BackgroundColor.Success => "bg-success",
BackgroundColor.Danger => "bg-danger",
BackgroundColor.Warning => "bg-warning",
BackgroundColor.Info => "bg-info",
BackgroundColor.Light => "bg-light",
BackgroundColor.Dark => "bg-dark",
BackgroundColor.Body => "bg-body",
BackgroundColor.White => "bg-white",
BackgroundColor.Transparent => "bg-transparent",

_ => ""
};
}
_ => ""
};
/// <summary>
/// Get the background and text classes.
/// </summary>
/// <param name="backgroundColor"></param>
/// <returns>string</returns>
public static string ToBackgroundAndTextClass(this BackgroundColor backgroundColor)
public static string ToBackgroundAndTextClass(this BackgroundColor backgroundColor) => backgroundColor switch
{
return backgroundColor switch
{
BackgroundColor.Primary => "bg-primary text-white",
BackgroundColor.Secondary => "bg-secondary text-white",
BackgroundColor.Success => "bg-success text-white",
BackgroundColor.Danger => "bg-danger text-white",
BackgroundColor.Warning => "bg-warning text-dark",
BackgroundColor.Info => "bg-info text-dark",
BackgroundColor.Light => "bg-light text-dark",
BackgroundColor.Dark => "bg-dark text-white",
BackgroundColor.Body => "bg-body text-dark",
BackgroundColor.White => "bg-white text-dark",
BackgroundColor.Transparent => "bg-transparent text-dark",
BackgroundColor.Primary => "bg-primary text-white",
BackgroundColor.Secondary => "bg-secondary text-white",
BackgroundColor.Success => "bg-success text-white",
BackgroundColor.Danger => "bg-danger text-white",
BackgroundColor.Warning => "bg-warning text-dark",
BackgroundColor.Info => "bg-info text-dark",
BackgroundColor.Light => "bg-light text-dark",
BackgroundColor.Dark => "bg-dark text-white",
BackgroundColor.Body => "bg-body text-dark",
BackgroundColor.White => "bg-white text-dark",
BackgroundColor.Transparent => "bg-transparent text-dark",

_ => ""
};
}
_ => ""
};

/// <summary>
/// Gets the button class.
/// </summary>
/// <param name="buttonColor"></param>
/// <returns>string</returns>
public static string ToButtonClass(this ButtonColor buttonColor)
public static string ToButtonClass(this ButtonColor buttonColor) => buttonColor switch
{
return buttonColor switch
{
ButtonColor.Primary => "btn btn-primary",
ButtonColor.Secondary => "btn btn-secondary",
ButtonColor.Success => "btn btn-success",
ButtonColor.Danger => "btn btn-danger",
ButtonColor.Warning => "btn btn-warning",
ButtonColor.Info => "btn btn-info",
ButtonColor.Light => "btn btn-light",
ButtonColor.Dark => "btn btn-dark",
ButtonColor.Link => "btn btn-link",
ButtonColor.Primary => "btn btn-primary",
ButtonColor.Secondary => "btn btn-secondary",
ButtonColor.Success => "btn btn-success",
ButtonColor.Danger => "btn btn-danger",
ButtonColor.Warning => "btn btn-warning",
ButtonColor.Info => "btn btn-info",
ButtonColor.Light => "btn btn-light",
ButtonColor.Dark => "btn btn-dark",
ButtonColor.Link => "btn btn-link",

_ => "btn btn-primary"
};
}
_ => "btn btn-primary"
};

/// <summary>
/// Gets the button tag name.
/// </summary>
/// <param name="buttonType"></param>
/// <returns>string</returns>
public static string ToButtonTagName(this ButtonType buttonType)
public static string ToButtonTagName(this ButtonType buttonType) => buttonType switch
{
return buttonType switch
{
ButtonType.Link => "a",
_ => "button"
};
}
ButtonType.Link => "a",
_ => "button"
};

/// <summary>
/// Gets the button type.
/// </summary>
/// <param name="buttonType"></param>
/// <returns>string</returns>
public static string ToButtonTypeString(this ButtonType buttonType)
public static string ToButtonTypeString(this ButtonType buttonType) => buttonType switch
{
return buttonType switch
{
ButtonType.Button => "button",
ButtonType.Submit => "submit",
ButtonType.Reset => "reset",
_ => null,
};
}
ButtonType.Button => "button",
ButtonType.Submit => "submit",
ButtonType.Reset => "reset",
_ => null,
};

/// <summary>
/// Gets the callout color.
/// </summary>
/// <param name="color"></param>
/// <returns>string</returns>
public static string ToCalloutColor(this CalloutType calloutColor)
public static string ToCalloutColor(this CalloutType calloutColor) => calloutColor switch
{
return calloutColor switch
{
CalloutType.Default => "",
CalloutType.Danger => "bb-callout-danger",
CalloutType.Warning => "bb-callout-warning",
CalloutType.Info => "bb-callout-info",
_ => ""
};
}
CalloutType.Default => "",
CalloutType.Danger => "bb-callout-danger",
CalloutType.Warning => "bb-callout-warning",
CalloutType.Info => "bb-callout-info",
_ => ""
};

/// <summary>
/// Gets the spinner color.
/// </summary>
/// <param name="color"></param>
/// <returns>string</returns>
public static string ToSpinnerColor(this SpinnerColor color)
public static string ToSpinnerColor(this SpinnerColor color) => color switch
{
return color switch
{
SpinnerColor.Primary => "text-primary",
SpinnerColor.Secondary => "text-secondary",
SpinnerColor.Success => "text-success",
SpinnerColor.Danger => "text-danger",
SpinnerColor.Warning => "text-warning",
SpinnerColor.Info => "text-info",
SpinnerColor.Light => "text-light",
SpinnerColor.Dark => "text-dark",
_ => ""
};
}
SpinnerColor.Primary => "text-primary",
SpinnerColor.Secondary => "text-secondary",
SpinnerColor.Success => "text-success",
SpinnerColor.Danger => "text-danger",
SpinnerColor.Warning => "text-warning",
SpinnerColor.Info => "text-info",
SpinnerColor.Light => "text-light",
SpinnerColor.Dark => "text-dark",
_ => ""
};

/// <summary>
/// Gets the link target name.
Expand All @@ -161,15 +140,12 @@ public static string ToSpinnerColor(this SpinnerColor color)
/// </summary>
/// <param name="tooltipPlacement"></param>
/// <returns>string</returns>
public static string ToTooltipPlacementName(this TooltipPlacement tooltipPlacement)
public static string ToTooltipPlacementName(this TooltipPlacement tooltipPlacement) => tooltipPlacement switch
{
return tooltipPlacement switch
{
TooltipPlacement.Auto => "auto",
TooltipPlacement.Right => "right",
TooltipPlacement.Bottom => "bottom",
TooltipPlacement.Left => "left",
_ => "top"
};
}
TooltipPlacement.Auto => "auto",
TooltipPlacement.Right => "right",
TooltipPlacement.Bottom => "bottom",
TooltipPlacement.Left => "left",
_ => "top"
};
}
Loading

0 comments on commit 19bf33e

Please sign in to comment.