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

@owenjs/lets-tour

v0.5.1

Published

Dead simple React element Walk-Through package. Powered by [Popper.js](https://popper.js.org/) and [@reactour/mask](https://github.com/elrumordelaluz/reactour/tree/main/packages/mask)

Downloads

10

Readme

Lets Tour

Dead simple React element Walk-Through package. Powered by Popper.js and @reactour/mask

Styling of popover is completely upto you!

We're in Beta, breaking changes to come 😘

Coded with ❤️ by owenjs

Demo

Install

yarn add @owenjs/lets-tour

Usage

import { TLetsTourStep, LetsTourProvider, useLetsTourContext } from "@owenjs/lets-tour";
import { useMemo } from "react";

/**
 * Each step in the Tour
 */
const STEPS: TLetsTourStep[] = [
  {
    selector: `[data-tour-step="1"]`
  },
  {
    selector: `[data-tour-step="2"]`
  }
];

/**
 * Popover component and Styling
 */
const Popover = () => {
  const { currentStep, handleBack, handleNext } = useLetsTourContext();

  const content = useMemo(() => {
    switch (currentStep) {
      case 0:
        return "Step 1";
      case 1:
        return "Step 2";
    }
  }, [currentStep]);

  return (
    <div style={{ background: "#ffffff" }}>
      {content}
      <button onClick={handleBack}>Back</button>
      <button onClick={handleNext}>Next</button>
    </div>
  );
};

/**
 * Main app component
 */
const App = () => {
  const { handleStartTour } = useLetsTourContext();

  return (
    <>
      <div data-tour-step="1">Step 1 Item</div>
      <div data-tour-step="2">Step 2 Item</div>

      <button onClick={handleStartTour}>Open Tour</button>
    </>
  );
};

/**
 * React Index File
 */
const Index = () => {
  return (
    <LetsTourProvider steps={STEPS} Component={Popover}>
      <App />
    </LetsTourProvider>
  );
};

Component API

ILetsTourProviderProps

import { LetsTourProvider } from "@owenjs/lets-tour";

const App = () => {
  // ...
  
  return (
    <LetsTourProvider {...ILetsTourProviderProps}>
      {/* Rest of your React App! */}
    </LetsTourProvider>
  );
};

isOpen?: boolean

Allow Tourer to be a controlled component
@default false

steps: TLetsTourStep[]

Each step in the Tour, see TLetsTourStep

Component: () => ReactNode

Component to render the popover

onOpen?: () => void

Fired whenever the Tour is opened

onClose?: () => void

Fired whenever the Tour is closed

onChange?: (isOpen: boolean) => void

Fired whenever the Tour Open or Closed state is changed
Allows the component to be controlled

isDismissible?: boolean

Should the Tour be dismissible by the user clicking on the backdrop?

maskPadding?: [number, number]

Padding around the Highlighted Area
@default [10, 10]

onBackdropClick?: MouseEventHandler<HTMLDivElement>

Event handler for user clicks on the Tour backdrop

onHighlightedAreaClick?: MouseEventHandler<SVGRectElement>

Event handler for user clicks on the Highlighted Area

backdropClassName?: string

ClassName for the Tour backdrop

highlightedAreaClassName?: string

ClassName for the highlighted area of the Tour

maskStyles?: Record

Styles for the Mask
Optionally extend the default styles using the base param

type maskStyles = {
  /**
   * Styles for the Tour backdrop
   * @param base default styles
   */
  backdrop?: (base: CSSProperties) => CSSProperties;
  /**
   * Styles for the Tour Highlighted Area
   * @param base default styles
   * @param props
   * @param props.x x position of the Highlighted Area
   * @param props.y y position of the Highlighted Area
   * @param props.width width of the Highlighted Area
   * @param props.height height of the Highlighted Area
   */
  highlightedArea?: (
    base: CSSProperties,
    props: {
      x: number;
      y: number;
      width: number;
      height: number;
    }
  ) => CSSProperties;
};

TTourContext

import { useLetsTourContext } from "@owenjs/lets-tour";

const App = () => {
  const { ... } = useLetsTourContext();
  
  // ...
};

steps: TLetsTourStep[]

Each step in the Tour, see TLetsTourStep

isOpen: boolean

Open state of the Tour

setIsOpen: Dispatch<SetStateAction<boolean>>

Set state for the open state of the Tour

currentStep: number

Current step of the Tour (starting at 0)

setCurrentStep: Dispatch<SetStateAction<number>>

Set state for the current step of the Tour (starting at 0)

handleStartTour: () => void

Start the Tour programmatically

handleEndTour: () => void

End the Tour programmatically

handleBack: () => void

Go back a step in the Tour

handleNext: () => void

Go forward a step in the Tour

TLetsTourStep

selector: string

CSS selector use to position of the Tour Popover

placement?: Placement

Placement of Tour Popover around selected element
@default auto

offset?: [number, number]

Offset the Tour Popper
@default [0, 20]