-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTablerColor.cs
66 lines (59 loc) · 1.52 KB
/
TablerColor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
namespace TablerForNet
{
public enum TablerColor
{
Default,
Blue,
Azure,
Indigo,
Purple,
Pink,
Red,
Orange,
Yellow,
Lime,
Green,
Teal,
Cyan,
White,
Primary,
Secondary,
Success,
Info,
Warning,
Danger,
Light,
Dark
}
public enum ColorType
{
Default,
Outline,
Ghost
}
public static class ColorsExtensions
{
public static string GetColorClass(this TablerColor color, string type,
ColorType colorType = ColorType.Default, string suffix = "")
{
var colorClass = $"{type}";
colorClass += colorType switch
{
ColorType.Default => "",
_ => $"-{Enum.GetName(typeof(ColorType), colorType)?.ToLower()}"
};
colorClass = color switch
{
TablerColor.Default => "",
_ => $"{colorClass}-{Enum.GetName(typeof(TablerColor), color)?.ToLower()}"
};
if (color != TablerColor.Light && colorClass.ToLower().EndsWith("light"))
{
colorClass = colorClass.Replace("light", "-lt", StringComparison.InvariantCultureIgnoreCase);
}
if (!string.IsNullOrWhiteSpace(suffix) && !string.IsNullOrWhiteSpace(colorClass))
colorClass += $"-{suffix}";
return colorClass;
}
}
}