0.2.7 • Published 1 year ago

@guiderjs/react v0.2.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Guiderjs React

A React component for creating customizable and animated guider on your website.

Get started

Installation

# npm
$ npm install @guiderjs/react
# yarn
$ yarn add @guiderjs/react

usage

// App.tsx
import Guider, { IGuider, Step } from "@guiderjs/react";
import { FC, useRef } from "react";

const App: FC = () => {
  // guider instance
  const guider = useRef<IGuider>(null);
  // guider steps
  const steps: Step[] = [{ key: "card", target: ".card" }];

  return (
    <div>
      <div className="card">Card content</div>
      <button onClick={() => guider.current?.start()}>start</button>
      <Guider ref={guider} steps={steps} />
    </div>
  );
};

API

IGuider

interface IGuider {
  /**
   * start guider from the step has given key, if no step key given, start from the first step.
   * guider needs to be `show` or `stop` status
   * @param stepKey key of the step to start
   */
  start: (stepKey?: string) => void;
  /**
   * go to next step, if current step is the last step, exit
   */
  next: () => void;
  /**
   * go back one step, if current step is the first step, do nothing.
   */
  back: () => void;
  /**
   * exit guider
   */
  exit: () => Promise<void>;
}

Component props

propsdescriptiontypedefault
steps (required)an array contains info of guider stepsStep[]-
onStartthe callback function when guider start() => void-
onExitthe callback function when guider exited() => void-
targetselector to select target (highlighted) elementstring-
targetClassclassName of targetstring-
preventTargetif prevent interaction of origin target elementbooleantrue
onTargetClickthe callback function when user click target (highlighted) part() => void-
overlayColorbackground color of overlaysstring"#333333"
overlayOpacityopacity of overlaysnumber0.5
overlayClassclassName of overlaysstring-
zIndexzindex property of guider containernumber99999
popoverpopover elementReact.ReactElement-
popoverPositionposition of popover (works when you have popover)"auto" | "center" | "target-top" | "target-bottom" | "target-left" | "target-right""auto"
popoverAnchorpopover position to target"start"|"middle"|"end""middle"
popoverGapgap (px) between popover and target, (works when you have popover and target)number8
popoverLeftleft property of popoverstring"0px"
popoverToptop property of popoverstring"0px"
popoverAnimationpopover animation namestring"flip-y"
popoverAnimationDurationpopover animation durationstring"400ms"
popoverAnimationFunctionpopover animation timing functionstring"ease"
onStepStartthe callback function when step start(step:Step,index:number) => void-
onStepExitthe callback function when step exit(step:Step,index:number) => void-

Step

(info of one guider step, will override component props)

propertydescriptiontypedefault
key (required)unique key of stepstring-
targetselector to select target (highlighted) elementstring-
targetClassclassName of targetstring-
preventTargetif prevent interaction of origin target elementbooleantrue
onTargetClickthe callback function when user click target (highlighted) part() => void-
overlayColorbackground color of overlaysstring"#333333"
overlayOpacityopacity of overlaysnumber0.5
overlayClassclassName of overlaysstring-
zIndexzindex property of guider containernumber99999
popoverpopover elementReact.ReactElement-
popoverPositionposition of popover (works when you have popover)"auto" | "center" | "target-top" | "target-bottom" | "target-left" | "target-right""auto"
popoverAnchorpopover position to target"start"|"middle"|"end""middle"
popoverGapgap (px) between popover and target, (works when you have popover and target)number8
popoverLeftleft property of popoverstring"0px"
popoverToptop property of popoverstring"0px"
popoverAnimationpopover animation namestring"flip-y"
popoverAnimationDurationpopover animation durationstring"400ms"
popoverAnimationFunctionpopover animation timing functionstring"ease"
onStepStartthe callback function when step start(step:Step,index:number) => void-
onStepExitthe callback function when step exit(step:Step,index:number) => void-
payloadstep payloadany-
0.2.7

1 year ago

0.2.6

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago