mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-19 23:03:24 +08:00
b0850139f2
* feat: init * feat: update * feat: upate * feat: update * feat: update * feat: init * feat: init * feat: init * feat: update * feat: update * feat: update * feat: update rc-tour * feat: init component * feat: init component * chore: update pck * doc: update doc * doc: update reviewer * doc: update reviewer * doc: update reviewer * feat: update reviewer * feat: update reviewer * feat: update doc * feat: update deme * feat: update demo doc * feat: update demo * feat: update demo * feat: update style * feat: update dom & style * feat: update dome * feat: update dome * docs: update demo * feat: update doc * feat: update dome * feat: add locale * doc: update locale * doc: add test * feat: add test case * feat: add test case * feat: update package * feat: update ts * feat: update ts * feat: update snapshots * feat: update demo * feat: update demo * feat: update demo * feat: edit maxSize * feat: edit maxSize * feat: update lint * feat: update lint * feat: update style reviewer * feat: update style * feat: merge next * feat: add locale * feat: reset bundleSize * feat: change maxSize * feat: update test coverage * feat: update test coverage * feat: add type * chore: simplify en locale * feat: update * feat: update test snap * docs: demo update * chore: adjust style * chore: adjust style * chore: bump rc-tour * Update package.json * feat: update package * feat: update package * feat: update cover * docs: update api * docs: update overview snap * feat: update token * feat: delete repeat ts * feat: remove finishButtonProps * chore: update demo * feat: tour style * test: fix lint * chore: code clean Co-authored-by: lijianan <574980606@qq.com> Co-authored-by: 二货机器人 <smith3816@gmail.com> Co-authored-by: MadCcc <1075746765@qq.com>
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import React, { useContext } from 'react';
|
|
import RCTour from '@rc-component/tour';
|
|
import classNames from 'classnames';
|
|
import panelRender from './panelRender';
|
|
import type { ConfigConsumerProps } from '../config-provider';
|
|
import { ConfigContext } from '../config-provider';
|
|
import useStyle from './style';
|
|
import type { TourProps, TourStepProps } from './interface';
|
|
|
|
const Tour: React.ForwardRefRenderFunction<HTMLDivElement, TourProps> = props => {
|
|
const {
|
|
prefixCls: customizePrefixCls,
|
|
steps,
|
|
current,
|
|
type,
|
|
rootClassName,
|
|
...restProps
|
|
} = props;
|
|
const { getPrefixCls, direction } = useContext<ConfigConsumerProps>(ConfigContext);
|
|
const prefixCls = getPrefixCls('tour', customizePrefixCls);
|
|
const [wrapSSR, hashId] = useStyle(prefixCls);
|
|
|
|
const customClassName = classNames(
|
|
{
|
|
[`${prefixCls}-rtl`]: direction === 'rtl',
|
|
},
|
|
{
|
|
[`${prefixCls}-primary`]: type === 'primary',
|
|
},
|
|
hashId,
|
|
rootClassName,
|
|
);
|
|
|
|
const mergedRenderPanel = (stepProps: TourStepProps, stepCurrent: number) =>
|
|
panelRender(stepProps, stepCurrent, type);
|
|
|
|
return wrapSSR(
|
|
<RCTour
|
|
{...restProps}
|
|
rootClassName={customClassName}
|
|
prefixCls={prefixCls}
|
|
steps={steps}
|
|
current={current}
|
|
renderPanel={mergedRenderPanel}
|
|
/>,
|
|
);
|
|
};
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
Tour.displayName = 'Tour';
|
|
}
|
|
|
|
export default Tour;
|