-
Notifications
You must be signed in to change notification settings - Fork 19
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
Missing documentation for passing objects as attributes #23
Comments
@mark-russ Regarding your question earlier, would something like this be clear enough or would it need more details? |
I think this would be immensely helpful! My knowledge on how frontend frameworks should work is pretty much nonexistent. If I wanted to pass a typed prop (like say, boolean false) from server-to-component, is this where server-side-rendering would come into play? I would like to use web components from the top-level, passing typed values into them without having to nest them in a main component, which is something that Svelte also seems to lack the capabilities of (Svelte actually has a few interesting quirks because unlike this project, it was not designed with native web-components-first in mind). |
If you use web components in native HTML you can't use advanced features such as However you could still pass complex object through JS: some-native-html-page.html
I haven't tested this but you eventually get the idea of how to get this working. However if the data your want to inject comes from the server (something like
Or even using slots might work, and that would be pretty cool:
|
I will play around with slots! Both of your suggestions seem like good ones. I'll work on figuring out a decent, reusable/convenient way of doing your first suggestion which also seems very viable. Thanks! |
The workaround here would be to wrap the HTML elements in a Lego component and then benefit from the enriched atributes for passing complex objects ( However when I do need to pass complex objects I do as you suggest, Another possibility I'm considering is to manipulate a global stateful object inspired from the ContextAPI, but simpler. |
I'll try to dive into it in !37 👍 |
This topic is probably solved with the Lego Store and a simple real world usage.
|
Very good example! 🚀 Recently the Store came out and is another way to resolve with a different architecture. Also that's great you have appropriate the Lego core. Component.js is the core web-component function and that outside of petit-dom. |
Hello, Thanks for your quick reply.
Yes I love the simplicity of this framework 😍. I think we could go even further by adding a built-in simple builder to avoid using rollup/parcel/...webpack when we want to assemble all JS components into one compact JS file. And we could compensate the added code by removing some unused code from petit-dom like directives. But that is another topic when I will have more time :) |
Thanks for the feedback, that's an honor to have Saint Exupery quoted for Lego 🙇
That's a dilema: either build something minimalist or use a heavy bloated builder.
We could cleanup indeed. However the choice here was to take it as is in order to be able to copy paste any further version. |
Lego supports passing strings, arrays, objects… to children.
They should be passed as attributes as so:
Now the
<my-child>
component can have astate.user
that is updated per instance.-> This should be in the doc
The text was updated successfully, but these errors were encountered: