mirror of https://github.com/abpframework/abp.git
5 changed files with 140 additions and 0 deletions
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button |
|||
{ |
|||
public enum AbpButtonGroupDirection |
|||
{ |
|||
Horizontal, |
|||
Vertical |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button |
|||
{ |
|||
public enum AbpButtonGroupSize |
|||
{ |
|||
Default, |
|||
Small, |
|||
Medium, |
|||
Large |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button |
|||
{ |
|||
public class AbpButtonGroupTagHelper : AbpTagHelper<AbpButtonGroupTagHelper, AbpButtonGroupTagHelperService> |
|||
{ |
|||
public AbpButtonGroupDirection Direction { get; set; } = AbpButtonGroupDirection.Horizontal; |
|||
|
|||
public AbpButtonGroupSize Size { get; set; } = AbpButtonGroupSize.Default; |
|||
|
|||
public AbpButtonGroupTagHelper(AbpButtonGroupTagHelperService tagHelperService) |
|||
: base(tagHelperService) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
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 AbpButtonGroupTagHelperService : AbpTagHelperService<AbpButtonGroupTagHelper> |
|||
{ |
|||
public override void Process(TagHelperContext context, TagHelperOutput output) |
|||
{ |
|||
AddButtonGroupClass(context, output); |
|||
AddSizeClass(context, output); |
|||
AddAttributes(context, output); |
|||
} |
|||
|
|||
protected virtual void AddSizeClass(TagHelperContext context, TagHelperOutput output) |
|||
{ |
|||
switch (TagHelper.Size) |
|||
{ |
|||
case AbpButtonGroupSize.Default: |
|||
break; |
|||
case AbpButtonGroupSize.Small: |
|||
output.Attributes.AddClass("btn-group-sm"); |
|||
break; |
|||
case AbpButtonGroupSize.Medium: |
|||
output.Attributes.AddClass("btn-group-md"); |
|||
break; |
|||
case AbpButtonGroupSize.Large: |
|||
output.Attributes.AddClass("btn-group-lg"); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
protected virtual void AddButtonGroupClass(TagHelperContext context, TagHelperOutput output) |
|||
{ |
|||
switch (TagHelper.Direction) |
|||
{ |
|||
case AbpButtonGroupDirection.Horizontal: |
|||
output.Attributes.AddClass("btn-group"); |
|||
break; |
|||
case AbpButtonGroupDirection.Vertical: |
|||
output.Attributes.AddClass("btn-group-vertical"); |
|||
break; |
|||
default: |
|||
output.Attributes.AddClass("btn-group"); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
protected virtual void AddAttributes(TagHelperContext context, TagHelperOutput output) |
|||
{ |
|||
output.Attributes.Add("role", "group"); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue