manyways-run
v1.0.4
Published
A react context library for Manyways Journeys
Downloads
2
Readme
REMOVED:
"prompts": "^2.4.2",
NOTE : NOTHING IN PUBLIC WILL BE AVAILABLE FOR THE END USER _ ONLY FOR DEV
Public methods
separate in src/publicmethod.js
Includes:
- Restart:
window.manyways.restart()
- Dispatcher:
window.manyways.dispatcher()
- Back:
window.manyways.back()
- Share:
window.manyways.share()
can disable w 'disablePublicMethods' on custom element
Running defaults
<manyways-wrapper
slug="my-slug"
mode="scroll"
locale="en"
customcss=".somecss {color: red}"
disablePublicMethods
></manyways-wrapper>
Running the SDK.
Initialization
import ManywaysProvider from "@manyways/run";
const MyApp = ({ children }) => {
return (
<>
<ManywaysRunProvider
slug="my-slug"
mode="scroll"
customComponents={{
choiceWithImage: MyComponent,
}}
disableRender={false}
>
{children}
</ManywaysRunProvider>
</>
);
};
Props
| Prop | Description |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| slug (required) | Your Journey Slug |
| disableRender | This causes the Provider not to render any components at all, ideally used when in pure headless mode |
| customComponents | This is ignored if disableRender
is true. Can provide a object mapped with name and value. Expects the value to be a react component. Full list of component names can be found here @todo |
| mode | Accepts scroll
or slideshow
. Default is scroll
|
- locale
- classNamePrefix
customComponents
All Custom components will have value
and onChange
props passed to them.
INPUTS
- ChoiceWithImage
- Text
- Number
- Date
- DateTime
- Checkbox
- Dropdown (Select)
NULL FIELDS
- Prose (HTML)
- Content Switcher
- Slideshow
TBD:
- AutoComplete
- MapWithDynamicSource
useManyways hook
This is the main way to utilize the various methods and journey states used by manyways.
import { useManyways } from "@manyways/run";
Getters, setters and actions
| Name | Desc | | ------------------- | --------------------------------------------------------------------------------------------- | | currentNode | The current node object from the api | | currentResponse | The current user response to the current node if it exists. Will return null if unanswered | | goBack | Take the user to the previous node. Will return current node if the user is unable to go back | | setResponse | Set the current response | | goForward | Go to the next node with the current response | | responseHistory | An array of response objects with node ids and responses | | getResponseByNodeID | Get response for node based on nodeID | | treeConfig | Get tree config | | journeyNodes | Array of all journey nodes | | locale | Get the current language | | setLocale | Set the current language |
Run Mode Variables
- backgroundImage - takes an image
- nodeLayout - center, content-left, and content-right (can be overriden on node)
- foregroundImage -
- customNextButton - global default, can be overriden on node
- customPreviewButton - global default, can be overriden on node
TODO
ManywaysContext - Double check this is workign correctly with umami tracking... is this needed? If not remove.
const isPreview = () => { // @TODO // if (window.location.search.includes("revision")) { // let revisionId = window.location.search // .split("revision=")[1] // .split("&")[0]; // setSlugAndRevisionParams(
${slug}/begin?revision=${revisionId}`); // }return window.location.search.includes("preview"); }; `
other
- Page titles (+ share titles)
- Header
Mini things
- ManywaysContext: check currentNodeId instead of setCurrentNodeId
let currentNode = currentNodeId !== false ? nodes.find((n) => n.id === currentNodeId) : false;
- ManywaysContext - removed
let umamidata = { website: treeConfig?.analytics_config?.umami_id, };