carlrip / x-modal

MIT License
4 stars 7 forks source link

How to use it in web component? #1

Open jackchoumine opened 2 years ago

jackchoumine commented 2 years ago

Hi I come from your artilce Creating a Modal Dialog Web Component in StencilJS I hve a question: how to use the modal component in a web component? like this

<my-web-component>
       <x-modal></x-modal>
</my-component>

in vue we crate a modal, we mount modal to end of body when modal show, how can achieve this in stencli?

carlrip commented 2 years ago

I would do something like the following inside my-web-component in one of the lifecycle methods like componentDidLoad:

const modal = document.createElement('x-modal');
document.body.append(modal);