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

easy-guide

v0.0.10

Published

用户指导

Downloads

6

Readme

EasyGuide

一个简单,便捷,可维护的用户指导。

Why?

我想很多时候你可能都不需要 EasyGuide.js。 因为市场上已经有很好用用户指导的组件了,比如:intro.js,而且它足够优秀!

但是为什么我还要写这个组件库? 这是当你尝试了市场上的其他用户指导的组件以后,你会发现有一种试用场景:在不能更改需要指导的对象代码的前提下,它们没有办法实现。我写这个框架的目的也是基于这个初衷! 没错,EasyGuide.js 不会入侵需要指导对象的目标代码。 基于这个特性,对于我们嵌入不属于我们自己的页面,或者需要有大量的代码需要更改,还需要做引导的时候有着非常重要的意义!

How?

EasyGuide 设计理念:指导页面逻辑无关,根据用户的屏幕,页面定位,完成指导功能。 因为跟页面没有逻辑关系,因此,EasyGuide 有两种模式:管理员模式 用户模式

  • 管理员模式:管理员在页面维护需要指导用户的信息。需要后端辅助保存数据;
  • 用户模式:在这个模式下只能查看 管理员 给你维护好的指导数据。

Live DEMO

线上 demo: http://www.abners.cn/easy-guide/demo

文档:http://www.abners.cn/easy-guide

Getting started

首先 npm 安装:

npm i easy-guide

然后 import 引入和初始化指导:

import EasyGuide from 'easy-guide';
import 'easy-guide/dist/easy-guide.css';

// 创建一个实例:
const guide = new EasyGuide({
  ...Config
})

Config

EasyGuide 配置:

| 参数 | 说明 | 类型 | 默认值 | | :----------------------- | :-------------------------------------------------- | :--------------------------------------------------- | :----- | | guideList | 指导数据列表 | array<guideItem> | [] | | mode | 指导当前所处的模式 | 'READ' | 'MAINTAIN' | 'READ' | | currentIndex | 查看模式下,当前指导对应的数组下标 | number | 0 | | beforeCreate | 指导创建前(必须自己实现) | function(guideInstance, guideItem) | null | | beforeNext | 下一步 前 | function(oldIndex, newIndex, guideList) | null | | afterNext | 下一步 后 | function(oldIndex, newIndex, guideList) | null | | beforePrev | 上一步 前 | function(oldIndex, newIndex, guideList) | null | | afterPrev | 上一步 后 | function(oldIndex, newIndex, guideList) | null | | guildClose | 指导关闭 | function(currentIndex, guideItem, guideList) | null | | onGuideListChange | 指导数据变化 | function(action, guideItem, guideList) | null |

  • action

    onGuideListChange 派发的事件行为,是一个字符串的枚举类型:'create', 'modify', 'delete'

  • guideItem

    每一项指导至少包含这些内容:

    {
      id: String((new Date()).getTime()),
      content: '',
      width: 0.15,
      widthUtil: '%',
      height: 120,
      heightUtil: 'px',
      left: 0.5,
      leftUtil: '%',
      top: 200,
      topUtil: 'px',
      orderNumber: 1,
      fixFlag: 'N',
      contentPosition: '_eG_guide-1'
    }

Api

  • EasyGuide.show(mode)

    展示指导,需要传入展示对应的模式 action

  • EasyGuide.destroy()

    销毁指导组件

  • EasyGuide.setGuideList(list)

    设置指导的列表

  • EasyGuide.setGuideItem(guideItem)

    更改指定 guideItem

  • EasyGuide.getGuideList()

    获取全部指导数据

  • EasyGuide.getGuideItemById()

    通过 ID 获取指导数据

  • EasyGuide.getConfig()

    获取当前实例配置

Example

import EasyGuide from 'easy-guide';
import 'easy-guide/dist/easy-guide.css';

const guide = new EasyGuide({
  mode: 'READ', // 初始化进入查看模式
  guideList: [], // TODO: 放置远程拉取到的数据
  beforeCreate: async (guideInstance, guideItem) => {
    // 1. 把即将要创建的数据保存到后端
    const res = await fetch({
      url: 'http://www.xxx.com',
      method: 'POST',
      body: guideItem // 对象传递格式,依据后端接口而定
    })

    // 2. 后端返回成功以后,需要把数据返回给 EasyGuide 渲染.
    //    新的数据必须带 `id` 字段, 如果数据格式不同,需要自己实现转换
    return res.newGuideItem
  },
  onGuideListChange: async (action, data) => {
    if (action === 'modify') {
      await fetch({
        url: 'http://www.xxx.com',
        method: 'POST',
        body: guideItem
      })
    } else if (action === 'delete') {
      ...
    } else {
      ...
    }
  },
  ...
})

// 展示维护模式
guide.show('MAINTAIN');

// 展示查看模式
guide.show('READ')

// 销毁
guide.destroy()

Changelog

  • v0.0.8 (Feb 3, 2021): 完善文档
  • v0.0.7 (Feb 2, 2021): 组件支持配置;修复若干 Bugs
  • v0.0.1 (Jan 20, 2021): 初始化发布组件

License

EasyGuide is available under the MIT license.