• Stars
    star
    173
  • Rank 212,179 (Top 5 %)
  • Language
    F#
  • License
    MIT License
  • Created almost 3 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Powered by .NET blazor!!! ❀ F#

Fun.Blazor Nuget

image

This is a project to make F# developer to write blazor easier.

  1. Use F# ❀️😊 for blazor
  2. Computation expression (CE) style DSL for internal and third party blazor libraries
  3. Dependency injection (html.inject/html.comp)
  4. Adaptive model (adaptiview/AdaptivieForm) (recommend), elmish model (html.elmish)
  5. Giraffe style routing (html.route)
  6. Type safe style (Fun.Css)
  7. Convert html to CE style by Fun.Dev.Tools

Check the WASM Docs for more πŸš€

Benchmark

BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1848/22H2/2022Update/SunValley2) Intel Core i7-1065G7 CPU 1.30GHz, 1 CPU, 8 logical and 4 physical cores .NET SDK=7.0.203 [Host] : .NET 7.0.7 (7.0.723.27404), X64 RyuJIT AVX2 DEBUG DefaultJob : .NET 7.0.7 (7.0.723.27404), X64 RyuJIT AVX2

Method Mean Error StdDev Gen0 Allocated
RenderWithRazorCSharp 411.4 ns 8.22 ns 11.52 ns 0.0896 376 B
RenderWithBolero 0.22.44 986.7 ns 19.21 ns 36.08 ns 0.3529 1480 B
RenderWithFunBlazorCE 793.1 ns 15.77 ns 32.57 ns 0.1736 728 B
RenderWithFunBlazorTemplate 2,901.1 ns 57.36 ns 101.96 ns 1.0109 4232 B
RenderWithFunBlazorSSRTemplate 1,029.7 ns 20.52 ns 37.00 ns 0.1221 512 B

Main projects

  1. Fun.Blazor: help you to use basic dom DSL and state management helpers.

    let demo =
        adaptiview(){
            let! count, setCount = FSharp.Data.Adaptive.cval(1).WithSetter()
            button {
                onclick (fun _ -> setCount (count + 1))
                "Increase"
            }
            div {
                style { color "red" }
                $"value = {count}"
            }
        }
  2. Fun.Blazor.Cli: support hot-reload and help you to generate CE style binding automatically for any blazor third party libraries.

    Docs for how to use it

    Docs for hot-reload

    Samples for using MudBlazor

    open Fun.Blazor
    open MudBlazor
    
    let alertDemo =
        MudCard'.create [
            MudAlert'() {
                Icon Icons.Filled.AccessAlarm
                "This is the way"
            }
        ]