An Argument for Elm/Html

Turns out that wasn’t very difficult. I’ve actually just released an MVP: Orasund/elm-html-style.

It currently has shorthands for every CSS attribute, with variants for constants and for both px and rem.

The tricky bit was actually to parse their BNF-like Notation. I currently only extract from it what I need and throw away the rest. But this definitely has a lot of potential. For now, I will test this version a bit. See if there are any low-hanging fruits left. And then slowly add features as I require them. But I will probably not go down the elm-CSS route.

I think actually having a strongly typed API would be the hard part. I mean, it should be easy to just translate the BNF into a Custom Type. But one would also need to actually find fitting names for everything and design an API that is useful in practice. This might break an automated solution. (at least that’s my feeling after spending less than 8h on that task)

It is currently setup to fail graceful whenever it encounters something unknown. I then get a report of what went wrong and why. I could see a version where you could assist the generator to handle all edge-cases manually.

3 Likes