jmpavlick/elm-css-with-context/1.0.0

WithContext

Cleaner, hack-free way to pass contexts to Elm view functions.

Simple port of arowM/elm-html-with-context to make it work with rtfeldman/elm-css.

Types

type WithContext context msg

An opaque type for representing Html with a context.

  • A Node is a wrapper for "a function that can take a list of functions that take a context and return a Html value, and return a function that takes a context and returns a Html value".
  • A Leaf is a wrapper for "a function that takes a context, and returns a Html value".

Converters

fromHtml : (context -> Html msg) -> WithContext context msg

A constructor for WithContext from Html.

toHtml : context -> WithContext context msg -> Html msg

Convert to Html.

Core functions

(context -> List (Html msg) -> Html msg)
-> List (WithContext context msg)
-> WithContext context msg

Custom node.

text : (context -> String) -> WithContext context msg

Text node. We have to explicitly define this, because it's the only Html function that doesn't take a List Html msg as an argument.

Low level functions

(context -> subContext)
-> WithContext subContext msg
-> WithContext context msg

This function is supposed to be used with functions in WithContext.Lazy. Please see actual use case for detail.