This react component allows you to easily include Olvy widgets in your React applications. The component takes care of all the necessary set up and configuration, allowing you to simply specify which Olvy widget you want to use and any relevant options.
https://codesandbox.io/s/olvy-widget-react-icif8y
Updated (v0.1.9) https://stackblitz-starters-cbnfty.stackblitz.io
Install @olvyhq/widget-react with npm
npm install @olvyhq/widget-react
In main.js
import {OlvyWidget} from "@olvyhq/widget-react"
<OlvyWidget
onReady={onOlvyReady}
config={<Configuration> }
targetElement={<div>
<div id="<Target-Element-Id>"></div>
</div>
}
></OlvyWidget>
//Replace <Target-Element-Id> with your target element id and <Configuration> with your configuration
// You can use onReady prop to provide a callback function to perform some actions when the widget is ready
<OlvyWidget
onReady={onOlvyReady}
config={{workspaceAlias: "olvysdktest"}}
targetElement={<div>
<div id="olvy-whats-new">Announcement Widget</div>
</div>
}>
</OlvyWidget>
// Callback function to use OlvyUtils when it's loaded
const onOlvyReady = (olvyUtils) => {
// use the olvyUtils functions here
setTimeout(() => {
olvyUtils.showWidget(workspaceAlias,widgetAliasOrID);
}, 1000);
};
{
widgetId:"", // (optional)
workspaceAlias:"" //(required)
}
Parameter | Type | Description |
---|---|---|
workspaceAlias |
string |
Required. Your subdomain |
widgetAliasOrID |
string |
Optional. widget Id or alias ( you can find it on widget details page in olvy dashbaord ) |
OlvyUtils.showWidget(workspaceAlias,widgetAliasOrID)
Parameter | Type | Description |
---|---|---|
workspaceAlias |
string |
Required. Your subdomain |
widgetAliasOrID |
string |
Required. widget Id or alias ( you can find it on widget details page in olvy dashbaord ) |
OlvyUtils.hideWidget(workspaceAlias,widgetAliasOrID)
Parameter | Type | Description |
---|---|---|
workspaceAlias |
string |
Required. Your subdomain |
widgetAliasOrID |
string |
Required. widget Id or alias ( you can find it on widget details page in olvy dashbaord ) |
OlvyUtils.setUser(workspaceAlias, userObject)
Parameter | Type | Description |
---|---|---|
workspaceAlias |
string |
Required. Your subdomain |
userObject |
object |
Required. |
OlvyUtils.setFeedbackMetaInfo (workspaceAlias, metaInfo)
Parameter | Type | Description |
---|---|---|
workspaceAlias |
string |
Required. Your subdomain |
metaInfo |
object |
Required. |
OlvyUtils.refreshUnreadCount(workspaceAlias,widgetAliasOrID)
Parameter | Type | Description |
---|---|---|
workspaceAlias |
string |
Required. Your subdomain |
widgetAliasOrID |
string |
Required. widget Id or alias ( you can find it on widget details page in olvy dashbaord ) |
OlvyUtils.getUnreadReleasesCount(workspaceAlias,widgetAliasOrID)
Parameter | Type | Description |
---|---|---|
workspaceAlias |
string |
Required. Your subdomain |
widgetAliasOrID |
string |
Required. widget Id or alias ( you can find it on widget details page in olvy dashbaord ) |
OlvyUtils.removeUnreadIndicatorElement(workspaceAlias,widgetAliasOrID)
Parameter | Type | Description |
---|---|---|
workspaceAlias |
string |
Required. Your subdomain |
widgetAliasOrID |
string |
Required. widget Id or alias ( you can find it on widget details page in olvy dashbaord ) |
OlvyUtils.addUnreadIndicatorElement(workspaceAlias,widgetAliasOrID, count)
Parameter | Type | Description |
---|---|---|
workspaceAlias |
string |
Required. Your subdomain |
widgetAliasOrID |
string |
Required. widget Id or alias ( you can find it on widget details page in olvy dashbaord ) |
OlvyUtils.getLastOpenedTimestamp(workspaceAlias,widgetAliasOrID)
Parameter | Type | Description |
---|---|---|
workspaceAlias |
string |
Required. Your subdomain |
widgetAliasOrID |
string |
Required. widget Id or alias ( you can find it on widget details page in olvy dashbaord ) |
OlvyUtils.refresh(workspaceAlias,widgetAliasOrID)
Parameter | Type | Description |
---|---|---|
workspaceAlias |
string |
Required. Your subdomain |
widgetAliasOrID |
string |
Required. widget Id or alias ( you can find it on widget details page in olvy dashbaord ) |
OlvyUtils.teardown(workspaceAlias,widgetAliasOrID)
Parameter | Type | Description |
---|---|---|
workspaceAlias |
string |
Required. Your subdomain |
widgetAliasOrID |
string |
Required. widget Id or alias ( you can find it on widget details page in olvy dashbaord ) |
OlvyUtils.createFeedback(workspaceAlias,params)
Parameter | Type | Description |
---|---|---|
workspaceAlias |
string |
Required. Your subdomain |
params |
object |
Required. |
npm run test:unit