I've made a widget in React that is meant to be embedded on other people's websites (think Drift/Intercom chat at the bottom right-hand corner of a webpage). First, there's a button, then when it's clicked a form pops up. Both the button and the form are inside a <Widget /> component.
I am now trying to get this into an iframe and bundle the application into a single .js file so others can embed it on their site like the following:
<script src="https://website.com/widget.js">
<script>
Widget.mount({id: 1})
</script
The widget.js file is the actual application, while the script below it is for passing in some props.
What I'm stuck on is how to do I get the Widget component into an iframe and have the iframe resize depending on whether the button is shown or the form is shown. I have tried using libraries like react-frame-component and react-frame, but neither seem to work. Zoid is also something that I've tried but it seems like I can't dynamically resize the iframe for the button/form.
Does anyone have any suggestions? Any help would be much appreciated.