Add widgets to your website, powered by embedded frames.
Install the library as a dependency:
npm install embed-widget
Or, if you're using Yarn:
yarn add embed-widget
Then import the library:
import widget from "embed-widget";
And initialize it with an optional selector:
const embed = new widget("https://example.com", "Button text!");
<script src="https://unpkg.com/embed-widget"></script>
You can use the following methods with a widget:
embed.open(); // Open the widget
embed.close(); // Close the widget
embed.toggle(); // Open if closed, close if opened
embed.destroy(); // Remove button and frame from DOM
Install dependencies:
yarn
Start local development server and Prettier watcher:
yarn start
Compile Typescript to ES6 before publishing to NPM:
yarn build