diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupDirection.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupDirection.cs new file mode 100644 index 0000000000..53f3c3b6f9 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupDirection.cs @@ -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 + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupSize.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupSize.cs new file mode 100644 index 0000000000..42635dd232 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupSize.cs @@ -0,0 +1,10 @@ +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +{ + public enum AbpButtonGroupSize + { + Default, + Small, + Medium, + Large + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupTagHelper.cs new file mode 100644 index 0000000000..b1958fc8af --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupTagHelper.cs @@ -0,0 +1,15 @@ +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +{ + public class AbpButtonGroupTagHelper : AbpTagHelper + { + public AbpButtonGroupDirection Direction { get; set; } = AbpButtonGroupDirection.Horizontal; + + public AbpButtonGroupSize Size { get; set; } = AbpButtonGroupSize.Default; + + public AbpButtonGroupTagHelper(AbpButtonGroupTagHelperService tagHelperService) + : base(tagHelperService) + { + + } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupTagHelperService.cs new file mode 100644 index 0000000000..602e956e1e --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupTagHelperService.cs @@ -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 + { + 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"); + } + } +} \ No newline at end of file diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Pages/Components/Buttons.cshtml b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Pages/Components/Buttons.cshtml index 0525029462..dc34aa32a9 100644 --- a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Pages/Components/Buttons.cshtml +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Pages/Components/Buttons.cshtml @@ -121,6 +121,53 @@
 <abp-button text="Busy" busy-text="Saving..."/>
+
+
+ + +

# Group Examples

+ +
+
+ + + Left + Middle + Right + + + + Primary + Secondary + Success + + + + Top + Middle + Bottom + +
+
+
+
+<abp-button-group>
+    <abp-button> Left </abp-button>
+    <abp-button> Middle </abp-button>
+    <abp-button> Right </abp-button>
+</abp-button-group>
+
+<abp-button-group size="Large">
+    <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-group>
+
+<abp-button-group direction="Vertical" size="Small">
+    <abp-button button-type="Primary"> Top </abp-button>
+    <abp-button button-type="Warning"> Middle </abp-button>
+    <abp-button button-type="Danger"> Bottom </abp-button>
+</abp-button-group>
 
\ No newline at end of file