matken11235/html-styled-extra/1.0.0

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 (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/ken-matsui/html-styled-extra.

What we checked: The repo moved to github.com/ken-matsui/html-styled-extra. Rebuilt with git archive from commit 24da6cf8c6a2 of https://github.com/ken-matsui/html-styled-extra (zip prefix matken11235-html-styled-extra-24da6cf/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 c591713a5f08be2e49c9056829d292eef6b4953e.

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.0/

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