matken11235/html-styled-extra/1.0.1

NOTE: the latest version is 1.0.2

Renamed to ken-matsui/html-styled-extra. It is published under that name, and new versions come out there.

Versions published as matken11235/html-styled-extra still install under that name. 2 versions of 3 come from the new location (see their notes). 1 version could not be recovered and cannot be installed.

Rerouted (cache, verified). The original is gone. This copy comes from a Lamdera package cache made before it went. The Lamdera package server serves a copy recovered from a Lamdera package cache from 2021-02-13.

What we checked: Rebuilt from the unpacked sources in a Lamdera package cache (5 copies agree), which Elm only writes after the published SHA-1 checked out; elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip is our own, so its SHA-1 is not the published one.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/matken11235/html-styled-extra/zipball/1.0.1/

Html.Styled.Extra

Convenience functionality on Html.Styled

static : Html Never -> Html msg

Embedding static html.

The type argument Never in Html Never tells us that the html has no event handlers attached, it will not generate any messages. We may want to embed such static html into arbitrary views, while using types to enforce the staticness. That is what this function provides.

Note: To call this function, the argument need not be literally of type Html Never. It suffices if it is a fully polymorphic (in the message type) Html value. For example, this works: static (Html.Styled.text "abcdef").

nothing : Html msg

Render nothing.

A more idiomatic way of rendering nothing compared to using Html.Styled.text "" directly.

viewIf : Bool -> Html msg -> Html msg

A function to only render html under a certain condition

fieldView : Model -> Html Msg
fieldView model =
    div
        []
        [ fieldInput model
        , viewIf
            (not <| List.isEmpty model.errors)
            errorsView
        ]
viewIfLazy : Bool -> (() -> Html msg) -> Html msg

Just like viewIf except its more performant. In viewIf, the html is always evaluated, even if its not rendered. viewIfLazy only evaluates your view function if it needs to. The trade off is your view function needs to accept a unit type (()) as its final parameter

fieldView : Model -> Html Msg
fieldView model =
    div
        []
        [ fieldInput model
        , viewIfLazy
            (not <| List.isEmpty model.errors)
            (\() -> errorsView)
        ]
viewMaybe : (a -> Html msg) -> Maybe a -> Html msg

Renders Html.Styled.nothing in case of Nothing, uses the provided function in case of Just.

viewMaybePost : Maybe Post -> Html Msg
viewMaybePost maybePost =
    viewMaybe viewPost maybePost


viewPost : Post -> Html Msg