surface-ui / surface

A server-side rendering component library for Phoenix
https://surface-ui.org
MIT License
2.08k stars 150 forks source link

LiveComponent/LiveView API Design Question #63

Closed paultannenbaum closed 4 years ago

paultannenbaum commented 4 years ago

Hi @msaraiva, this is an awesome library! I def plan on contributing to this project.

One initial question I have looking over the docs, is why handle_event methods on Surface.{LiveComponent, LiveView} dont use bracket notation the same way Surface.Component does?

In this documentation, for a Surface.Component a click handler is set like this:

<Button click={{ @hideEvent }}>Ok</Button>

Where as on a Surface.{LiveComponent, LiveView} it looks like this:

<Button click="hide">Ok</Button>

I personally find this pretty confusing, as well as harder to parse what is markup versus executed code (I realize it all is actually a sigil that is intepreted and executed, but I hope you get the gist of what I am getting at).

Why not just have all Surface modules use bracket syntax for consistency?

msaraiva commented 4 years ago

Hi @paultannenbaum!

why handle_event methods on Surface.{LiveComponent, LiveView} dont use bracket notation the same way Surface.Component does?

They do :)

Component properties (no matter in what type of component) can either receive a literal like "hide" or an expression like {{ @hideEvent }}, where @hideEvent is just syntactic sugar for assigns.hideEvent.

The golden rule is:

paultannenbaum commented 4 years ago

Thanks for the reply. That makes sense, I guess where I was thrown off is the magic that is happening in a click attribute, where passing it a string invokes the message that ultimately calls the callback function of the string literal, which to be fair is what is happening in phoenix-liveview.

Is there a slack or discord channel for the development of this project? I'd be happy to pick up a couple of these issues, but would want to discuss designs before opening up a PR

msaraiva commented 4 years ago

Hey @paultannenbaum!

Is there a slack or discord channel for the development of this project?

Not yet. Sorry. I'll consider doing that when we have more contributors :)

I'd be happy to pick up a couple of these issues, but would want to discuss designs before opening up a PR

That's awesome! Feel free to drop any question you might have on any existing issue or open new ones if you need. If at some point we need to have a chat, we can arrange that too.

Cheers.