mirror of https://github.com/abpframework/abp.git
12 changed files with 177 additions and 5 deletions
@ -0,0 +1,13 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button |
|||
{ |
|||
public class AbpButtonTagHelper : AbpTagHelper<AbpButtonTagHelper, AbpButtonTagHelperService> |
|||
{ |
|||
public AbpButtonType ButtonType { get; set; } = AbpButtonType.Default; |
|||
|
|||
public AbpButtonTagHelper(AbpButtonTagHelperService service) |
|||
: base(service) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -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.Button |
|||
{ |
|||
public class AbpButtonTagHelperService : AbpTagHelperService<AbpButtonTagHelper> |
|||
{ |
|||
public override void Process(TagHelperContext context, TagHelperOutput output) |
|||
{ |
|||
output.TagName = "button"; |
|||
output.Attributes.Add("type", "button"); |
|||
output.Attributes.AddClass("btn"); |
|||
|
|||
if (TagHelper.ButtonType != AbpButtonType.Default) |
|||
{ |
|||
output.Attributes.AddClass("btn-" + TagHelper.ButtonType.ToString().ToLowerInvariant()); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button |
|||
{ |
|||
public enum AbpButtonType |
|||
{ |
|||
Default, |
|||
Primary, |
|||
Secondary, |
|||
Success, |
|||
Danger, |
|||
Warning, |
|||
Info, |
|||
Light, |
|||
Dark, |
|||
Link |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using Microsoft.AspNetCore.Razor.TagHelpers; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button |
|||
{ |
|||
[HtmlTargetElement("a", Attributes = "abp-button")] |
|||
[HtmlTargetElement("input", Attributes = "abp-button", TagStructure = TagStructure.WithoutEndTag)] |
|||
public class AbpLinkButtonTagHelper : AbpTagHelper<AbpLinkButtonTagHelper, AbpLinkButtonTagHelperService> |
|||
{ |
|||
[HtmlAttributeName("abp-button")] |
|||
public AbpButtonType ButtonType { get; set; } |
|||
|
|||
public AbpLinkButtonTagHelper(AbpLinkButtonTagHelperService service) |
|||
: base(service) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using System; |
|||
using Microsoft.AspNetCore.Razor.TagHelpers; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button |
|||
{ |
|||
public class AbpLinkButtonTagHelperService : AbpTagHelperService<AbpLinkButtonTagHelper> |
|||
{ |
|||
public override void Process(TagHelperContext context, TagHelperOutput output) |
|||
{ |
|||
output.Attributes.AddClass("btn"); |
|||
|
|||
if (TagHelper.ButtonType != AbpButtonType.Default) |
|||
{ |
|||
output.Attributes.AddClass("btn-" + TagHelper.ButtonType.ToString().ToLowerInvariant()); |
|||
} |
|||
|
|||
if (!output.Attributes.ContainsName("role")) |
|||
{ |
|||
output.Attributes.Add("role", "button"); |
|||
} |
|||
|
|||
if (!output.Attributes.ContainsName("type") && |
|||
output.TagName.Equals("input", StringComparison.InvariantCultureIgnoreCase)) |
|||
{ |
|||
output.Attributes.Add("type", "button"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
@page |
|||
@model Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Pages.Components.ButtonsModel |
|||
@{ |
|||
ViewData["Title"] = "Buttons"; |
|||
} |
|||
|
|||
<h2>Buttons</h2> |
|||
|
|||
<p>Based on <a href="http://getbootstrap.com/docs/4.1/components/buttons/" target="_blank"> Bootstrap button</a>.</p> |
|||
|
|||
<h4># Example</h4> |
|||
|
|||
<div class="demo-with-code"> |
|||
<div class="demo-area"> |
|||
<abp-button>Default</abp-button> |
|||
<abp-button button-type="Primary">Primary</abp-button> |
|||
<abp-button button-type="Secondary">Secondary</abp-button> |
|||
<abp-button button-type="Success">Success</abp-button> |
|||
<abp-button button-type="Danger">Danger</abp-button> |
|||
<abp-button button-type="Warning">Warning</abp-button> |
|||
<abp-button button-type="Info">Info</abp-button> |
|||
<abp-button button-type="Light">Light</abp-button> |
|||
<abp-button button-type="Dark">Dark</abp-button> |
|||
<abp-button button-type="Link">Link</abp-button> |
|||
</div> |
|||
<div class="code-area"> |
|||
<pre> |
|||
<abp-button>Default</abp-button> |
|||
<abp-button button-type="Primary">Primary</abp-button> |
|||
<abp-button button-type="Secondary">Secondary</abp-button> |
|||
<abp-button button-type="Success">Success</abp-button> |
|||
<abp-button button-type="Danger">Danger</abp-button> |
|||
<abp-button button-type="Warning">Warning</abp-button> |
|||
<abp-button button-type="Info">Info</abp-button> |
|||
<abp-button button-type="Light">Light</abp-button> |
|||
<abp-button button-type="Dark">Dark</abp-button> |
|||
<abp-button button-type="Link">Link</abp-button> |
|||
</pre> |
|||
</div> |
|||
</div> |
|||
|
|||
<h4># Example</h4> |
|||
|
|||
<div class="demo-with-code"> |
|||
<div class="demo-area"> |
|||
<a abp-button="Primary" href="#">Link</a> |
|||
<abp-button button-type="Primary" type="submit">Button</abp-button> |
|||
<input abp-button="Primary" value="Input" /> |
|||
<input abp-button="Primary" type="submit" value="Submit" /> |
|||
<input abp-button="Primary" type="reset" value="Reset" /> |
|||
</div> |
|||
<div class="code-area"> |
|||
<pre></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 ButtonsModel : PageModel |
|||
{ |
|||
public void OnGet() |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue