diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableBorderStyle.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableBorderStyle.cs new file mode 100644 index 0000000000..374f04b7b2 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableBorderStyle.cs @@ -0,0 +1,9 @@ +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Table +{ + public enum AbpTableBorderStyle + { + Default, + Bordered, + Borderless + } +} \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableHeaderTheme.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableHeaderTheme.cs new file mode 100644 index 0000000000..dbcd379917 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableHeaderTheme.cs @@ -0,0 +1,9 @@ +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Table +{ + public enum AbpTableHeaderTheme + { + Default, + Light, + Dark + } +} \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableTagHelper.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableTagHelper.cs new file mode 100644 index 0000000000..7f94693258 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableTagHelper.cs @@ -0,0 +1,27 @@ +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Table +{ + public class AbpTableTagHelper : AbpTagHelper + { + public bool? Responsive { get; set; } + public bool? ResponsiveSm { get; set; } + public bool? ResponsiveMd { get; set; } + public bool? ResponsiveLg { get; set; } + public bool? ResponsiveXl { get; set; } + + public bool? DarkTheme { get; set; } + + public bool? StripedRows { get; set; } + + public bool? HoverableRows { get; set; } + + public bool? Small { get; set; } + + public AbpTableBorderStyle BorderStyle { get; set; } = AbpTableBorderStyle.Default; + + public AbpTableTagHelper(AbpTableTagHelperService tagHelperService) + : base(tagHelperService) + { + + } + } +} diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableTagHelperService.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableTagHelperService.cs new file mode 100644 index 0000000000..63fec5ee92 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Table/AbpTableTagHelperService.cs @@ -0,0 +1,99 @@ +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 AbpTableTagHelperService : AbpTagHelperService + { + public override void Process(TagHelperContext context, TagHelperOutput output) + { + output.TagName = "table"; + output.Attributes.AddClass("table"); + + SetResponsiveness(context, output); + SetTheme(context, output); + SetHoverableRows(context, output); + SetBorderStyle(context, output); + SetSmall(context, output); + SetStripedRows(context, output); + + } + + protected virtual void SetResponsiveness(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.Responsive ?? false) + { + output.PreElement.SetHtmlContent("
"); + } + else if (TagHelper.ResponsiveSm ?? false) + { + output.PreElement.SetHtmlContent("
"); + } + else if (TagHelper.ResponsiveMd ?? false) + { + output.PreElement.SetHtmlContent("
"); + } + else if (TagHelper.ResponsiveLg ?? false) + { + output.PreElement.SetHtmlContent("
"); + } + else if (TagHelper.ResponsiveXl ?? false) + { + output.PreElement.SetHtmlContent("
"); + } + else + { + return; + } + + output.PostElement.SetHtmlContent("
"); + } + + protected virtual void SetTheme(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.DarkTheme ?? false) + { + output.Attributes.AddClass("table-dark"); + } + } + + protected virtual void SetStripedRows(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.StripedRows ?? false) + { + output.Attributes.AddClass("table-striped"); + } + } + + protected virtual void SetHoverableRows(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.HoverableRows ?? false) + { + output.Attributes.AddClass("table-hover"); + } + } + + protected virtual void SetSmall(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.Small ?? false) + { + output.Attributes.AddClass("table-sm"); + } + } + + protected virtual void SetBorderStyle(TagHelperContext context, TagHelperOutput output) + { + switch (TagHelper.BorderStyle) + { + case AbpTableBorderStyle.Default: + return; + case AbpTableBorderStyle.Bordered: + output.Attributes.AddClass("table-bordered"); + return; + case AbpTableBorderStyle.Borderless: + output.Attributes.AddClass("table-borderless"); + return; + } + } + } +} \ No newline at end of file