1.3.8 • Published 2 years ago

@amanisystemsinc/instawidget v1.3.8

Weekly downloads
25
License
MIT
Repository
-
Last release
2 years ago

instawidget

webrtc react components and vanilla js bundle to embed button or widget on your website

NPM JavaScript Style Guide

Install

npm install --save @amanisystemsinc/instawidget

Usage

To use this package you must register yourself in the amanisysteminc instaconnect website and from the dashboard you will get the accessToken that you need to pass as a prop. You have to pass only a single prop . And if you want just the textchat component, you have to pass that.

import InstaWidget from "@amanisystemsinc/instawidget";

class Example extends Component {
  render() {
    return <InstaWidget accessToken={accessToken} textchat />;
  }
}

Usage in plain html file as vanilla js

  • Step 1: Add a DOM Container to the HTML Add an empty <div> tag to mark the spot where you want to display the widget/button. For example:
<!-- ... existing HTML ... -->

<div id="instawidget"></div>
<!-- ... existing HTML ... -->

We gave this <div> a unique id HTML attribute. This will allow us to find it from the JavaScript code later and display a React component inside of it.

  • Step 2: Add the Script Tags and necessary css
    Next, add three <script> tags to the HTML page right before the closing </body> tag and css inside <link> tag in <head> of HTML :
 <!-- ... Load css inside head ... -->
 <link rel="stylesheet" href="https://unpkg.com/@amanisystemsinc/instawidget/umd/main.c967f187.css"
    />
 <!-- ... other HTML ... -->
  <!-- Load React. -->
  <!-- Note: when deploying, replace "development.js" with "production.min.js". -->
  <script src="https://unpkg.com/react@17/umd/react.development.js" crossorigin></script>
  <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js" crossorigin></script>
  <!-- Load our React component. -->
  <script src="https://unpkg.com/@amanisystemsinc/instawidget/umd/instawidget.min.js"></script>
</body>

The first two tags load React. The third one will load your component code.

  • Step 3: Open another script tag and use the components like this
<script>
  const e = React.createElement;
  const domContainer = document.querySelector("#instawidget");
  const configObj = {
    accessToken: acessToken,
    buttonText = "Contact Us", //default is 'Contact Us', this text will appear as button text
    textchat: false, //default value is false, if you use true it will only give you a textchat window
    deptwise: false, //default value is false, you can use `true` to get a department wise view
    style: { variant: "outlined", color: "primary" }, //variant can be `contained|text`, color can be `inherit|secondary`, size can be `large|medium|small`
  };
  ReactDOM.render(e(instaWidget, configObj), domContainer);
</script>
  • Step 4(Optional): Tip: Minify JavaScript for Production
    Before deploying your website to production, be mindful that unminified JavaScript can significantly slow down the page for your users. If you already minify the application scripts, your site will be production-ready if you ensure that the deployed HTML loads the versions of React ending in production.min.js:
<script
  src="https://unpkg.com/react@17/umd/react.production.min.js"
  crossorigin
></script>
<script
  src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"
  crossorigin
></script>

If you don’t have a minification step for your scripts, here’s one way to set it up.

License

MIT © amanisystemsinc

1.3.7

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.8

2 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago