Skip to content

Commit

Permalink
feat: Add ShowNone method to SwapStyleBuilder
Browse files Browse the repository at this point in the history
A new method, ShowNone, has been added to the SwapStyleBuilder class. This method turns off scrolling after a swap and allows for chaining with other methods in the class. Corresponding unit test has also been added to ensure that it returns the correct value.
  • Loading branch information
tanczosm committed Apr 30, 2024
1 parent 75c40d4 commit 75f4ef6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Htmxor/Http/SwapStyleBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ public SwapStyleBuilder ShowWindow(ScrollDirection direction)
return this;
}

/// <summary>
/// Turns off scrolling after swap
/// </summary>
/// <returns>The SwapStyleBuilder instance for chaining.</returns>
public SwapStyleBuilder ShowNone()
{
AddModifier("show", "none");

return this;
}

/// <summary>
/// Builds the swap style command string with all specified modifiers.
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions test/Htmxor.Tests/Http/SwapStyleBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,17 @@ public void SwapStyleBuilder_NullSwapStyle_ReturnsNullStyle()
// Assert
Assert.Null(style);
}

[Fact]
public void SwapStyleBuilder_ShowNone_ReturnsCorrectValue()
{
// Arrange
var builder = new SwapStyleBuilder(SwapStyle.InnerHTML);

// Act
var (_, modifiers) = builder.ShowNone().Build();

// Assert
Assert.Equal("show:none", modifiers);
}
}

0 comments on commit 75f4ef6

Please sign in to comment.