Giter VIP home page Giter VIP logo

tour's Introduction

@rc-component/tour

React 18 supported Tour Component.

NPM version dumi build status Codecov npm download

Development

npm install
npm start
open http://localhost:8000

Feature

  • React life cycle support tour component

Install

@rc-component/tour

Usage

import Tour from '@rc-component/tour';

const Demo = () => {
    const createBtnRef = useRef<HTMLButtonElement>(null);
    const updateBtnRef = useRef<HTMLButtonElement>(null);
    const deleteBtnRef = useRef<HTMLButtonElement>(null);
    return (
        <div style={{ margin: 20 }}>
            <div>
                <button
                    className="ant-target"
                    ref={createBtnRef}
                    style={{ marginLeft: 100 }}
                >
                    Create
                </button>
                <div style={{ height: 200 }} />
                <button className="ant-target" ref={updateBtnRef}>
                    Update
                </button>
                <button className="ant-target" ref={deleteBtnRef}>
                    Delete
                </button>
            </div>

            <div style={{ height: 200 }} />

            <Tour
                defaultCurrent={0}
                steps={[
                    {
                        title: '创建',
                        description: '创建一条数据',
                        target: () => createBtnRef.current,
                        mask: true,
                    },
                    {
                        title: '更新',
                        description: (
                            <div>
                                <span>更新一条数据</span>
                                <button>帮助文档</button>
                            </div>
                        ),
                        target: () => updateBtnRef.current,
                    },
                    {
                        title: '删除',
                        description: (
                            <div>
                                <span>危险操作:删除一条数据</span>
                                <button>帮助文档</button>
                            </div>
                        ),
                        target: () => deleteBtnRef.current,
                        mask: true,
                        style: { color: 'red' },
                    },
                ]}
            />
        </div>
    );
};

export default Demo;

🔥 API

We use typescript to create the Type definition. You can view directly in IDE. But you can still check the type definition here.

Tour

属性 类型 默认值 说明
closeIcon React.ReactNode - 自定义关闭按钮
steps TourStepProps[] - 引导步骤
open boolean true 受控打开引导(与 current 受控分开)
current number 0 受控当前处于哪一步
defaultCurrent number 0 默认处于哪一步
gap { offset?: number | [number, number]; radius?: number } - 控制引导显示间距
onChange (current: number) => void - 步骤改变时的回调,current为改变前的步骤,next为改变后的步骤
onClose (current: number) => void - 关闭引导时的回调
onFinish () => void - 完成引导时的回调
mask boolean | { style?: React.CSSProperties; color?: string; } true 整体是否启用蒙层,也可以传入自定义样式修改蒙层样式
animated boolean | { placeholder: boolean } false 是否启用目标遮罩动画
arrow boolean | { pointAtCenter: boolean} true 整体是否显示箭头,包含是否指向元素中心的配置
scrollIntoViewOptions boolean | ScrollIntoViewOptions true 是否支持当前元素滚动到视窗内,也可传入配置指定滚动视窗的相关参数
onPopupAlign function(popupDomNode, align) - 当弹出框对齐后回调
zIndex number 1001 弹层的层级

TourStep

属性 类型 默认值 说明
closeIcon React.ReactNode - 自定义关闭按钮
target () => HTMLElement | HTMLElement - 获取引导卡片指向的元素
arrow boolean | { pointAtCenter: boolean} true 是否显示箭头,包含是否指向元素中心的配置
placement left | leftTop | leftBottom | right | rightTop | rightBottom | top | topLeft | topRight | bottom | bottomLeft | bottomRight bottom 引导卡片相对于目标元素的位置
onClose () => void - 关闭引导时的回调函数
mask boolean | { style?: React.CSSProperties; color?: string; } true 是否启用蒙层,也可以传入自定义样式修改蒙层样式,默认跟随 Tour 的 mask 属性
renderPanel (props: TourStepProps, current: number) => ReactNode; 渲染 popoup 弹窗方法
className string - -
style React.CSSProperties - -
scrollIntoViewOptions boolean | ScrollIntoViewOptions true 是否支持当前元素滚动到视窗内,也可传入配置指定滚动视窗的相关参数,默认跟随 Tour 的 scrollIntoViewOptions 属性

tour's People

Contributors

afc163 avatar anuglyplugin avatar fuphoenixes avatar heiyu4585 avatar kiner-tang avatar lgtm-com[bot] avatar li-jia-nan avatar linxianxi avatar madccc avatar peachscript avatar redjue avatar zhou-bill avatar zombiej 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tour's Issues

Inability to style rc-tour used in a custom web component due to it being placed in the document.body by default

Hello.

I am currently working on using the rc-tour component in an Antd 4.24.x project but I couldn't get the rc-tour divs (rc-tour-mask, rc-tour-target-placeholder, and rc-tour) to be placed within the custom web component being used.

The custom web component contains the stylings which apply to the web component alone and we don't want the styles to leak out of the component. Also, we don't want to manage a separate styles file which can be placed on the page as different page sections have different colour theme styles. We want the rc-tour theme to be controlled by the webcomponent.

Has the team explored the use of a getContainer prop which then gets passed to the Portal components within the rc-tour for such placements similar to Antd Tooltips and Popovers?

Will be glad to put in a PR for it if this use case hasn't been explored yet.

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.