diff --git a/README.md b/README.md index d56815ef..7b3970a4 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,8 @@ You can customize the tooltip by passing a component to the `copilot` HOC maker. ```js const TooltipComponent = ({ + tooltipPosition, + arrowPosition, isFirstStep, isLastStep, handleNext, @@ -166,6 +168,28 @@ copilot({ })(RootComponent) ``` +### Custom navigator +You can add a custom navigator, by passing a React Component to the `copilot` HOC maker. + +This is the same prop as [tooltip](#custom-tooltip-component). + +```js +const customNavigator = ({ + isFirstStep, + isLastStep, + handleNext, + handlePrev, + handleStop, + currentStep, +}) => ( + // ... +); + +copilot({ + customNavigator: customNavigator +})(RootComponent) +``` + ### Custom components as steps The components wrapped inside `CopilotStep`, will receive a `copilot` prop of type `Object` which the outermost rendered element of the component or the element that you want the tooltip be shown around, must extend. diff --git a/src/components/CopilotModal.js b/src/components/CopilotModal.js index abff9c0c..7105000d 100644 --- a/src/components/CopilotModal.js +++ b/src/components/CopilotModal.js @@ -21,7 +21,8 @@ type Props = { overlay: 'svg' | 'view', animated: boolean, androidStatusBarVisible: boolean, - backdropColor: string + backdropColor: string, + customNavigator?: React$Component, }; type State = { @@ -263,9 +264,14 @@ class CopilotModal extends Component { currentStepNumber={this.props.currentStepNumber} /> , - , - + TooltipComponent ? null : ( + + ), + TooltipComponent ? ( { handlePrev={this.handlePrev} handleStop={this.handleStop} /> - , + ) : ( + + + + ), ]; } render() { const containerVisible = this.state.containerVisible || this.props.visible; const contentVisible = this.state.layout && containerVisible; + const CustomNavigator = this.props.customNavigator; return ( { > {contentVisible && this.renderMask()} {contentVisible && this.renderTooltip()} + {!!CustomNavigator && ( + + )} ); diff --git a/src/hocs/copilot.js b/src/hocs/copilot.js index 6c009d3b..46dc3046 100644 --- a/src/hocs/copilot.js +++ b/src/hocs/copilot.js @@ -35,6 +35,7 @@ const copilot = ({ animated, androidStatusBarVisible, backdropColor, + customNavigator, verticalOffset = 0, wrapperStyle, } = {}) => @@ -193,6 +194,7 @@ const copilot = ({ animated={animated} androidStatusBarVisible={androidStatusBarVisible} backdropColor={backdropColor} + customNavigator={customNavigator} ref={(modal) => { this.modal = modal; }} />