ant-design/components/spin/Indicator/index.tsx
二货爱吃白萝卜 0352b2fd2e
feat: Spin support percent (#48657)
* feat: spin support ptg

* chore: ptg

* chore: update demo

* chore: popout component

* chore: adjust logic

* test: update snapshot

* test: update snapshot

* docs: update docs

* test: update snapshot

* test: update snapshot

* test: update snapshot

* chore: back of snapshot

* chore: clean up

* test: fix test case

* chore: fix types

* test: update snapshot

* chore: opt

* test: update testcase

* test: coverage

* test: update snapshot
2024-06-03 11:30:27 +08:00

25 lines
656 B
TypeScript

import * as React from 'react';
import classNames from 'classnames';
import { cloneElement } from '../../_util/reactNode';
import Looper from './Looper';
export interface IndicatorProps {
prefixCls: string;
indicator?: React.ReactNode;
percent?: number;
}
export default function Indicator(props: IndicatorProps) {
const { prefixCls, indicator, percent } = props;
const dotClassName = `${prefixCls}-dot`;
if (indicator && React.isValidElement(indicator)) {
return cloneElement(indicator, {
className: classNames(indicator.props.className, dotClassName),
});
}
return <Looper prefixCls={prefixCls} percent={percent} />;
}