npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@leadoo/react-bot

v0.4.0

Published

React components for Leadoo bots

Downloads

71

Readme

React Bots

React components for Leadoo bots

Build Status

Leadoo In-Page bot demo

This UI library provides components and helpers for using Leadoo bots within React environments.

Please note that to use these bot components, you need to have a Leadoo account.

About

Leadoo bots are complex JavaScript applications that render complex UI element trees, and they are usually not directly usable within reactive environments such as React. React can update the DOM, removing and moving elements around, many times a second (in extreme cases). Doing so with a Leadoo bot inside could result in large amounts of errors and memory overflow - but this library is designed to handle that.

These React components wrap Leadoo bots and handle all the cleanup and mount/dismount preparation for you.

Please note that destroying and recreating bot components regularly should be considered an anti-pattern. Do not place bot components in areas or subtrees that are regularly re-rendered.

Bot Types

Currently In-Page (InPageBot) and Visual (VisualBot) bots are supported. These bots are containers that can be placed in content areas.

Compatibility

These components are designed for the latest version of React, at least version 18.2.

The bots used within these components follow internal bot generation configurations - please see your Leadoo contact regarding the version of your bot before using this toolkit.

Important: The modules in this library are built using ESM - They will only work within other ESM environments, or projects with a compatible build phase (Webpack/Rollup etc.). CommonJS exports are no longer supported.

Usage

Install by running the following:

npm install @leadoo/react-bot --save-dev

You can import separate bot components to use in your website:

import { InPageBot } from "@leadoo/react-bot";

export function MyComponent() {
    return (
        <div>
            <InPageBot code="abc123" />
        </div>
    );
}

Development

Once cloned, execute npm install in the root of this project using at least NodeJS version 10.

You can develop on this repository, having the files watched for changes, by running npm run dev. To build a production copy in the dist directory, run npm run build. You can run the tests by executing npm test.

When publishing, make sure to use the np module, installed globally. Make sure to update the CHANGELOG.md file beforehand with your changes.

To preview the components in this repository, run npm run storybook to open the component stories in your browser.

API

InPageBot

In-Page bot wrapper. Import using { InPageBot }.

Properties:

| Property | Required | Default | Description | |-------------------|-----------|-----------|---------------------------------------| | code | Yes | None | The bot code (provided by Leadoo). | | mediaPartner | | None | Optional Media Partner identifier. Enables Media Partner mode. | | seamless | | true | Whether to run in seamless mode or not. |

Usage is straightforward - import the InPageBot component and place it in your application using a bot code:

import { InPageBot } from "@leadoo/react-bot";

const BOT_CODE = "xyz123";

export function MyApp() {
    return (
        <div>
            <InPageBot code={BOT_CODE} seamless={false} />
        </div>
    );
}

When using a Media Partner configuration, set the mediaPartner property to the Media Partner identifier used in your system:

import { InPageBot } from "@leadoo/react-bot";

const MEDIA_PARTNER = "MyCompany";

function getSectionCode(): string {
    return /^\/blog/.test(window.location.pathname)
        ? "blog"
        : "main";
}

export function MyApp() {
    return (
        <div>
            <InPageBot
                code={getSectionCode()}
                mediaPartner={MEDIA_PARTNER}
            />
        </div>
    );
}

Make sure to read the Media Partner concept description.

VisualBot

Visual bot wrapper. Import using { VisualBot }.

Properties:

| Property | Required | Default | Description | |-------------------|-----------|-----------|---------------------------------------| | code | Yes | None | The bot code (provided by Leadoo). | | seamless | | false | Whether to run in seamless mode or not. |

Usage is straightforward - import the VisualBot component and place it in your application using a bot code:

import { VisualBot } from "@leadoo/react-bot";

const BOT_CODE = "xyz123";

export function MyApp() {
    return (
        <div>
            <VisualBot code={BOT_CODE} seamless />
        </div>
    );
}

Concepts

Seamless mode

Seamless mode allows the bot to continue expanding, vertically, as content appears within it. This is not the default mode of operation, which is to lock at a certain height and use a scroll-bar to continue viewing content within the bot.

Seamless mode can appear more natural in certain scenarios, as more of the bot content is visible to the user.

Media Partner

The Media Partner configuration is a subset of functionality available for configuring In-Page bots so that they're installation and configuration are handled separately, at different times, and possibly by different teams at a company.

Using a Media Partner setup, bots can be placed on a page using dynamic codes which can be later tied to an actual bot set-up through the UI. Bot scripts that run and do not find an associated bot on that account simply do nothing.