Skip to content

Commit

Permalink
feat(blazorui): add FullWidth parameter to BitSeparator #8511 (#8542)
Browse files Browse the repository at this point in the history
  • Loading branch information
msynk authored Sep 7, 2024
1 parent 8a8cea7 commit fbbacc2
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ public partial class BitSeparator : BitComponentBase
/// </summary>
[Parameter] public RenderFragment? ChildContent { get; set; }

/// <summary>
/// Renders the separator in full width of its container.
/// </summary>
[Parameter, ResetStyleBuilder]
public bool FullWidth { get; set; }

/// <summary>
/// Whether the element is a vertical separator.
/// </summary>
Expand All @@ -34,4 +40,9 @@ protected override void RegisterCssClasses()
_ => "bit-spr-ctr"
});
}

protected override void RegisterCssStyles()
{
StyleBuilder.Register(() => FullWidth ? "width:100%" : string.Empty);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

.bit-spr-cnt {
position: relative;
display: inline-block;
color: $clr-fg-pri;
display: inline-block;
background: $clr-bg-pri;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
<ComponentExampleBox Title="Basic" RazorCode="@example1RazorCode" Id="example1">
<ExamplePreview>
<div>
<BitLabel>Empty separator</BitLabel>
<div>Empty separator</div>
<BitSeparator />
<br />
<BitLabel>Separator with text</BitLabel>
<div>Separator with text</div>
<BitSeparator>Text</BitSeparator>
<br />
<BitLabel>Separator with icon</BitLabel>
<div>Separator with icon</div>
<BitSeparator><BitIcon IconName="Clock" /></BitSeparator>
</div>
</ExamplePreview>
</ComponentExampleBox>
<ComponentExampleBox Title="Vertical" RazorCode="@example2RazorCode" Id="example1">
<ComponentExampleBox Title="Vertical" RazorCode="@example2RazorCode" Id="example2">
<ExamplePreview>
<div class="custom-horizontal-layout">
<span>Item 1</span>
Expand All @@ -38,11 +38,11 @@
</div>
</ExamplePreview>
</ComponentExampleBox>
<ComponentExampleBox Title="AlignContent" RazorCode="@example3RazorCode" Id="example1">
<ComponentExampleBox Title="AlignContent" RazorCode="@example3RazorCode" Id="example3">
<ExamplePreview>
<div style="height: 28rem">
<div>
<BitLabel>Horizontal separator with text</BitLabel>
<div>Horizontal separator with text</div>
<BitSeparator AlignContent="@BitSeparatorAlignContent.Center">Center</BitSeparator>
<br />
<BitSeparator AlignContent="@BitSeparatorAlignContent.Start">Start</BitSeparator>
Expand All @@ -51,14 +51,24 @@
</div>
<br /><br />
<div style="height: 13rem">
<BitLabel>Vertical separator with text</BitLabel>
<br />
<div>Vertical separator with text</div><br />
<BitSeparator Vertical AlignContent="@BitSeparatorAlignContent.Center">Center</BitSeparator>
<BitSeparator Vertical AlignContent="@BitSeparatorAlignContent.Start">Start</BitSeparator>
<BitSeparator Vertical AlignContent="@BitSeparatorAlignContent.End">End</BitSeparator>
</div>
</div>
</ExamplePreview>
</ComponentExampleBox>
<ComponentExampleBox Title="FullWidth" RazorCode="@example4RazorCode" Id="example4">
<ExamplePreview>
<div>While using inside a flex container with align-items css style:</div>
<br /><br />
<div style="display:flex;flex-direction:column;align-items:center">
<BitSeparator>Normal</BitSeparator>
<br />
<BitSeparator FullWidth>FullWidth</BitSeparator>
</div>
</ExamplePreview>
</ComponentExampleBox>
</ComponentDemo>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public partial class BitSeparatorDemo
Type = "BitSeparatorAlignContent",
DefaultValue = "BitSeparatorAlignContent.Center",
Description = "Where the content should be aligned in the separator.",
LinkType = LinkType.Link,
Href = "#separator-align-enum",
LinkType = LinkType.Link
},
new()
{
Expand All @@ -21,6 +21,13 @@ public partial class BitSeparatorDemo
Description = "The content of the Separator, it can be any custom tag or text."
},
new()
{
Name = "FullWidth",
Type = "bool",
DefaultValue = "false",
Description = "Renders the separator in full width of its container."
},
new()
{
Name = "Vertical",
Type = "bool",
Expand Down Expand Up @@ -97,6 +104,12 @@ public partial class BitSeparatorDemo
<BitSeparator Vertical AlignContent=""@BitSeparatorAlignContent.Center"">Center</BitSeparator>
<BitSeparator Vertical AlignContent=""@BitSeparatorAlignContent.Start"">Start</BitSeparator>
<BitSeparator Vertical AlignContent=""@BitSeparatorAlignContent.End"">End</BitSeparator>";

private readonly string example4RazorCode = @"
<div style=""display:flex;flex-direction:column;align-items:center"">
<BitSeparator>Normal</BitSeparator>
<BitSeparator FullWidth>FullWidth</BitSeparator>
</div>";
}


0 comments on commit fbbacc2

Please sign in to comment.