Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": []
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
@namespace FluentUI.Demo.Shared

<p>Alignment of the Stack content elements:</p>
<FluentStack>
<FluentStack HorizontalGap="12px">
<FluentSelect Label="Horizontal"
Items="@(Enum.GetValues<HorizontalAlignment>())"
@bind-Value="@Horizontal" />
<FluentSelect Label="Vertical"
Items="@(Enum.GetValues<VerticalAlignment>())"
@bind-Value="@Vertical" />
<FluentSwitch Label="Reversed"
LabelPosition="LabelPosition.Above"
@bind-Value="@Reversed" />
</FluentStack>

<p>Result:</p>
<FluentStack Orientation="Orientation.Vertical"
HorizontalAlignment="@Horizontal"
VerticalAlignment="@Vertical"
VerticalGap="20"
Reversed="@Reversed"
Style="height: 200px"
Class="container">
<div class="box">Vertical item 1</div>
Expand All @@ -23,7 +27,8 @@
HorizontalAlignment="@Horizontal"
VerticalAlignment="@Vertical"
HorizontalGap="4"
class="container">
Reversed="@Reversed"
Class="container">
<div class="box" style="width: 150px">Horizontal <br />item 1</div>
<div class="box">Horizontal item 2</div>
</FluentStack>
Expand All @@ -33,6 +38,7 @@
{
HorizontalAlignment Horizontal;
VerticalAlignment Vertical;
bool Reversed;
}

<style>
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Components/Stack/FluentStack.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@namespace Microsoft.FluentUI.AspNetCore.Components
@inherits FluentComponentBase

<div id="@Id" class="@ClassValue" style="@StyleValue" @attributes="AdditionalAttributes">
<div id="@Id" class="@ClassValue" style="@StyleValue" @attributes="AdditionalAttributes" reverse="@Reversed">
@ChildContent
</div>
6 changes: 6 additions & 0 deletions src/Core/Components/Stack/FluentStack.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ public partial class FluentStack : FluentComponentBase
[Parameter]
public string? VerticalGap { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the stack is reversed.
/// </summary>
[Parameter]
public bool? Reversed { get; set; }

/// <summary>
/// Gets or sets the content to be rendered inside the component.
/// </summary>
Expand Down
10 changes: 10 additions & 0 deletions src/Core/Components/Stack/FluentStack.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@
display: flex;
flex-direction: row;
}

.fluent-stack-vertical[reverse] {
display: flex;
flex-direction: column-reverse;
}

.fluent-stack-horizontal[reverse] {
display: flex;
flex-direction: row-reverse;
}
16 changes: 16 additions & 0 deletions tests/Core/Components/Stack/FluentStackTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,20 @@
// Assert
Assert.Contains(expectedStyle, styles);
}

[Theory]
[InlineData(true, true)]
[InlineData(false, false)]
[InlineData(null, false)]
public void FluentStack_Reverse(bool? reversed, bool hasExpectedAttribute)
{
// Arrange
var cut = Render(@<FluentStack Reversed="@reversed" />);

// Act
var hasAttribute = cut.Find("div").Attributes.Any(i => i.Name == "reverse");

// Assert
Assert.Equal(hasExpectedAttribute, hasAttribute);
}
}