Browse Source

Vertical/Horizontal align for grid taghelpers

pull/272/head
yekalkan 9 years ago
parent
commit
1edb8b6296
  1. 4
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Grid/AbpColumnTagHelper.cs
  2. 17
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Grid/AbpColumnTagHelperService.cs
  3. 1
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Grid/AbpContainerTagHelperService.cs
  4. 4
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Grid/AbpRowTagHelper.cs
  5. 29
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Grid/AbpRowTagHelperService.cs
  6. 12
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Grid/HorizontalAlign.cs
  7. 10
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Grid/VerticalAlign.cs

4
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Grid/AbpColumnTagHelper.cs

@ -2,7 +2,9 @@
{ {
public class AbpColumnTagHelper : AbpTagHelper<AbpColumnTagHelper, AbpColumnTagHelperService> public class AbpColumnTagHelper : AbpTagHelper<AbpColumnTagHelper, AbpColumnTagHelperService>
{ {
public string Breakpoint { get; set; } public string Size { get; set; }
public VerticalAlign VAlign { get; set; } = VerticalAlign.Default;
public AbpColumnTagHelper(AbpColumnTagHelperService tagHelperService) public AbpColumnTagHelper(AbpColumnTagHelperService tagHelperService)
: base(tagHelperService) : base(tagHelperService)

17
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Grid/AbpColumnTagHelperService.cs

@ -9,17 +9,24 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid
{ {
public override void Process(TagHelperContext context, TagHelperOutput output) public override void Process(TagHelperContext context, TagHelperOutput output)
{ {
output.Attributes.AddClass("col"); output.TagName = "div";
SetBreakpoint(output); ProcessColClass(output);
} }
protected virtual void SetBreakpoint(TagHelperOutput output) protected virtual void ProcessColClass(TagHelperOutput output)
{ {
if (!string.IsNullOrWhiteSpace(TagHelper.Breakpoint)) output.Attributes.AddClass("col" + (string.IsNullOrWhiteSpace(TagHelper.Size)? "" : "-" + TagHelper.Size));
}
protected virtual void ProcessVerticalAlign(TagHelperOutput output)
{
if (TagHelper.VAlign == VerticalAlign.Default)
{ {
output.Attributes.AddClass("col-"+TagHelper.Breakpoint); return;
} }
output.Attributes.AddClass("align-self-" + TagHelper.VAlign.ToString().ToLowerInvariant());
} }
} }
} }

1
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Grid/AbpContainerTagHelperService.cs

@ -8,6 +8,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid
{ {
public override void Process(TagHelperContext context, TagHelperOutput output) public override void Process(TagHelperContext context, TagHelperOutput output)
{ {
output.TagName = "div";
output.Attributes.AddClass("container"); output.Attributes.AddClass("container");
} }

4
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Grid/AbpRowTagHelper.cs

@ -2,6 +2,10 @@
{ {
public class AbpRowTagHelper : AbpTagHelper<AbpRowTagHelper, AbpRowTagHelperService> public class AbpRowTagHelper : AbpTagHelper<AbpRowTagHelper, AbpRowTagHelperService>
{ {
public VerticalAlign VAlign { get; set; } = VerticalAlign.Default;
public HorizontalAlign HAlign { get; set; } = HorizontalAlign.Default;
public AbpRowTagHelper(AbpRowTagHelperService tagHelperService) public AbpRowTagHelper(AbpRowTagHelperService tagHelperService)
: base(tagHelperService) : base(tagHelperService)
{ {

29
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Grid/AbpRowTagHelperService.cs

@ -1,4 +1,5 @@
using System.Text; using System.ComponentModel;
using System.Text;
using Microsoft.AspNetCore.Razor.TagHelpers; using Microsoft.AspNetCore.Razor.TagHelpers;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers;
@ -8,8 +9,32 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid
{ {
public override void Process(TagHelperContext context, TagHelperOutput output) public override void Process(TagHelperContext context, TagHelperOutput output)
{ {
output.TagName = "div";
output.Attributes.AddClass("row"); output.Attributes.AddClass("row");
ProcessVerticalAlign(output);
ProcessHorizontalAlign(output);
}
protected virtual void ProcessVerticalAlign(TagHelperOutput output)
{
if (TagHelper.VAlign == VerticalAlign.Default)
{
return;
}
output.Attributes.AddClass("align-items-" + TagHelper.VAlign.ToString().ToLowerInvariant());
} }
protected virtual void ProcessHorizontalAlign(TagHelperOutput output)
{
if (TagHelper.HAlign == HorizontalAlign.Default)
{
return;
}
output.Attributes.AddClass("justify-content-" + TagHelper.HAlign.ToString().ToLowerInvariant());
}
} }
} }

12
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Grid/HorizontalAlign.cs

@ -0,0 +1,12 @@
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid
{
public enum HorizontalAlign
{
Default,
Start,
Center,
Around,
Between,
End
}
}

10
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Grid/VerticalAlign.cs

@ -0,0 +1,10 @@
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid
{
public enum VerticalAlign
{
Default,
Start,
Center,
End
}
}
Loading…
Cancel
Save