zhaolei
2020-11-20 921de2254ff5712a44ed8575ee8efe34252f6603
commit | author | age
921de2 1 namespace Bootstrap.Admin.Pages.Components
Z 2 {
3     /// <summary>
4     /// 组件位置枚举类型
5     /// </summary>
6     public enum Placement
7     {
8         /// <summary>
9         /// 
10         /// </summary>
11         Default,
12         /// <summary>
13         /// 
14         /// </summary>
15         Top,
16         /// <summary>
17         /// 
18         /// </summary>
19         TopLeft,
20         /// <summary>
21         /// 
22         /// </summary>
23         TopRight,
24         /// <summary>
25         /// 
26         /// </summary>
27         Bottom,
28         /// <summary>
29         /// 
30         /// </summary>
31         BottomLeft,
32         /// <summary>
33         /// 
34         /// </summary>
35         BottomRight,
36         /// <summary>
37         /// 
38         /// </summary>
39         Center
40     }
41
42     /// <summary>
43     /// 
44     /// </summary>
45     public static class PlacementExtensions
46     {
47         /// <summary>
48         /// 
49         /// </summary>
50         /// <param name="placement"></param>
51         /// <param name="prefix"></param>
52         /// <returns></returns>
53         public static string ToCss(this Placement placement, string prefix = "")
54         {
55             string ret = "";
56             switch (placement)
57             {
58                 case Placement.Center:
59                     ret = "center";
60                     break;
61                 case Placement.Top:
62                     ret = "top";
63                     break;
64                 case Placement.TopLeft:
65                     ret = "top-left";
66                     break;
67                 case Placement.TopRight:
68                     ret = "top-right";
69                     break;
70                 case Placement.Bottom:
71                     ret = "bottom";
72                     break;
73                 case Placement.BottomLeft:
74                     ret = "bottom-left";
75                     break;
76                 case Placement.BottomRight:
77                 case Placement.Default:
78                     ret = "bottom-right";
79                     break;
80             }
81             return string.IsNullOrEmpty(prefix) ? ret : $"{prefix}-{ret}";
82         }
83     }
84 }