You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Components/Components/Input/InputCssHelper.cs

38 lines
2.0 KiB

2 years ago
using Connected.Extensions;
using Connected.Utilities;
namespace Connected.Components;
internal static class InputCssHelper
{
public static string GetClassname<T>(InputBase<T> baseInput, Func<bool> shrinkWhen) =>
new CssBuilder("mud-input")
.AddClass($"mud-input-{baseInput.Variant.ToDescriptionString()}")
.AddClass($"mud-input-adorned-{baseInput.Adornment.ToDescriptionString()}", baseInput.Adornment != Adornment.None)
.AddClass($"mud-input-margin-{baseInput.Margin.ToDescriptionString()}", when: () => baseInput.Margin != Margin.None)
.AddClass("mud-input-underline", when: () => baseInput.DisableUnderLine == false && baseInput.Variant != Variant.Outlined)
.AddClass("mud-shrink", when: shrinkWhen)
.AddClass("mud-disabled", baseInput.Disabled)
.AddClass("mud-input-error", baseInput.HasErrors)
.AddClass("mud-ltr", baseInput.GetInputType() == InputType.Email || baseInput.GetInputType() == InputType.Telephone)
.AddClass(baseInput.Class)
.Build();
public static string GetInputClassname<T>(InputBase<T> baseInput) =>
new CssBuilder("mud-input-slot")
.AddClass("mud-input-root")
.AddClass($"mud-input-root-{baseInput.Variant.ToDescriptionString()}")
.AddClass($"mud-input-root-adorned-{baseInput.Adornment.ToDescriptionString()}", baseInput.Adornment != Adornment.None)
.AddClass($"mud-input-root-margin-{baseInput.Margin.ToDescriptionString()}", when: () => baseInput.Margin != Margin.None)
.AddClass(baseInput.Class)
.Build();
public static string GetAdornmentClassname<T>(InputBase<T> baseInput) =>
new CssBuilder("mud-input-adornment")
.AddClass($"mud-input-adornment-{baseInput.Adornment.ToDescriptionString()}", baseInput.Adornment != Adornment.None)
.AddClass($"mud-text", !string.IsNullOrEmpty(baseInput.AdornmentText))
.AddClass($"mud-input-root-filled-shrink", baseInput.Variant == Variant.Filled)
.AddClass(baseInput.Class)
.Build();
}