-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change time based config properties to use timespan, add tests
- Loading branch information
Showing
27 changed files
with
574 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Htmxor.Configuration.Serialization; | ||
using Microsoft.AspNetCore.Components; | ||
using System.Text.Json; | ||
|
||
namespace Htmxor.Configuration; | ||
|
||
/// <summary> | ||
/// This component will render a meta tag with the serialized <see cref="HtmxConfig"/> object, | ||
/// enabling customization of Htmx. | ||
/// </summary> | ||
/// <remarks> | ||
/// Configure the <see cref="HtmxConfig"/> via the | ||
/// <see cref="HtmxorApplicationBuilderExtensions.AddHtmx(Microsoft.Extensions.Hosting.IHostApplicationBuilder, Action{Htmxor.Configuration.HtmxConfig}?)"/> | ||
/// method. | ||
/// </remarks> | ||
public class HtmxConfigHeadOutlet : IComponent | ||
{ | ||
[Inject] private HtmxConfig Config { get; set; } = default!; | ||
|
||
/// <inheritdoc/> | ||
public void Attach(RenderHandle renderHandle) | ||
{ | ||
var json = JsonSerializer.Serialize(Config, HtmxConfig.SerializerOptions); | ||
var json = JsonSerializer.Serialize(Config, HtmxConfigJsonSerializerContext.Default.HtmxConfig); | ||
renderHandle.Render(builder => | ||
{ | ||
builder.AddMarkupContent(0, @$"<meta name=""htmx-config"" content='{json}'>"); | ||
}); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public Task SetParametersAsync(ParameterView parameters) => Task.CompletedTask; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
namespace Htmxor.Configuration; | ||
|
||
/// <summary> | ||
/// The behavior for a boosted link on page transitions. | ||
/// </summary> | ||
public enum ScrollBehavior | ||
{ | ||
/// <summary> | ||
/// Smooth will smooth-scroll to the top of the page. | ||
/// </summary> | ||
Smooth, | ||
/// <summary> | ||
/// Auto will behave like a vanilla link. | ||
/// </summary> | ||
Auto, | ||
} | ||
|
12 changes: 12 additions & 0 deletions
12
src/Htmxor/Configuration/Serialization/HtmxConfigJsonSerializerContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Htmxor.Configuration.Serialization; | ||
|
||
[JsonSourceGenerationOptions( | ||
Check warning on line 5 in src/Htmxor/Configuration/Serialization/HtmxConfigJsonSerializerContext.cs GitHub Actions / create-nuget
Check warning on line 5 in src/Htmxor/Configuration/Serialization/HtmxConfigJsonSerializerContext.cs GitHub Actions / infer-sharp
Check warning on line 5 in src/Htmxor/Configuration/Serialization/HtmxConfigJsonSerializerContext.cs GitHub Actions / run-test (net8.0)
|
||
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, | ||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, | ||
Converters = [typeof(JsonCamelCaseStringEnumConverter), typeof(TimespanMillisecondJsonConverter)])] | ||
[JsonSerializable(typeof(HtmxConfig))] | ||
internal sealed partial class HtmxConfigJsonSerializerContext : JsonSerializerContext | ||
{ | ||
} |
Oops, something went wrong.