mdgriffith / style-elements

Create styles that don't mysteriously break!
http://package.elm-lang.org/packages/mdgriffith/style-elements/latest
BSD 3-Clause "New" or "Revised" License
445 stars 49 forks source link

Conditional helpers for attributes #130

Open kuon opened 6 years ago

kuon commented 6 years ago

It would be great to have conditional helpers for attributes, like Element.when.

Usage:

row style [ when config.spaced (spacing 20) ] []

Maybe use another name to avoid conflict with Element.when.

My current workaround:

whenAttr: Bool -> Element.Attribute variation msg -> Element.Attribute variation msg
whenAttr val attr =
    if val then
        attr
    else
        attribute "data-none" ""