From d4836e9c2de85b4fa3fde16569334ffd36efcee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Denuzi=C3=A8re?= Date: Wed, 3 Jan 2024 10:21:33 +0100 Subject: [PATCH] feat: Add attr.renderMode as alternative to using an attribute --- src/Bolero.Server/Html.fs | 9 +++++++++ tests/Remoting.Client/Main.fs | 2 -- tests/Remoting.Server/Startup.fs | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Bolero.Server/Html.fs b/src/Bolero.Server/Html.fs index 73f7db92..51183787 100644 --- a/src/Bolero.Server/Html.fs +++ b/src/Bolero.Server/Html.fs @@ -128,3 +128,12 @@ module Html = /// preceded by the standard "html" doctype declaration. /// let doctypeHtml = DoctypeHtmlBuilder() + +#if NET8_0_OR_GREATER + module attr = + + let renderMode (mode: IComponentRenderMode) = + Attr(fun _ b i -> + b.AddComponentRenderMode(mode) + i) +#endif diff --git a/tests/Remoting.Client/Main.fs b/tests/Remoting.Client/Main.fs index 39967520..feb56a23 100644 --- a/tests/Remoting.Client/Main.fs +++ b/tests/Remoting.Client/Main.fs @@ -21,7 +21,6 @@ module Bolero.Tests.Remoting.Client open System.Collections.Generic -open Microsoft.AspNetCore.Components open Microsoft.AspNetCore.Components.Authorization open Bolero open Bolero.Html @@ -221,7 +220,6 @@ let Display model dispatch = } } -[] type MyApp() = inherit ProgramComponent() diff --git a/tests/Remoting.Server/Startup.fs b/tests/Remoting.Server/Startup.fs index 5250de23..bf5c77c4 100644 --- a/tests/Remoting.Server/Startup.fs +++ b/tests/Remoting.Server/Startup.fs @@ -35,6 +35,8 @@ open Bolero.Server open FSharp.SystemTextJson.Swagger module Page = + open Microsoft.AspNetCore.Components + open Microsoft.AspNetCore.Components.Web open Bolero.Html open Bolero.Server.Html @@ -45,12 +47,13 @@ module Page = ``base`` { attr.href "/" } } body { - div { attr.id "main"; comp } + div { attr.id "main"; comp { attr.renderMode RenderMode.InteractiveAuto } } script { attr.src "_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js" } boleroScript } } + [] type Page() = inherit Bolero.Component() override _.Render() = index