Skip to content

AnandChowdhary/embed-widget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ—ƒ Embed widget

Add widgets to your website, powered by embedded frames.

โญ Usage

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>

๐Ÿ’ป API

You can use the following methods with a widget:

Open/close/togggle

embed.open(); // Open the widget
embed.close(); // Close the widget
embed.toggle(); // Open if closed, close if opened

Remove

embed.destroy(); // Remove button and frame from DOM

๐Ÿ› ๏ธ Development

Install dependencies:

yarn

Start local development server and Prettier watcher:

yarn start

Compile Typescript to ES6 before publishing to NPM:

yarn build