rtfeldman / elm-css

Typed CSS in Elm.
https://package.elm-lang.org/packages/rtfeldman/elm-css/latest
BSD 3-Clause "New" or "Revised" License
1.24k stars 197 forks source link

toUnstyled function that can take Lists or a Document #490

Open MelvIsntNormal opened 5 years ago

MelvIsntNormal commented 5 years ago

Currently, with the Document type you need to use List.map toUnstyled to convert to unstyled Html. This would result in a style tag being created for each element in that list, when it may be better to merge them into one. Would it be worth creating a toUnstyled function for either a list of Html or a Document?

Erudition commented 5 years ago

Ohh is that what you have to do?

I've just been wrapping my view function in a list with the toUnstyled function being called on it. Imagine my surprise when seeing the error:

-- TYPE MISMATCH -------------------------------------------------- elm/Main.elm

Something is off with the 1st branch of this `case` expression:

214|>            { title = "title"
215|>            , body = [ view ]
216|>            }

The 1st branch is a record of type:

    { body : List (Html Msg), title : String }

But the type annotation on `view` says it should be:

    Browser.Document Msg

Which is the same thing... and then fixing that, it complains about toUnstyled producing VirtualDom.Node instead of Html... also the same thing!