New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
attr and slot functions for LiveComponent? #2407
Comments
I think it would be awesome to migrate to actual components. We were a bit too early in our own component system :D |
Yes, for sure! Now we have a much better base to build components. I found very helpful the |
One of the considerations when it comes to |
I didn't think about runtime or compilation time validations. It's interesting. Maybe for Live Components can have both validations at runtime and at compilation time. Runtime validations can be executed just before run So Live Components and Phoenix Components have same syntax for these macros but no exactly the same behavior. Of course, it is a suggestion. I think it would make sense. It's strange to have these useful macros on Phoenix Components and not on Live Components. |
I am fine with compile-time only validation. It will provide large benefits and with type systems work the types are only going to get better. |
It is more nuanced than compile/runtime. The biggest issue is the distinction between the assigns you pass to |
And what about using separate macros for properties ( Then Regular components could then just support the |
I like the idea to start with only compile-time validation. It would be easier to implement because a lot of work has already been done. Anyway, let me argue in favor of runtime validations just for future reference:
IMHO I think we should declare the former because it is the real input for the component. The result of the
Sorry, I don't understand this problem clearly. At the end of the day, both ways call I can see a small problem with the @dvic I don't have enough experience with Surface to have an opinion about it 😅 Let's see what other people think If you agree with at least compile-time validation I can give it a try. I don't know if I will have enough expertise to do it, I have never looked at the LiveView code in depth. |
Hello again! Not sure if you still think it is a good or a bad idea. In Phoenix Dashboard we "solved" the situation creating "function components" that internally call to This way, we have attributes/slots validations, default values and documentation in live components. I think this is something good. However, the problem is that if we modify the live component we can forget to update our "function component". Related code should be close. I still see the gap between function and live components. Feel free to close the issue if you think so :) |
This isn't planned at the moment because the state + render model doesn't quite fit 1:1 with declarative assigns. We may revisit this in the future |
Hello,
I'm working on migrating the live view dashboard to the new Phoenix.Component: phoenixframework/phoenix_live_dashboard#394
I realized that most of the code of LiveComponents are related to validations attributes or slots, ie: https://github.com/phoenixframework/phoenix_live_dashboard/blob/master/lib/phoenix/live_dashboard/components/nav_bar_component.ex#L16-L168
AFAIK we cannot use
attr
orslot
macros in a LiveComponent, but I think it could reduce a lot of code for these components. Do you have any plans to add them? What are the difficulties you think may arise? May I help?Thank you
The text was updated successfully, but these errors were encountered: