seanhess / web-view

Typed HTML with simplified layout, and easy composable styles. Inspired by Tailwindcss and Elm UI
Other
34 stars 1 forks source link

Add extClass convinience utiltiy for use-cases where CSS is provided externally #5

Closed kfigiela closed 3 months ago

kfigiela commented 3 months ago

In response to the question in the other PR https://github.com/seanhess/web-view/pull/3#discussion_r1638420071 this helper makes it easier to add classes to HTML elements that are defined in 3rd party CSS. This is what I've been using in my project. Alternatively, IsString instance could be added to Class so addClass can be used directly. This however, can cause some confusion for people who will use web-view "as prescribed", as it'd be pretty easy to confuse addClass $ cls "foo" & prop "foo" "bar" with addClass "foo" & prop "foo" "bar"

seanhess commented 3 months ago

Great, thanks for this!

I feel like the name cls_ is confusing, because it's not really an alternative to the cls constructor, it's an alternative to addClass. What do you think about naming it something like addClass_ or addClassName? It helps communicate that it's not setting the entire class attribute, just adding a single class (it handles spaces for you, etc)

kfigiela commented 3 months ago

Yeah, naming is hard. Personally, I'd pick something short as this is going to be used a lot if user decides to use external CSS. How about externalClass or extClass so it's harder to confuse?

seanhess commented 3 months ago

Let's go with extClass since it'll be used frequently

kfigiela commented 3 months ago

Adjusted & force pushed