From fe429bf7a91034df098708d026a5cbb9252702f9 Mon Sep 17 00:00:00 2001 From: yekalkan Date: Mon, 14 May 2018 10:20:46 +0300 Subject: [PATCH] abp-table-style tag helper --- .../TagHelpers/Table/AbpTableStyle.cs | 16 ++++++++++ .../Table/AbpTableStyleTagHelper.cs | 19 ++++++++++++ .../Table/AbpTableStyleTagHelperService.cs | 29 +++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableStyle.cs create mode 100644 src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableStyleTagHelper.cs create mode 100644 src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableStyleTagHelperService.cs diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableStyle.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableStyle.cs new file mode 100644 index 0000000000..cd6dfd64fc --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableStyle.cs @@ -0,0 +1,16 @@ +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Table +{ + public enum AbpTableStyle + { + Default, + Primary, + Secondary, + Success, + Danger, + Warning, + Info, + Light, + Dark, + Active, + } +} \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableStyleTagHelper.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableStyleTagHelper.cs new file mode 100644 index 0000000000..dadb22af1c --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableStyleTagHelper.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Razor.TagHelpers; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Table +{ + [HtmlTargetElement("tr")] + [HtmlTargetElement("td")] + public class AbpTableStyleTagHelper : AbpTagHelper + { + public AbpTableStyle AbpTableStyle { get; set; } = AbpTableStyle.Default; + + public AbpTableStyle AbpDarkTableStyle { get; set; } = AbpTableStyle.Default; + + public AbpTableStyleTagHelper(AbpTableStyleTagHelperService tagHelperService) + : base(tagHelperService) + { + + } + } +} diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableStyleTagHelperService.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableStyleTagHelperService.cs new file mode 100644 index 0000000000..716233b888 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableStyleTagHelperService.cs @@ -0,0 +1,29 @@ +using Microsoft.AspNetCore.Razor.TagHelpers; +using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Table +{ + public class AbpTableStyleTagHelperService : AbpTagHelperService + { + public override void Process(TagHelperContext context, TagHelperOutput output) + { + SetStyle(context,output); + } + + protected virtual void SetStyle(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.AbpTableStyle != AbpTableStyle.Default) + { + output.Attributes.AddClass("table-" + TagHelper.AbpTableStyle.ToString().ToLowerInvariant()); + } + } + + protected virtual void SetDarkTableStyle(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.AbpDarkTableStyle != AbpTableStyle.Default) + { + output.Attributes.AddClass("bg-" + TagHelper.AbpDarkTableStyle.ToString().ToLowerInvariant()); + } + } + } +} \ No newline at end of file