https://github.com/anandchowdhary/embed-widget
🗃 Embeddable widgets for your website
https://github.com/anandchowdhary/embed-widget
dom embed iframe library typescript widget
Last synced: about 1 year ago
JSON representation
🗃 Embeddable widgets for your website
- Host: GitHub
- URL: https://github.com/anandchowdhary/embed-widget
- Owner: AnandChowdhary
- License: mit
- Created: 2019-03-19T09:59:14.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-06-18T01:49:43.000Z (about 2 years ago)
- Last Synced: 2025-06-12T17:14:44.466Z (about 1 year ago)
- Topics: dom, embed, iframe, library, typescript, widget
- Language: TypeScript
- Homepage: https://anandchowdhary.github.io/embed-widget/
- Size: 131 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🗃 Embed widget
Add widgets to your website, powered by embedded frames.
## ⭐ Usage
Install the library as a dependency:
```bash
npm install embed-widget
```
Or, if you're using Yarn:
```bash
yarn add embed-widget
```
Then import the library:
```js
import widget from "embed-widget";
```
And initialize it with an optional selector:
```js
const embed = new widget("https://example.com", "Button text!");
```
```html
```
## 💻 API
You can use the following methods with a widget:
### Open/close/togggle
```js
embed.open(); // Open the widget
embed.close(); // Close the widget
embed.toggle(); // Open if closed, close if opened
```
### Remove
```js
embed.destroy(); // Remove button and frame from DOM
```
## 🛠️ Development
Install dependencies:
```bash
yarn
```
Start local development server and Prettier watcher:
```bash
yarn start
```
Compile Typescript to ES6 before publishing to NPM:
```bash
yarn build
```