Thank you for your interest in contributing to React Live Chat Loader! 🙌🏻 Below, you will find everything you need to get started.
This project and everyone participating in it are governed by this Code of Conduct. By participating, we expect you to act accordingly to this code. Please report unacceptable behaviour to [email protected].
Before creating a bug report, see if the problem has already been reported. If yes, and the issue is still open, add a comment to the existing issue instead of creating a new one.
When creating a bug report, please provide as much information and context as possible to help the maintainers quickly identify and resolve problems:
- Describe the bug. Please provide a clear and concise description of what the bug is.
- Explain how to reproduce. Outline the steps to reproduce the behaviour, including any relevant information such as operating system, browser type and version, etc.
- Outline the expected behaviour. Describe what you expected to happen clearly and concisely.
- Add screenshots. If applicable, add screenshots to help explain the problem.
You will be guided to provide relevant information as you create the issue.
Before suggesting a new feature, see if has already been suggested. If yes, and the issue is still open, add a comment to the existing issue instead of creating a new one.
When filing a feature request, please provide as much information and context as possible to help the maintainers triage issues:
- What problem would this feature solve? A clear and concise description of what the problem is.
- Describe the solution you’d like to see. A clear and concise description of what you would like to happen. Are you willing to work on implementing this solution?
- Describe alternatives you’ve considered. A clear and concise description of any alternative solutions or features you’ve considered.
You will be guided to provide relevant information as you create the feature request.
We welcome contributions to React Live Chat Loader that:
- improve the quality, security and performance of the library
- resolve existing issues and feature requests
- add new live chat providers
Please follow these steps to have your contribution considered by the maintainers:
- Fork and clone this repository.
- Create a new branch:
git checkout -b my-branch-name
. - Make your changes and verify that the checks are still passing.
- Push to your fork and submit a pull request accordingly to the guidelines.
- Sign a CLA (if present).
- Wait till your changes are reviewed and merged. 🥳
You must meet the above requirements to have your pull request reviewed. The maintainer(s) may ask you to complete additional work, tests, or other changes before your pull request is accepted and merged.
To contribute a new provider, follow these steps:
Create a new provider file at src/providers/providerName.js
using the
following as a template:
Provider Template
const domain = 'https://provider.domain.com'
const loadScript = () => {
// Detect the provider is already loaded and return early
if (alreadyLoaded) return
// Call provider script here
}
const load = ({ providerKey }) => {
loadScript()
// Initialise provider script
}
const open = () => // Open provider
const close = () => // Close provider
export default {
domain,
load,
open,
close
}
The provider must export the following:
domain
: A string of the domain where the provider script is loaded from that will be used in apreconnect
link.load
: Function which when called will load and initialize the provider script. It should accept props and use theproviderKey
as theapp_id
orapi_key
. For consistency, it should call aloadScript
function.open
: Function which when called will open the provider chat.close
: Function which when called will close the provider chat.
Import the new file in src/providers/index.js
and add it to Providers
.
The name of this file will be the providerKey
used in the
LiveChatLoaderProvider
.
Create a new component in src/Components/ProviderName/index.js
which
replicates the chat widget, using the following as a template:
Component Template
import React from 'react'
import { useChat } from '../../'
import STATES from '../../utils/states'
const styles = {
// Add widget styles here
button: {
// Add button styles here
}
}
const Provider = ({ color }) => {
const [state, loadChat] = useChat({ loadWhenIdle: true })
if (state === STATES.COMPLETE) return null
return (
<div>
<button
onClick={() => loadChat({ open: true })}
onMouseEnter={() => loadChat({ open: false })}
style={{
...styles.button,
backgroundColor: color
}}
>
Button
</button>
</div>
)
}
Provider.defaultProps = {
color: '#976ad4'
}
export default Provider
Do not worry about loading animations as the widget
will be shown instantly on page load. Increase the z-index
by 1
so the fake
widget sits immediately above the chat widget that is being replaced.
Export the component from src/index.js
Add your new provider to this README under Supported Providers.
Add a new page to website/pages/
which showcases the provider. If you don't want to include your providerKey
leave this blank and the maintainers will set one up.
The new provider page can be tested locally by creating a distribution version of the package and referencing this from the website
.
To create the distribution version and reference it, do the following:
- In the root of the project, run
npm run build
- In the
website
directory runnpm install
- In the
website
directory run the server withnpm run dev
- Add a new page to
website/pages/
which includes the new component - Add a link to the provider in
website/pages/index.js
- Add a link to the provider in
website/components/exampleLinks.js