# @redbuck/intro

> Step-by-step guide

Latest version **0.0.4** (published 2019-04-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install @redbuck/intro
pnpm add @redbuck/intro
yarn add @redbuck/intro
bun add @redbuck/intro
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2019-04-10 |
| First published | 2019-04-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 36.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | TY-xie |
| Maintainers | redbuck |
| Keywords | introduction, step |

## Links

- npm: https://www.npmjs.com/package/@redbuck/intro
- Repository: https://github.com/xty1992a/intro
- Homepage: https://github.com/xty1992a/intro#readme
- Issues: https://github.com/xty1992a/intro/issues
- npm.io page: https://npm.io/package/@redbuck/intro

## Dependencies (1)

- [preact](https://npm.io/package/preact.md) ^8.4.2

## Recent versions

- 0.0.4 (latest) — 2019-04-10
- 0.0.3 — 2019-04-08
- 0.0.2 — 2019-04-08
- 0.0.1 — 2019-04-08

## README

### 截图上传组件

#### 简介
一个简单的引导插件.
支持事件钩子并跳过步骤.
umd格式,可`<script>`和import引入使用.

[Live Code](https://codepen.io/xty1992a/pen/WWGdKX)

#### 安装
js: `npm i @redbuck/intro`或`yarn add @redbuck/intro`

css: 位于`@redbuck/intro/lib/intro.css`

#### 使用
```
const intro = new Intro(options)
```

options:

属性 | 类型 | 默认值|描述
--:|--:|--:|--:
steps| `Array` | []|步骤
stepCount|`Number`|1|播放次数
storageKey|`String`|'intro_play_count'|标识播放次数

steps为一个成员为对象(step)的数组.对象必须包含el,text字段

其中,el字段应为DOM对象,或DOM对象组成的数组,或者是返回前述类型的函数.

引导窗将聚焦这个(些)DOM围合成的矩形.
text字段将自动排布在剩余方向中,最大的一个.


实例支持浏览器事件风格绑定回调.
```
intro.on(event, callback)
```
支持事件

事件|参数|描述
--:|--:|--:|
before-next|{step, next, skip}|下一步之前,传入下一步step对象,调用next以继续插件流程,也可以调用skip跳过该步骤
done|无|结束事件

#### 示例
查看static/demo.html获取全部详情
```javascript
const intro = new Intro({
  playCount: 3,
  steps: [
	{
	  el: $('#left'),
	  text: '点击这里,打开新世界大门!',
	},
	{
	// el can be on array
	  el: [$('#block1'), $('#block2'), $('#block3')],
	  text: '根据你想【赠送的奖励】,选择不同的活动类型',
	},
	{
	  el: $('#block4'),
	  text: '选择第5项活动',
	},
	{
	  el: $('#block6'),
	  text: '当你同时要赠送多种奖励时，请选择组合送吧！',
	},
	{
	  el: $('#item1'),
	  text: '点这里，可以查看和管理所有的活动1',
	},
	{
	  el: $('#item2'),
	  text: '点这里，可以查看和管理所有的活动2',
	},
	{
	  el: $('#item3'),
	  text: '点这里，可以查看和管理所有的活动3',
	},
	{
	  el: $('#item4'),
	  text: '点这里，可以查看和管理所有的活动4',
	},
	{
	  el: $('#item5'),
	  text: '点这里，可以查看和管理所有的活动5',
	},
  ],
})

// if you did not listen this event, intro will auto next
intro.on('before-next', async ({step, next, skip}) => {
  // do something
  console.log('before-next', step)
  // continue this step
  if (step.el) {
	next()
  }
  // you can skip this step
  else {
	skip()
  }
})

```

---
_Source: https://npm.io/package/@redbuck/intro · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
