0.0.1 • Published 6 years ago

ray-hints v0.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

ray-hints

dependencies

usage

css

import 'intro.js/introjs.css';

module

import { TipSteps, TipHints } from 'ray-hints';

Steps demo

  • Basic
const steps = [
  {
    element: '.selector1',
    intro: '步骤1',
    position: 'right',
    tooltipClass: 'myTooltipClass',
    highlightClass: 'myHighlightClass',
  },
  {
    element: '.selector2',
    intro: '步骤2',
  },
  {
    element: '.selector3',
    intro: '步骤3',
  },
];

<TipSteps
  enabled={stepsEnabled}
  steps={steps}
  initialStep={initialStep}
  onExit={this.onExit}
/>
  • Dynamic elements

如果想使用Intro.js步骤与动态创建的元素,则必须更新与该步骤相关联的元素

使用 updateStepElement() API

onBeforeChange = nextStepIndex => {
  if (nextStepIndex === 4) {
    this.steps.updateStepElement(nextStepIndex);
  }
}

<TipSteps
  enabled={stepsEnabled}
  steps={steps}
  ref={steps => (this.steps = steps)}
/>

TipHints demo

const hints = [
  {
    element: '.selector1',
    hint: 'test 1',
    hintPosition: 'middle-middle',
  },
  {
    element: '.selector2',
    hint: 'test 2',
  },
];

<TipHints
  enabled={hintsEnabled}
  hints={hints}
/>

// use Instro instance
<TipHints
  enabled={hintsEnabled}
  steps={hints}
  ref={hints => (this.hints = hints)}
/>

Install

npm install ray-hints --save

Props

TipSteps props

paramtypedefaultdescription
enabledBooleanfalse定义steps是否可见.
initialStepNumber-其实步骤.
stepsStep[]-所有的步骤.
onExitFunction: (stepIndex) => {}null退出时的回调. 注意:当使用内联Intro.js事件而不是prop enabled 取消步骤时,需要强制跟踪状态.
onBeforeExitFunction: (stepIndex) => {}null退出之前回调. 如果想要阻止退出,在回调中返回 false 即可 (since intro.js 0.2.7).
onStartFunction: (stepIndex) => {}null启用后回调.
onChangeFunction: (nextStepIndex, nextElement) => {}null当前步骤改变时的回调.
onBeforeChangeFunction: (nextStepIndex) => {}null当前步骤改变前的回调. 如果想要阻止上一个/下一个,返回 false 即可 (since intro.js 2.8.0).*
onAfterChangeFunction: (nextStepIndex, nextElement) => {}null更改当前步骤后调用回调.
onPreventChangeFunction: (stepIndex) => {}nullonBeforeChange中返回false时,将阻止转换为新的步骤.
onCompleteFunctionnull完成所有步骤后调用回调.
optionsObject{ hidePrev: true, hideNext: true }Intro.js 配置参数.

Step

{
  element: String // 用于步骤的CSS选择器.
  intro: String // 提示文本.
  position: String // 提示显示位置.
  tooltipClass: String // 提示框样式名.
  highlightClass: String // 高亮浮层的样式名.
}

TipHints props

paramtypedefaultdescription
enabledBooleanfalseTipHints是否可见.
hintsHint[]-所有的 TipHints.
onClickFunction-点击 TipHints 时的回调.
onCloseFunction-TipHints关闭时的回调.
optionsObject-Intro.js 配置参数.

Hint

{
  element: String // hint 元素选择器,必填
  hint: String // hint提示内容,必填
  hintPosition: String // 提示框位置
  hintAnimation: Boolean // 是否启用动画
}

Intro.js-options

Intro.js documentation

Intro.js options

Intro.js code.

default options _utils/defaultProps.js file.

paramtypedescription
nextLabelString下一个 标签内容.
prevLabelString上一个 标签内容.
skipLabelString跳过 标签内容.
doneLabelString完成 标签内容.
hidePrevBoolean隐藏第一步中的 上一个 按钮.
hideNextBoolean隐藏最后一步中的 下一个 按钮.
tooltipPositionString提示框位置,可选值 top,right,bottom,left,'bottom-left-aligned','bottom-middle-aligned','bottom-right-aligned',auto.
tooltipClassString提示框样式名.
highlightClassString高亮浮层的样式名.
exitOnEscBoolean按键ESC是否退出.
exitOnOverlayClickBoolean点击浮层是是否退出.
showStepNumbersBoolean在红色圆圈中显示步骤编号.
keyboardNavigationBoolean允许使用键盘跳转各个步骤.
showButtonsBoolean显示导航按钮.
showBulletsBoolean显示弹头.
showProgressBoolean显示进度指示器.
scrollToElementBoolean是否启用自动滚动到在视窗之外的元素.
scrollToElement滚动到指定的元素,当scrollToElementtrue 时应用.
scrollPaddingNumberscrollToElementtrue 时,自动填充的padding值,默认30px
overlayOpacityNumber浮层透明度.
disableInteractionBoolean禁用突出显示元素的内部交互.

hint-options

paramtypedescription
hintPositionStringhint位置,可选值为 'top-middle','top-left','top-right','bottom-left','bottom-right','bottom-middle','middle-left','middle-right','middle-middle'.
hintButtonLabelStringhint按钮白哦前.
hintAnimationBoolean是否启用hint动画.

License

MIT