Dzoukr / Feliz.Bulma

Bulma UI (https://bulma.io) wrapper for amazing Feliz DSL
https://dzoukr.github.io/Feliz.Bulma/
MIT License
66 stars 19 forks source link

Generate prop aliases for specific elements where applicable #5

Closed Zaid-Ajaj closed 4 years ago

Zaid-Ajaj commented 4 years ago

Generate prop aliases for specific elements such that there is no need to fallback to prop for "most commonly used" properties:

Before

Bulma.columns [
  Bulma.column [
    column.is2
    prop.children [
      Bulma.button [
        button.isPrimary
        prop.onClick (fun _ -> DoStuff)
        prop.text "Do Stuff"
      ]
    ]
  ]
]

After

Bulma.columns [
  Bulma.column [
    column.is2
    column.children [
      Bulma.button [
        button.isPrimary
        button.onClick (fun _ -> DoStuff)
        button.text "Do Stuff"
      ]
    ]
  ]
]

I think this looks much cleaner and symmetric. Users would only fallback to prop when needing some exotic properties.

"Most common properties" are things like prop.text, prop.children, prop.onClick (button), prop.onChange (input), prop.valueOrDefault (input), prop.key, prop.src (image) etc.

What do you think about this?

Dzoukr commented 4 years ago

Hmmmmm I am not sure about this, frankly. The biggest benefit of this small library is that it's nothing more than just extension to Feliz. I tend to build on Feliz instead of overloading / shadowing its functionality. The message here is: Hey, here you have some Feliz divs, inputs, buttons with pre-selected className, but for everything else use the original syntax. Whatever you add into future versions (if not breaking change) of Feliz, it should be available immediatelly and used with existing extensions. I actually have that in README as advantage of this library, that most of the time you remaing with known existing Feliz syntax.

I agree it would look way more concise to have button.onClick instead of prop.onClick but thinking if this should be concern of extension.

Damn, you made me thinking again! 😄

Zaid-Ajaj commented 4 years ago

It is not really a big deal to be honest. From a user point of view I am following a vague guideline called "Don't make me think" :smile: and in this case I was trying to minimize the number of places the user has to look for properties if he or she already started looking under the button module. Even Fulma does a little bit of this where it adds Button.OnClick and Input.OnChange so I thought it might be nice here too.