mirror of https://github.com/abpframework/abp.git
13 changed files with 2634 additions and 4 deletions
@ -0,0 +1,13 @@ |
|||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert |
||||
|
{ |
||||
|
public enum AbpAlertHeaderSize |
||||
|
{ |
||||
|
Default, |
||||
|
h1, |
||||
|
h2, |
||||
|
h3, |
||||
|
h4, |
||||
|
h5, |
||||
|
h6 |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert |
||||
|
{ |
||||
|
public class AbpAlertHeaderTagHelper : AbpTagHelper<AbpAlertHeaderTagHelper, AbpAlertHeaderTagHelperService> |
||||
|
{ |
||||
|
public AbpAlertHeaderSize Size { get; set; } = AbpAlertHeaderSize.Default; |
||||
|
|
||||
|
public AbpAlertHeaderTagHelper(AbpAlertHeaderTagHelperService tagHelperService) |
||||
|
: base(tagHelperService) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
using Microsoft.AspNetCore.Razor.TagHelpers; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert |
||||
|
{ |
||||
|
public class AbpAlertHeaderTagHelperService : AbpTagHelperService<AbpAlertHeaderTagHelper> |
||||
|
{ |
||||
|
public override void Process(TagHelperContext context, TagHelperOutput output) |
||||
|
{ |
||||
|
output.TagName = GetHeaderSize(context, output); |
||||
|
output.Attributes.AddClass("alert-heading"); |
||||
|
output.TagMode = TagMode.StartTagAndEndTag; |
||||
|
} |
||||
|
|
||||
|
protected virtual string GetHeaderSize(TagHelperContext context, TagHelperOutput output) |
||||
|
{ |
||||
|
if (TagHelper.Size == AbpAlertHeaderSize.Default) |
||||
|
{ |
||||
|
return AbpAlertHeaderSize.h4.ToString(); |
||||
|
} |
||||
|
|
||||
|
return TagHelper.Size.ToString(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert |
||||
|
{ |
||||
|
public class AbpAlertLinkTagHelper : AbpTagHelper<AbpAlertLinkTagHelper, AbpAlertLinkTagHelperService> |
||||
|
{ |
||||
|
public AbpAlertLinkTagHelper(AbpAlertLinkTagHelperService tagHelperService) |
||||
|
: base(tagHelperService) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
using Microsoft.AspNetCore.Razor.TagHelpers; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert |
||||
|
{ |
||||
|
public class AbpAlertLinkTagHelperService : AbpTagHelperService<AbpAlertLinkTagHelper> |
||||
|
{ |
||||
|
public override void Process(TagHelperContext context, TagHelperOutput output) |
||||
|
{ |
||||
|
output.TagName = "a"; |
||||
|
output.Attributes.AddClass("alert-link"); |
||||
|
output.TagMode = TagMode.StartTagAndEndTag; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert |
||||
|
{ |
||||
|
public class AbpAlertTagHelper : AbpTagHelper<AbpAlertTagHelper, AbpAlertTagHelperService> |
||||
|
{ |
||||
|
public AbpAlertType AlertType { get; set; } = AbpAlertType.Default; |
||||
|
|
||||
|
public bool? Dismissible { get; set; } |
||||
|
|
||||
|
public AbpAlertTagHelper(AbpAlertTagHelperService tagHelperService) |
||||
|
: base(tagHelperService) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,54 @@ |
|||||
|
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.Alert |
||||
|
{ |
||||
|
public class AbpAlertTagHelperService : AbpTagHelperService<AbpAlertTagHelper> |
||||
|
{ |
||||
|
|
||||
|
public override void Process(TagHelperContext context, TagHelperOutput output) |
||||
|
{ |
||||
|
output.TagName = "div"; |
||||
|
output.TagMode = TagMode.StartTagAndEndTag; |
||||
|
|
||||
|
AddClasses(context, output); |
||||
|
|
||||
|
AddDismissButtonIfDismissible(context, output); |
||||
|
} |
||||
|
|
||||
|
protected virtual void AddClasses(TagHelperContext context, TagHelperOutput output) |
||||
|
{ |
||||
|
output.Attributes.Add("role", "alert"); |
||||
|
output.Attributes.AddClass("alert"); |
||||
|
|
||||
|
if (TagHelper.AlertType != AbpAlertType.Default) |
||||
|
{ |
||||
|
output.Attributes.AddClass("alert-" + TagHelper.AlertType.ToString().ToLowerInvariant()); |
||||
|
} |
||||
|
|
||||
|
if (TagHelper.Dismissible ?? false) |
||||
|
{ |
||||
|
output.Attributes.AddClass("alert-dismissible"); |
||||
|
output.Attributes.AddClass("fade"); |
||||
|
output.Attributes.AddClass("show"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected virtual void AddDismissButtonIfDismissible(TagHelperContext context, TagHelperOutput output) |
||||
|
{ |
||||
|
if (!TagHelper.Dismissible ?? true) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var buttonAsHtml = |
||||
|
"<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\">" + Environment.NewLine + |
||||
|
" <span aria-hidden=\"true\">×</span>" + Environment.NewLine + |
||||
|
" </button>"; |
||||
|
|
||||
|
output.PostContent.SetHtmlContent(buttonAsHtml); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert |
||||
|
{ |
||||
|
public enum AbpAlertType |
||||
|
{ |
||||
|
Default, |
||||
|
Primary, |
||||
|
Secondary, |
||||
|
Success, |
||||
|
Danger, |
||||
|
Warning, |
||||
|
Info, |
||||
|
Light, |
||||
|
Dark |
||||
|
} |
||||
|
} |
||||
File diff suppressed because it is too large
@ -0,0 +1,87 @@ |
|||||
|
@page |
||||
|
@model Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Pages.Components.AlertsModel |
||||
|
@{ |
||||
|
ViewData["Title"] = "Alerts"; |
||||
|
} |
||||
|
|
||||
|
<h2>Alerts</h2> |
||||
|
|
||||
|
<p>Based on <a href="https://getbootstrap.com/docs/4.1/components/alerts/" target="_blank"> Bootstrap Alert</a>.</p> |
||||
|
|
||||
|
<h4># Alert Example</h4> |
||||
|
|
||||
|
<div class="demo-with-code"> |
||||
|
<div class="demo-area"> |
||||
|
|
||||
|
<abp-alert alert-type="Danger"> |
||||
|
I'm an abp alert! |
||||
|
</abp-alert> |
||||
|
|
||||
|
</div> |
||||
|
<div class="code-area"> |
||||
|
<pre> |
||||
|
<abp-alert alert-type="Danger"> |
||||
|
I'm an abp alert! |
||||
|
</abp-alert> |
||||
|
</pre> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<h4># Dismissible Alert Example</h4> |
||||
|
|
||||
|
<div class="demo-with-code"> |
||||
|
<div class="demo-area"> |
||||
|
|
||||
|
<abp-alert alert-type="Warning" dismissible="true"> |
||||
|
I'm a dismissible abp alert! |
||||
|
</abp-alert> |
||||
|
|
||||
|
</div> |
||||
|
<div class="code-area"> |
||||
|
<pre> |
||||
|
<abp-alert alert-type="Warning" dismissible="true"> |
||||
|
I'm a dismissible abp alert! |
||||
|
</abp-alert> |
||||
|
</pre> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<h4># Alert With Link Example</h4> |
||||
|
|
||||
|
<div class="demo-with-code"> |
||||
|
<div class="demo-area"> |
||||
|
|
||||
|
<abp-alert alert-type="Secondary"> |
||||
|
I'm an abp alert with <abp-alert-link href="#">Link</abp-alert-link>! |
||||
|
</abp-alert> |
||||
|
|
||||
|
</div> |
||||
|
<div class="code-area"> |
||||
|
<pre> |
||||
|
<abp-alert alert-type="Info"> |
||||
|
I'm an abp alert with <abp-alert-link href="#">Link</abp-alert-link>! |
||||
|
</abp-alert> |
||||
|
</pre> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<h4># Alert With Header Example</h4> |
||||
|
|
||||
|
<div class="demo-with-code"> |
||||
|
<div class="demo-area"> |
||||
|
|
||||
|
<abp-alert alert-type="Primary"> |
||||
|
<abp-alert-header size="h3">Header</abp-alert-header> |
||||
|
I'm an abp alert! |
||||
|
</abp-alert> |
||||
|
|
||||
|
</div> |
||||
|
<div class="code-area"> |
||||
|
<pre> |
||||
|
<abp-alert alert-type="Primary"> |
||||
|
<abp-alert-header size="h3">Header</abp-alert-header> |
||||
|
I'm an abp alert! |
||||
|
</abp-alert> |
||||
|
</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 AlertsModel : PageModel |
||||
|
{ |
||||
|
public void OnGet() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue