GithubHelp home page GithubHelp logo

bytedance / guide Goto Github PK

View Code? Open in Web Editor NEW
645.0 10.0 69.0 1.02 MB

A new feature guide component by react 🧭

License: Other

JavaScript 4.34% TypeScript 88.53% Shell 0.11% Less 7.02%
react guide typescript onboarding tour highlight

guide's Introduction

Introduction

English | 简体中文

When we onboard new users or ship new features, how do we make sure that our audience knows what's in it and get them excited to use our apps? That's where an onboarding sequence comes into play. This React library guide offers an effective way to construct a smooth onboarding experience. mask no mask

Installation

/* install via npm or yarn */
npm i byte-guide
yarn add byte-guide

/* load via umd */
<script src='https://unpkg.com/byte-guide/dist/index.umd.min.js'></script>
/* load via umd and specified version */
<script src='https://unpkg.com/byte-guide@version/dist/index.umd.min.js'></script>

Usage

import Guide from 'byte-guide';
<Guide
  steps={[]}
  localKey="uni-key"
  /* customize styles */
  hotspot
  modalClassName="my-guide-modal"
  maskClassName="my-guide-arrow"
  /* customize callbacks */
  onClose={() => {
    /* do sth */
  }}
  beforeStepChange={(nextIndex, nextStep) => {
    /* do sth */
  }}
  afterStepChange={(nextIndex, nextStep) => {
    /* do sth */
  }}
  /* customize footers */
  stepText={(stepIndex, stepCount) => `Step ${stepIndex} of ${stepCount}`}
  nextText="Next"
  prevText="Previous"
  showPreviousBtn
  okText="Finish"
/>;

API

Component API's

props definition type required defalut value
steps An array of info of each step of the onboarding sequence IStep[] --
localKey A unique key that will be stored in localStorage to indicate if the guide has finished string --
expireDate The expire date of the guide when it will not be displayed anymore string,YYYY-mm-hh --
closable If the guide can be closed before the last step. If false, the close button x will not be displayed on each modal. bool true
closeEle Customize the element that skips the guide string, reactNode
modalClassName The class name of the modal string --
maskClassName The class name of the mask string --
mask Whether or not to display the mask bool false
arrow Whether or not to display the arrow bool true
hotspot Whether or not to display the hotspot bool false
stepText The custom text for the step info (stepIndex, stepCount): string => {} (stepIndex, stepCount) => Step ${stepIndex} of ${stepCount}
nextText The custom text for the Next Step button string Next
prevText The custom text for the Previous step button string Previous
showPreviousBtn Whether or not to display the previous button bool true
okText The custom text for the confirm button at the last step string I know
visible If the guide is visible bool true
lang The language of use 'zh' | 'en' | 'ja' 'zh'
step The first step's number number 0
afterStepChange The callback function when the step changes (nextIndex, nextStep): void=>{} --
beforeStepChange The callback function when the user is about to move to the next step (stepIndex: number, step: IStep) => void --
onClose The callback function when the guide closes */
onClose?: () => void; ():void=> {} --

steps: IStep[]

key definition type required defalut value
selector The CSS Selector of the anchor element or the anchor element itself string | () => reactNode, reactNode --
targetPos If you don't want the modal to be displayed relative to an anchor element, you can pass a targetPos object to indicate the modal's position relative to the document body { top, left, width, height } Required when selector is not defined --
title The title of the modal string --
content The content of the modal string | reactNode --
placement The placement of the modal relative to the selector 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'left-top' | 'left-bottom' | 'right-top' | 'right-bottom' 'bottom'
offset The offset of the modal relative to the selector. x indicates the horizontal offset, y the vertical offset { x, y } --
parent The parent component to mount 'body'or null --
visible If this step is visible bool true
skip If this step should be skipped bool false
beforeStepChange The function called when user click "next" and BEFORE going to the next step (curStep: IStep, curStepIndex: number, steps: IStep[]) => void; --
afterStepChange The function called when user click "next" and AFTER going to the next step (curStep: IStep, curStepIndex: number, steps: IStep[]) => void; --

An example of steps

const steps = [
  {
    selector: '#search',
    title: 'Search',
    content: <div>You can now search for your customers using ID or name</div>,
    placement: 'bottom-left',
    offset: {
      x: 20,
    }
    beforeStepChange: () => {
      window.open('https://my.web.net')
    }
  },
  {
    selector: () => {
        const tabs = Array.from(
          document.querySelectorAll('.nav-scroll > div > div > .tab')
        );
        return tabs?.[2];
      },
    title: 'Customer Detail',
    content: 'In this tab, you can read and update customer details.'
    visible: location.pathname === 'customer/detail'
  }
];

guide's People

Contributors

albert-cord avatar fz6m avatar windlany avatar xch1029 avatar xyuwan avatar ycjcl868 avatar yjiang28 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

guide's Issues

不支持调整高亮元素的区域

image
我设置了高亮自定义属性targetPos,发现不生效,看了代码,好像是和高亮元素是二选一的,这里文档描述的好像不一样

getModalStyle top 计算问题

两列布局,左侧全屏,右侧垂直方向可以滚动,guide 组件添加在右侧,这种情况下 Modal 的 top 时会被算上 scrollTop 的值,导致 Modal 定位飞出可视范围。 demo 待补充。

未来待解决的问题

  1. 打包结果会带有一些 polyfill ,这些 polyfill 自带了 TypeCheck 的报错信息,浪费空间,不太友好,后面应该清理掉所有高阶语法,另外是否自己用 rollup 打包控制流程转而放弃黑盒 father 需要考虑。

  2. 没有 demo 站点。

  3. dumi doc 排版不太好,13 寸小屏不太友好,有一些覆盖和靠边的问题。

  4. 12 个方位假如指定了某个方位,靠屏幕边缘显示不全的时候是否应该自动更改方向,或者增加一个是否靠边自动更改方向的选项。

  5. 弹窗动画不太好

  6. unpkg 在国内太慢,需要 jsdelivr 加持

  7. 类名没有自己的前缀,容易冲突,比如 byted-guide-* ,后面应该需要增加前缀或者可自定义前缀。

steps中placement参数问题

image

placement我设置了top,但是页面渲染时还是预留默认的bottom位置,导致正常页面高度被撑出屏幕

蒙层高度的问题

image
你好,这个蒙层的高度是怎么计算的呀?正常来说是取得页面的高度,但是使用过程中发现取得是屏幕的高度?

当目标元素触发了外层的scroll时显示错误

  1. 比如a是父级, 目标元素是b (selector), 当a触发 overflow: auto; 内部滚动的时候则显示的不对
  2. 还要考虑多层滚动的情况, 比如 目标元素是b (selector), b 的父级是 a, a的父级是a1, a1的父级是a1, 并且a&a1&a1 都有滚动的情况需要循环判断。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.