mirror of https://github.com/abpframework/abp.git
4 changed files with 217 additions and 2 deletions
@ -0,0 +1,16 @@ |
|||
using Microsoft.AspNetCore.Razor.TagHelpers; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border |
|||
{ |
|||
[HtmlTargetElement(Attributes = "abp-border")] |
|||
public class AbpBorderTagHelper : AbpTagHelper<AbpBorderTagHelper, AbpBorderTagHelperService> |
|||
{ |
|||
public AbpBorderType AbpBorder { get; set; } = AbpBorderType._; |
|||
|
|||
public AbpBorderTagHelper(AbpBorderTagHelperService tagHelperService) |
|||
: base(tagHelperService) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,91 @@ |
|||
using Microsoft.AspNetCore.Razor.TagHelpers; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border |
|||
{ |
|||
public class AbpBorderTagHelperService : AbpTagHelperService<AbpBorderTagHelper> |
|||
{ |
|||
public override void Process(TagHelperContext context, TagHelperOutput output) |
|||
{ |
|||
var borderAttributeAsString = TagHelper.AbpBorder.ToString().ToLowerInvariant(); |
|||
|
|||
var borderClass = "border" + GetBorderDirection(context, output, borderAttributeAsString) + GetExtensionIfBorderIsSubtractive(context, output, borderAttributeAsString); |
|||
|
|||
output.Attributes.AddClass(borderClass); |
|||
|
|||
SetBorderType(context, output, borderAttributeAsString); |
|||
} |
|||
|
|||
protected virtual string GetBorderDirection(TagHelperContext context, TagHelperOutput output, string borderAttributeAsString) |
|||
{ |
|||
if (borderAttributeAsString.Contains("top")) |
|||
{ |
|||
return "-top"; |
|||
} |
|||
if (borderAttributeAsString.Contains("right")) |
|||
{ |
|||
return "-right"; |
|||
} |
|||
if (borderAttributeAsString.Contains("left")) |
|||
{ |
|||
return "-left"; |
|||
} |
|||
if (borderAttributeAsString.Contains("bottom")) |
|||
{ |
|||
return "-bottom"; |
|||
} |
|||
|
|||
return ""; |
|||
} |
|||
|
|||
protected virtual string GetExtensionIfBorderIsSubtractive(TagHelperContext context, TagHelperOutput output, string borderAttributeAsString) |
|||
{ |
|||
if (borderAttributeAsString.Contains("_0")) |
|||
{ |
|||
return "-0"; |
|||
} |
|||
|
|||
return ""; |
|||
} |
|||
|
|||
protected virtual void SetBorderType(TagHelperContext context, TagHelperOutput output, string borderAttributeAsString) |
|||
{ |
|||
if (borderAttributeAsString.Contains("primary")) |
|||
{ |
|||
output.Attributes.AddClass("border-primary"); |
|||
} |
|||
if (borderAttributeAsString.Contains("secondary")) |
|||
{ |
|||
output.Attributes.AddClass("border-secondary"); |
|||
} |
|||
if (borderAttributeAsString.Contains("success")) |
|||
{ |
|||
output.Attributes.AddClass("border-success"); |
|||
} |
|||
if (borderAttributeAsString.Contains("danger")) |
|||
{ |
|||
output.Attributes.AddClass("border-danger"); |
|||
} |
|||
if (borderAttributeAsString.Contains("warning")) |
|||
{ |
|||
output.Attributes.AddClass("border-warning"); |
|||
} |
|||
if (borderAttributeAsString.Contains("info")) |
|||
{ |
|||
output.Attributes.AddClass("border-info"); |
|||
} |
|||
if (borderAttributeAsString.Contains("light")) |
|||
{ |
|||
output.Attributes.AddClass("border-light"); |
|||
} |
|||
if (borderAttributeAsString.Contains("dark")) |
|||
{ |
|||
output.Attributes.AddClass("border-dark"); |
|||
} |
|||
if (borderAttributeAsString.Contains("white")) |
|||
{ |
|||
output.Attributes.AddClass("border-white"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,106 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border |
|||
{ |
|||
public enum AbpBorderType |
|||
{ |
|||
_, |
|||
_0, |
|||
Primary, |
|||
Secondary, |
|||
Success, |
|||
Danger, |
|||
Warning, |
|||
Info, |
|||
Light, |
|||
Dark, |
|||
White, |
|||
Primary_0, |
|||
Secondary_0, |
|||
Success_0, |
|||
Danger_0, |
|||
Warning_0, |
|||
Info_0, |
|||
Light_0, |
|||
Dark_0, |
|||
White_0, |
|||
Top, |
|||
Top_0, |
|||
Top_Primary, |
|||
Top_Secondary, |
|||
Top_Success, |
|||
Top_Danger, |
|||
Top_Warning, |
|||
Top_Info, |
|||
Top_Light, |
|||
Top_Dark, |
|||
Top_White, |
|||
Top_Primary_0, |
|||
Top_Secondary_0, |
|||
Top_Success_0, |
|||
Top_Danger_0, |
|||
Top_Warning_0, |
|||
Top_Info_0, |
|||
Top_Light_0, |
|||
Top_Dark_0, |
|||
Top_White_0, |
|||
Right, |
|||
Right_0, |
|||
Right_Primary, |
|||
Right_Secondary, |
|||
Right_Success, |
|||
Right_Danger, |
|||
Right_Warning, |
|||
Right_Info, |
|||
Right_Light, |
|||
Right_Dark, |
|||
Right_White, |
|||
Right_Primary_0, |
|||
Right_Secondary_0, |
|||
Right_Success_0, |
|||
Right_Danger_0, |
|||
Right_Warning_0, |
|||
Right_Info_0, |
|||
Right_Light_0, |
|||
Right_Dark_0, |
|||
Right_White_0, |
|||
Left, |
|||
Left_0, |
|||
Left_Primary, |
|||
Left_Secondary, |
|||
Left_Success, |
|||
Left_Danger, |
|||
Left_Warning, |
|||
Left_Info, |
|||
Left_Light, |
|||
Left_Dark, |
|||
Left_White, |
|||
Left_Primary_0, |
|||
Left_Secondary_0, |
|||
Left_Success_0, |
|||
Left_Danger_0, |
|||
Left_Warning_0, |
|||
Left_Info_0, |
|||
Left_Light_0, |
|||
Left_Dark_0, |
|||
Left_White_0, |
|||
Bottom, |
|||
Bottom_0, |
|||
Bottom_Primary, |
|||
Bottom_Secondary, |
|||
Bottom_Success, |
|||
Bottom_Danger, |
|||
Bottom_Warning, |
|||
Bottom_Info, |
|||
Bottom_Light, |
|||
Bottom_Dark, |
|||
Bottom_White, |
|||
Bottom_Primary_0, |
|||
Bottom_Secondary_0, |
|||
Bottom_Success_0, |
|||
Bottom_Danger_0, |
|||
Bottom_Warning_0, |
|||
Bottom_Info_0, |
|||
Bottom_Light_0, |
|||
Bottom_Dark_0, |
|||
Bottom_White_0, |
|||
} |
|||
} |
|||
Loading…
Reference in new issue