1.5.0 • Published 2 years ago

palavyr-chat-widget v1.5.0

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

palavyr-chat-widget

Demo Page

Usage

import Widget from 'palavyr-chat-widget';

const App = () => {
    return <Widget src={"https://www.some-url.com/"} resizable />
}

Description

This project holds a pure react component with few dependencies that can be used to load things in a launchable chat window.

There are essentially two use cases:

  1. Loading an iframe - whereby you will provide a valid and compatible url (.e.g https://www.google.com is not a valid url)
  2. Loading custom content - whereby you will provide a react component, which will then be rendered in the container.

API

PropTypeDefault ValueDescription
customLauncher?AnyFunctionundefinedFunction that is used to trigger the launcher toggle action
onToggle?(widgetOpenState: boolean, setWidgetOpenState: React.Dispatch<React.SetStateAction) => void;)undefinedFunction that will fire when the launcher is clicked to toggle the widget
launcherOpenLabelstring''Label provided to the Launcher when it is open
launcherCloseLabelstring''Label provided to the Launcher when it is closed
launcherCloseImgstring''Image provided to the launcher when closed (shows up in the clickable launcher button)
launcherOpenImgstring''Image provided to launcher when open (shows up in the clickable launcher button)
resizablebooleantrueWhen true, you can drag the left side of the widget
startOpenbooleanfalseWhen true, and fixedPosition is False, the widget will start in the open state
alternateContent?AltContentundefinedA Component that will be rendered instead of the iFrame. No styles are applied internally to the alternate component
fixedPositionbooleantrueIf true, the launcher will be visible and the widget will be fixed to the bottom left right corner (depending on the alignLeft value)
open?booleanundefinedprop used to control the state of the widget (open or closed state)
setOpen?Dispatch<SetStateAction>undefinedThe dispatch hook for the open control prop (todo: remove this dependency)
alignLeftbooleanfalseIf true, the widget aligns to the left side of the screen instead of the right
closeComponent?React.ReactNodeundefinedComponent rendered as the clickable button to open and close the widget when closed
openComponent?React.ReactNodeundefinedComponent rended as the clickable button to open and close the widget when opened
launchComponent?React.ReactNodeundefinedComponent rendered as the clickable button to open and close the widget when open
persistStatebooleantrueIf true, the state of the container will be maintained (i.e. will not be unmounted) when the launcher is closed e.g. this is useful if you'd like to persist the same conversation across different pages (and the widget sits outside of the router)
containerStylesReact.CSSPropertiesundefinedStyles applied ot the div that contains the iframe. (There is only one such outer div)
containerClassNamestring (class names)''className applied ot the div that contains the iframe. (There is only one such outer div)
customSpinnerReact.ReactNode or nullnullAn optional component that is shown when the iframe is loading. A default spinner is used if this not provided.
IframeProps?React's IFrame Props -- see belowundefinedAdditional props that are specific to the React iframe element may be passed for further customization.
autoOpen?numberundefinedWhen defined, this causes the widget to automatically open after the provided number of milliseconds
autoOpenCallback?Any void function that takes no arguments, i.e. () => voidundefinedA function to call when the auto open event occurs
disableBounce?booleanfalseDisable bounce animation behavior when using the default launcher componentoccurs
openImgProps?React.ImgHTMLAttributes{}img element props passed to the default launcher image element when in the 'click to open' state occurs
closeImgProps?React.ImgHTMLAttributes{}img element props passed to the default launcher image element when in the 'click to close' state occurs
launcherButtonAdditionalStyles?React.CSSProperties{}Additional styles passed to the default launcher button
onEffect?(widgetOpenState: boolean, setWidgetOpenState: SetState) => void;undefinedFunction to call on effect
onEffectDependencyArray?ArrayundefinedDependency array for the useEffect provided for the onEffect callback. required if onEffect is supplied.

iframeProps: React.DetailedHTMLProps<IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>

Package details

=== Tarball Details ===
name:          palavyr-chat-widget
version:       1.5.0
filename:      palavyr-chat-widget-1.5.0.tgz
package size:  22.3 kB
unpacked size: 125.2 kB
total files:   15
1.5.0

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.0.0

2 years ago

0.4.0

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.17

2 years ago

0.2.16

2 years ago

0.2.15

2 years ago

0.2.14

2 years ago

0.2.13

2 years ago

0.2.12

2 years ago

0.2.11

2 years ago

0.2.10

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.31

2 years ago

0.1.30-dev

2 years ago

0.1.29-dev

2 years ago

0.1.28-dev

2 years ago

0.1.27-dev

2 years ago

0.1.25-dev

2 years ago

0.1.24-dev

2 years ago

0.1.23

2 years ago

0.1.22

2 years ago

0.1.20

2 years ago

0.1.18

2 years ago

0.1.17

2 years ago

0.1.16

2 years ago

0.1.14

2 years ago

0.1.13

2 years ago

0.1.12

2 years ago

0.1.11

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

3.1.0

2 years ago