### Complete ES6 Module Setup with Plugins
Source: https://context7.com/labs64/guidechimp/llms.txt
Integrate GuideChimp using ES6 modules, including core library, styles, and multiple plugins. This example demonstrates importing, extending plugins, defining tours, and setting placeholders.
```javascript
// Import core library and styles
import GuideChimp from 'guidechimp';
import 'guidechimp/dist/guidechimp.min.css';
// Import plugins
import beacons from 'guidechimp/dist/plugins/beacons';
import lazyLoading from 'guidechimp/dist/plugins/lazyLoading';
import placeholders from 'guidechimp/dist/plugins/placeholders';
// Enable plugins
GuideChimp.extend(beacons);
GuideChimp.extend(lazyLoading, { timeout: 10000 });
GuideChimp.extend(placeholders);
// Define tour
const tour = [
{
element: '#app-header',
title: 'Welcome, {userName}!',
description: 'Let us show you around {appName}.',
},
{
element: '#lazy-component',
title: 'Dynamic Content',
description: 'This component loads dynamically.',
}
];
// Create instance
const guideChimp = GuideChimp(tour, {
position: 'bottom',
showProgressbar: true
});
// Set placeholders
guideChimp.setPlaceholders({
userName: 'Developer',
appName: 'MyApp'
});
// Register events
guideChimp.on('onStart', () => console.log('Tour started'));
guideChimp.on('onComplete', () => console.log('Tour completed'));
// Export for use in components
export default guideChimp;
```
--------------------------------
### start() Method
Source: https://context7.com/labs64/guidechimp/llms.txt
Starts the tour from a specified step number or index. If no step is specified, it starts from the beginning.
```APIDOC
## start() Method
### Description
Starts the tour from a specified step number or index. If no step is specified, it starts from the beginning.
### Method
`guideChimpInstance.start(step, isIndex)`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **step** (Number) - Optional - The step number or index to start the tour from. If omitted, starts from the first step.
- **isIndex** (Boolean) - Optional - If true, `step` is treated as a 0-based index. If false or omitted, `step` is treated as a step number.
### Request Example
```javascript
// Start from the beginning (index 0)
guideChimp.start();
// Start from step index 2 (third step)
guideChimp.start(2, true);
// Start tour on button click
document.getElementById('startTourBtn').addEventListener('click', function() {
guideChimp.start();
});
```
### Response
#### Success Response (200)
None (This method controls the tour's state).
#### Response Example
None
```
--------------------------------
### React Example Integration
Source: https://github.com/labs64/guidechimp/blob/master/README.md
This is a sample React application demonstrating the integration of GuideChimp. It requires a GuideChimp tour to be configured and initiated.
```jsx
import React from "react";
import GuideChimp from "@guidechimp/guidechimp-react";
export default function App() {
return (
{/* Your application content here */}
);
}
```
--------------------------------
### Start GuideChimp Tour from Specific Step
Source: https://context7.com/labs64/guidechimp/llms.txt
Initiate a GuideChimp tour, optionally starting from a specific step index or step number. The `start` method can be triggered programmatically or via event listeners, such as a button click.
```javascript
var guideChimp = GuideChimp([
{ element: '#step1', title: 'First Step', description: 'Welcome to the tour!' },
{ element: '#step2', title: 'Second Step', description: 'This is step two.' },
{ element: '#step3', title: 'Final Step', description: 'Tour complete!' }
]);
// Start from beginning (index 0)
guideChimp.start();
// Start from step index 2 (third step)
guideChimp.start(2, true);
// Start from step with specific step number (not index)
guideChimp.start(5, false);
// Start tour on button click
document.getElementById('startTourBtn').addEventListener('click', function() {
guideChimp.start();
});
```
--------------------------------
### Install GuideChimp via npm Command
Source: https://github.com/labs64/guidechimp/wiki/Install
Execute this command in your Node.js environment to install the GuideChimp package.
```bash
$ npm install guidechimp
```
--------------------------------
### GuideChimp Method Examples
Source: https://github.com/labs64/guidechimp/wiki/Configure
Examples demonstrating the usage of GuideChimp methods like stop() and on() for event handling. The stop() method can accept context, which is passed to event listeners.
```javascript
guide.stop({ flag: true });
```
```javascript
guide.on('onStop', (context) => {
const { flag } = context || {};
if (flag) {
// ...
} else {
// ...
}
});
```
--------------------------------
### Install GuideChimp as npm Module
Source: https://github.com/labs64/guidechimp/wiki/Install
Add GuideChimp as a dependency in your package.json file for Node.js projects. Run 'npm install' to complete the installation.
```json
"dependencies": {
"guidechimp": "x.y.z"
}
```
--------------------------------
### Install Blurred Overlay via CDN
Source: https://github.com/labs64/guidechimp/wiki/Blurred-Overlay-plugin
Include the required scripts and styles, then extend GuideChimp with the plugin.
```html
```
--------------------------------
### Install Blurred Overlay via ES6
Source: https://github.com/labs64/guidechimp/wiki/Blurred-Overlay-plugin
Import the GuideChimp core and the blurred overlay plugin, then extend the instance.
```javascript
import GuideChimp from 'guidechimp';
import blurredOverlay from 'guidechimp/dist/plugins/blurredOverlay';
import 'guidechimp/dist/plugins/blurredOverlay.min.css';
GuideChimp.extend(blurredOverlay);
```
--------------------------------
### GuideChimp Beacons Plugin Setup and Usage
Source: https://context7.com/labs64/guidechimp/llms.txt
Includes HTML and JavaScript definitions for creating interactive beacons. Ensure GuideChimp core and beacons plugin scripts are included. Beacons can be defined in HTML or JavaScript.
```html
New Feature!
```
```javascript
// Enable beacons plugin
GuideChimp.extend(guideChimpPluginBeacons);
// JavaScript Beacon Definition
var beacons = [
{
element: '#notifications-bell',
position: 'top-left', // top-left, top, top-right, center-left, center, center-right, bottom-left, bottom, bottom-right
boundary: 'outer', // outer or inner
class: 'pulse-beacon',
onClick: function() {
alert('Check your notifications!');
}
},
{
element: '#upgrade-btn',
position: 'center-right',
tour: [
{ title: 'Upgrade Available', description: 'Unlock premium features today!' }
]
},
{
element: '#help-center',
position: 'bottom',
tour: {
steps: [ { title: 'Need Help?', description: 'Access our knowledge base and support.' } ],
options: { position: 'left' }
}
}
];
// Create and show beacons
var guideChimpBeacons = GuideChimp.beacons(beacons, { boundary: 'outer' });
guideChimpBeacons.showAll();
// Or show beacons from HTML definitions
var htmlBeacons = GuideChimp.beacons();
htmlBeacons.showAll();
```
--------------------------------
### GuideChimp Event Listener Examples
Source: https://github.com/labs64/guidechimp/wiki/Configure
Registering event listeners for GuideChimp tours. Multiple events can be grouped using the pipe symbol '|' for a single callback.
```javascript
guideChimp.on('onBeforeChange|onAfterChange', (to, from)=>{});
```
```javascript
guideChimp.on('onStart|onStop|onComplete', ()=>{});
```
--------------------------------
### GuideChimp Plugin Boilerplate
Source: https://github.com/labs64/guidechimp/blob/master/plugins/_boilerplate/README.md
Use this template to start developing a GuideChimp plugin. It demonstrates how to extend the GuideChimp class and factory, and override existing methods.
```javascript
/**
*
* @param {Class} cls GuideChimp class
* @param {Object} factory GuideChimp factory
* @param {Array} args optional arguments needed for the plugin; for instance, the options object
*/
module.exports = (cls, factory, ...args) => {
/**
* extend GuideChimp() class
* e.g. add GuideChimp(tour).customMethod()
*/
cls.prototype.customMethod = () => {};
/**
* extend GuideChimp factory
* e.g. add GuideChimp.customMethod()
*/
factory.customMethod = () => {};
// override existing API
// e.g. extend GuideChimp().init()
const parentInit = cls.prototype.init;
cls.prototype.init = () => {
parentInit();
// custom code
//...
};
// Override static method
const parentDefaultOptions = cls.prototype.getDefaultOptions;
cls.getDefaultOptions = () => ({
...parentDefaultOptions(),
// custom options
// ...
});
};
```
--------------------------------
### Register GuideChimp Event Listeners
Source: https://context7.com/labs64/guidechimp/llms.txt
The `on()` method allows you to register callbacks for various tour lifecycle events like start, step changes, completion, and stop. You can listen to multiple events by separating them with a pipe '|'.
```javascript
var guideChimp = GuideChimp([
{ element: '#intro', title: 'Welcome', description: 'Tour introduction' },
{ element: '#main', title: 'Main Content', description: 'Core features' },
{ element: '#end', title: 'Finish', description: 'Tour complete!' }
]);
// Listen for tour start
guideChimp.on('onStart', function() {
console.log('Tour started');
analytics.track('tour_started');
});
// Listen for step changes with step data
guideChimp.on('onBeforeChange', function(toStep, fromStep) {
console.log('Changing from:', fromStep?.title, 'to:', toStep.title);
// Return false to prevent step change
if (toStep.element === '#restricted') {
return false;
}
});
guideChimp.on('onAfterChange', function(toStep, fromStep) {
console.log('Now showing step:', toStep.title);
document.getElementById('stepIndicator').textContent = toStep.title;
});
// Listen for navigation events
guideChimp.on('onPrevious', function(previousStep, currentStep) {
console.log('Going back to:', previousStep.title);
});
guideChimp.on('onNext', function(nextStep, currentStep) {
console.log('Advancing to:', nextStep.title);
});
// Listen for tour completion
guideChimp.on('onComplete', function() {
console.log('Tour completed!');
localStorage.setItem('tourCompleted', 'true');
});
// Listen for tour stop (includes early exits)
guideChimp.on('onStop', function(context) {
console.log('Tour stopped', context);
if (context?.flag) {
// Handle custom flag from stop() call
}
});
// Multiple events with pipe separator
guideChimp.on('onStart|onStop|onComplete', function() {
console.log('Tour state changed');
});
guideChimp.start();
```
--------------------------------
### Configure Lazy Loading Plugin
Source: https://github.com/labs64/guidechimp/wiki/Lazy-loading-plugin
Extend GuideChimp with the lazy loading plugin, customizing timeout and frequency. Ensure the plugin is installed and configured via the Wiki page.
```javascript
GuideChimp.extend(guideChimpPluginLazyLoading, { timeout: 15000, frequency: 500 });
```
--------------------------------
### JavaScript Initialization for HTML Defined Tours
Source: https://github.com/labs64/guidechimp/wiki/Configure
Initialize GuideChimp in JavaScript when using HTML attributes to define tour steps. This example shows initializing for a single tour named 'tour'.
```javascript
// js
var guideChimp = GuideChimp('tour');
```
--------------------------------
### Initialize GuideChimp with Options
Source: https://github.com/labs64/guidechimp/wiki/Configure
Initialize GuideChimp with a tour and custom options to control its behavior and appearance. Refer to the options list for available settings.
```javascript
var guideChimp = GuideChimp(tour, options);
```
--------------------------------
### Initialize GuideChimp
Source: https://github.com/labs64/guidechimp/wiki/Configure
Initializes a new GuideChimp tour instance using a tour configuration.
```APIDOC
## Initialize GuideChimp
### Description
Initializes the GuideChimp library with a specified tour configuration.
### Parameters
- **tour** (string/object) - Required - The name of the tour if using HTML configuration or a tour JavaScript object.
- **options** (object) - Optional - Configuration options for tour behavior and look-and-feel.
### Request Example
```javascript
var guideChimp = GuideChimp(tour, options);
```
```
--------------------------------
### Initialize GuideChimp with JavaScript Tour Definition
Source: https://context7.com/labs64/guidechimp/llms.txt
Create a new GuideChimp instance by providing a JavaScript array of tour steps and an optional configuration object. The tour steps define elements, titles, descriptions, and positions. Options control behavior like keyboard navigation, exit conditions, and UI elements.
```javascript
var tour = [
{
element: '#welcome-section',
title: 'Welcome!',
description: 'This is your dashboard overview.',
position: 'bottom'
},
{
element: '#sidebar-menu',
title: 'Navigation',
description: 'Use this menu to navigate between sections.',
position: 'right'
},
{
element: '#user-profile',
title: 'Your Profile',
description: 'Click here to manage your account settings.',
position: 'left'
}
];
var options = {
position: 'bottom', // Default tooltip position: top, bottom, left, right
useKeyboard: true, // Enable arrow key navigation
exitEscape: true, // Stop tour on Escape key
exitOverlay: true, // Stop tour on overlay click
showPagination: true, // Show step pagination dots
showProgressbar: true, // Show progress bar
interaction: true, // Allow interaction with highlighted elements
padding: 10, // Padding around highlighted element
scrollPadding: 10, // Padding when scrolling to element
scrollBehavior: 'auto' // Scroll behavior: auto, smooth
};
var guideChimp = GuideChimp(tour, options);
```
--------------------------------
### GuideChimp Constructor
Source: https://context7.com/labs64/guidechimp/llms.txt
Initializes a new GuideChimp instance with tour steps and configuration options. The tour can be defined using an array of step objects or via HTML data attributes.
```APIDOC
## GuideChimp Constructor
### Description
Creates a new GuideChimp instance with tour steps and optional configuration options.
### Method
`GuideChimp(tour, options)`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **tour** (Array