# react-webintegration-template
[![React](https://badges.aleen42.com/src/react.svg)](https://reactjs.org/) [![Node](https://badges.aleen42.com/src/javascript.svg)](https://developer.mozilla.org/en-US/docs/Web/JavaScript) [![Node](https://badges.aleen42.com/src/node.svg)](https://nodejs.org/en/) [![ESLint](https://badges.aleen42.com/src/eslint.svg)](https://eslint.org/)

`react-webintegration-template` is an injectable React Application that serves a conversational chat-widget. 

## Installation
`react-webintegration-template` requires [Node.js](https://nodejs.org/) v14+ to run.

Install the dependencies by running these commands.

```ssh
git clone git@gitlab.com:GreenhouseGroup/gh-teams/conversational/react-webintegration-template.git
cd react-webintegration-template
yarn
```

## Usage
For development environments

```ssh
yarn start
```

Running a build for production

```ssh
yarn build
# optional command to publish the packge to npm/jsdelivr
yarn publish
```

Deploy the latest version to NPM & jsDelivr.

```ssh
yarn deploy
```

Add [browser-sync](https://www.npmjs.com/package/browser-sync) to test the inject script locally, then run the following command.
*Note: You can adjust the uuid inside example/index.html on line 394.* 
```ssh
yarn example
```

Or inject the script using a browser extension using the following code.
```js
(function () {
  window.conversational = { id: 'c655906f-fb6e-4879-bc63-ba4184f5de54' };
  var r = document.createElement('div'); r.id = 'ghg__conv-wit'; document.body.appendChild(r);
  var e = document.createElement('script'); e.async = true; e.src = 'https://cdn.jsdelivr.net/npm/@freshfruitdigital/conv-inject-react-app@latest/build/main.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(e, s);
})();
 ```

## Packages

`react-webintegration-template` is currently extended with the following packages.
Instructions on how to use them in your own application are linked below.

| Package | Documentation |
| ------ | ------ |
| craco | [npmjs.com](https://www.npmjs.com/package/@craco/craco) |
| gsap | [npmjs.com](https://www.npmjs.com/package/gsap) |
| styled-components | [npmjs.com](https://npmjs.com/package/styled-components) |
| swr | [npmjs.com](https://www.npmjs.com/package/swr) |
| react-device-detect | [npmjs.com](https://www.npmjs.com/package/react-device-detect) |
| react-helmet-async | [npmjs.com](https://www.npmjs.com/package/react-helmet-async) |
| react-conversational-chatcomponent | [gitlab.com](https://gitlab.com/GreenhouseGroup/conversational/tech/libraries/react-components/react-conversational-chatcomponent) |

## License

MIT / [Jim de Ronde](https://github.com/jrtderonde) / 2021

_Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software._