mirror of https://github.com/abpframework/abp.git
10 changed files with 372 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.Default; |
|||
|
|||
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 |
|||
{ |
|||
Default, |
|||
_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, |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using Microsoft.AspNetCore.Razor.TagHelpers; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border |
|||
{ |
|||
[HtmlTargetElement(Attributes = "abp-rounded")] |
|||
public class AbpRoundedTagHelper : AbpTagHelper<AbpRoundedTagHelper, AbpRoundedTagHelperService> |
|||
{ |
|||
public AbpRoundedType AbpRounded { get; set; } = AbpRoundedType.Default; |
|||
|
|||
public AbpRoundedTagHelper(AbpRoundedTagHelperService tagHelperService) |
|||
: base(tagHelperService) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
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 AbpRoundedTagHelperService : AbpTagHelperService<AbpRoundedTagHelper> |
|||
{ |
|||
public override void Process(TagHelperContext context, TagHelperOutput output) |
|||
{ |
|||
var roundedClass = "rounded"; |
|||
|
|||
if (TagHelper.AbpRounded != AbpRoundedType.Default) |
|||
{ |
|||
roundedClass += "-" + TagHelper.AbpRounded.ToString().ToLowerInvariant().Replace("_",""); |
|||
} |
|||
|
|||
output.Attributes.AddClass(roundedClass); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border |
|||
{ |
|||
public enum AbpRoundedType |
|||
{ |
|||
Default, |
|||
_0, |
|||
Top, |
|||
Right, |
|||
Left, |
|||
Bottom |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
using System.Collections.Generic; |
|||
using Microsoft.Extensions.Options; |
|||
|
|||
namespace Volo.Abp.Options |
|||
{ |
|||
//TODO: Derive from OptionsFactory when this is released: https://github.com/aspnet/Options/pull/258 (or completely remove this!)
|
|||
public class AbpOptionsFactory<TOptions> : IOptionsFactory<TOptions> where TOptions : class, new() |
|||
{ |
|||
private readonly IEnumerable<IConfigureOptions<TOptions>> _setups; |
|||
private readonly IEnumerable<IPostConfigureOptions<TOptions>> _postConfigures; |
|||
|
|||
public AbpOptionsFactory(IEnumerable<IConfigureOptions<TOptions>> setups, IEnumerable<IPostConfigureOptions<TOptions>> postConfigures) |
|||
{ |
|||
_setups = setups; |
|||
_postConfigures = postConfigures; |
|||
} |
|||
|
|||
public virtual TOptions Create(string name) |
|||
{ |
|||
var options = new TOptions(); |
|||
|
|||
foreach (var setup in _setups) |
|||
{ |
|||
if (setup is IConfigureNamedOptions<TOptions> namedSetup) |
|||
{ |
|||
namedSetup.Configure(name, options); |
|||
} |
|||
else if (name == Microsoft.Extensions.Options.Options.DefaultName) |
|||
{ |
|||
setup.Configure(options); |
|||
} |
|||
} |
|||
|
|||
foreach (var post in _postConfigures) |
|||
{ |
|||
post.PostConfigure(name, options); |
|||
} |
|||
|
|||
return options; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
@page |
|||
@model Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Pages.Components.BordersModel |
|||
@{ |
|||
ViewData["Title"] = "Borders"; |
|||
} |
|||
|
|||
<h2>Borders</h2> |
|||
|
|||
<p>Based on <a href="https://getbootstrap.com/docs/4.1/components/border/" target="_blank"> Bootstrap Border</a>.</p> |
|||
|
|||
<h4># Borders Examples</h4> |
|||
|
|||
<div class="demo-with-code"> |
|||
<div class="demo-area"> |
|||
|
|||
<span abp-border></span> |
|||
<span abp-border="top"></span> |
|||
<span abp-border="Right"></span> |
|||
<span abp-border="Left"></span> |
|||
<span abp-border="Bottom"></span> |
|||
<span abp-border="top_0"></span> |
|||
<span abp-border="Right_0"></span> |
|||
<span abp-border="Left_0"></span> |
|||
<span abp-border="Bottom_0"></span> |
|||
<span abp-border="Top_Primary"></span> |
|||
<span abp-border="Warning_0"></span> |
|||
<span abp-border="Bottom_Primary_0"></span> |
|||
<span abp-border="Left_Danger"></span> |
|||
|
|||
</div> |
|||
<div class="code-area"> |
|||
<pre> |
|||
<span abp-border></span> |
|||
<span abp-border="top"></span> |
|||
<span abp-border="Right"></span> |
|||
<span abp-border="Left"></span> |
|||
<span abp-border="Bottom"></span> |
|||
<span abp-border="top_0"></span> |
|||
<span abp-border="Right_0"></span> |
|||
<span abp-border="Left_0"></span> |
|||
<span abp-border="Bottom_0"></span> |
|||
<span abp-border="Top_Primary"></span> |
|||
<span abp-border="Warning_0"></span> |
|||
<span abp-border="Bottom_Primary_0"></span> |
|||
<span abp-border="Left_Danger"></span> |
|||
</pre> |
|||
</div> |
|||
</div> |
|||
@ -0,0 +1,17 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.AspNetCore.Mvc.RazorPages; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Pages.Components |
|||
{ |
|||
public class BordersModel : PageModel |
|||
{ |
|||
public void OnGet() |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue