-
I'm trying to integrate with an existing web component library, specifically https://github.com/microsoft/fluentui/tree/master/packages/web-components. I've seen examples of building a web component in rust but not consuming/integrating with existing web components. What I've got so far "works", but I'd like a better integration with leptos. I'd like to be able to use something like Import Web Component library into projectI've added the npm package @fluentui/web-components@beta (and @microsoft/fast-element in order to build for some reason) to my workspace. I added a fluent-ui-component.js file to my root and am using webpack to manually build a js bundle into the target/site output folder (this gets removed when I do a build right now, but doing the js build manually for testing) and I add a reference to the bundled js file in my shell.
This lets me use the web components in my leptos components, bind signals to attributes, add event handlers etc. all good stuff. Integrate with Dialog componentthe fluent-dialog component exposes hide and show methods. I've created a fluent-ui-helper.js in the root of my app folder that interacts with the dom to hide/show the dialog.
I then use the bindgen to import as a JsSnippet and interface with that in my component.
Doesn't feel great, but it works. Attempt to bindgen componentI (feebly) tried to bindgen an interface for the dialog component...not sure if i'm in the right direction here or not
This compiles, but I don't see any evidence of it in the bindgen js generated. When I try to use the Dialog type in a I'm not sure if I'm on the right track with this bindgen or not. Has anyone tried to integrate with a Web Component library? Any ideas on what I might try next to better integrate with leptos? Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
It seems to me that the only question here that's not currently covered is how to call the When I need to do things like this, I'll typically just use What you're going to generate bindings to would be like a You'd then define a separate struct However just using |
Beta Was this translation helpful? Give feedback.
It seems to me that the only question here that's not currently covered is how to call the
show
andhide
methods — Is that right?When I need to do things like this, I'll typically just use
js_sys::Reflect::get()
to get the function and to call it, but usingwasm-bindgen
to do the bindings properly is reasonable, I guess, if you want a better API.What you're going to generate bindings to would be like a
FluentDialogElement
similar to all the element types likeweb_sys::HtmlDialogElement
and so on.You'd then define a separate struct
FluentDialog
that you'd implementElementType
on if you want to use it directly in aNodeRef
without usingCustom<_>
. (ElementType
is not a particularly comp…