maciejhirsz / kobold

Easy declarative web interfaces.
https://docs.rs/kobold/
Mozilla Public License 2.0
385 stars 7 forks source link

Passing properties to WebComponents #33

Open ranaya-formant opened 1 year ago

maciejhirsz commented 1 year ago

@ranaya-formant would you mind adding some context here, since it's actually unclear to me what this would entail exactly.

One thing would be using Web Components internally for performance (which may or may not be needed, benchmarks pending), another would be the ability to define Web Components in Kobold to use them outside of Kobold.

9876691 commented 1 year ago

another would be the ability to define Web Components in Kobold to use them outside of Kobold.

That was probably the OP's intention.

There's some background on web components with bindgen https://github.com/rustwasm/wasm-bindgen/issues/3119

ranaya-formant commented 1 year ago

@maciejhirsz sorry for the delay.

What I mean is not being able to define web components, but rather being able to effectively pass down properties to a web component.

Right now react currently suffers from only being able to pass data to components by attribute.

lit-html and a planned improvement to React allow web components to receive data directly on properties exposed by the element ( to avoid the attribute string -> value conversion ).

I think this change would allow kobold to utilize web components from the ecosystem that exists today, and if kobold ever allows creating of web components one day, it would have an efficient way to pass it props too.

example:

let a = 42;

view! {

    <Greeter name="Richard" .age={a} />
}
maciejhirsz commented 1 year ago

@ranaya-formant thanks for the explanation. This seems like a pretty modest ask and I don't see a reason why we shouldn't be able to do it one way or the other.

I'll organize a roadmap till 1.0 next week and plan this in somewhere.