@mxenabled/connect-widget
v0.0.7
Published
A simple ui library for React
Downloads
539
Maintainers
Keywords
Readme
Connect Widget
This is the UI only for the connect widget. Heavy configuration and an API are needed for this project to work. See usage and props for more details.
Installation
Install using npm package manager:
npm install @mxenabled/connect-widget
Usage
- Install package:
npm install --save @mxenabled/connect-widget
- Import
ApiProvider
andConnectWidget
. Add both to your project. - Pass applicable props to widget and your API to the provider.
import ConnectWidget, { ApiProvider } from '@mxenabled/connect-widget'
import apiService from './apiService' // You custom api service
const App = () => {
return (
<ApiProvider apiValue={apiService}>
<ConnectWidget {...props} />
{/* See props details below */}
</ApiProvider>
)
}
Props
| Prop | Type | Description | Default |
| :------------------- | :------------------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------- |
| clientConfig
| ClientConfigType
| The connect widget uses the config to set the initial state and behavior of the widget. More details | See more details |
| language
| LanguageType
| The connect widget supports multiple languages and custom copy. Supported locale options: en
, es
, and fr-ca
. | { locale: 'en', custom_copy_namespace: '' }
|
| onAnalyticEvent
| AnalyticContextType
| The connect widget provides a way to track events and pageviews using your own analytics provider. More details | null
|
| onAnalyticPageview
| AnalyticContextType
| The connect widget provides a way to track events and pageviews using your own analytics provider. More details | null
|
| onPostMessage
| PostMessageContextType
| The connect widget uses post messages to communicate with the parent window. More details | null
|
| profiles
| ProfilesTypes
| The connect widget uses the profiles to set the initial state of the widget. More details | See more details |
| userFeatures
| UserFeaturesType
| The connect widget uses user features to determine the behavior of the widget. More details | See more details |
| showTooSmallDialog
| boolean
| The connect widget can show a warning when the widget size is below the supported 320px. | true
|
ApiProvider
You need to pass an object containing API endpoint callbacks as the apiValue
prop of the ApiProvider as described in the usage section for the widget to work. Here is a more detailed list of the API endpoint callbacks.
Developing
- Clone project
- Install
Node(with npm)
. See package.json for current required versions - Run
npm i
- Make your code changes
- Run
npm run build
to build the project - Link Project
- Test your changes
- Update change log, translations, and documentation as needed
- Open Pull Request
Linking for Development
For developing this package locally, we suggest you use npm link to connect your local version of the package to your client app using the package.
- In the npm package root, run
npm link
. - Then in your consumer project, run
npm link @mxenabled/connect-widget
.
This will link the local package to your project in the node modules. Unlink the package when you are finished or if you run into issues.
Contributing
Pull requests are welcome. Please open an issue first to discuss what you would like to change.
Make sure to add/update tests, translations, and documentation as appropriate.
Changelog
View our changelog here