fable-compiler / fable-react

Fable bindings and helpers for React and React Native
MIT License
273 stars 67 forks source link

`HTMLAttr.Class` alternative that works with a list of strings #206

Closed JaggerJo closed 3 years ago

JaggerJo commented 3 years ago

Using HTMLAttr.Class in combination with a CSS type provider or CSS class literals lets to messy code. Would be cool to have an alternative case that takes a list of strings.

Example:

Class (sprintf "%s %s %s" AdminCss.button AdminCss.buttonPrimary AdminCss.buttonLarge)

Instead I'd like to do something like this:

Classes [ AdminCss.button; AdminCss.buttonPrimary; AdminCss.buttonLarge ]

Would be a nice addition IMHO.

I use a helper function for now..

MangelMaxime commented 3 years ago

Hello,

there already are some helpers to work with classes:

https://github.com/fable-compiler/fable-react/blob/81ca109cfd296357ea1359391e8de7dc90b4f771/src/Fable.React.Helpers.fs#L386-L395