ant-design/components/timeline/TimelineItem.tsx
Tom Xu 514cc062be
chore: fix timeline TimelineItemProps typo (#27001)
* chore: fix timeline TimelineItemProps typo

* Update Timeline.tsx

* Update TimelineItem.tsx

* Update TimelineItem.tsx

* Update TimelineItem.tsx

* Update TimelineItem.tsx

Co-authored-by: Olivier Louvignes <olivier@mgcrea.io>
Co-authored-by: 偏右 <afc163@gmail.com>
2020-10-03 22:03:09 +08:00

73 lines
1.8 KiB
TypeScript

import * as React from 'react';
import classNames from 'classnames';
import omit from 'omit.js';
import { ConfigContext } from '../config-provider';
export interface TimelineItemProps {
prefixCls?: string;
className?: string;
color?: string;
dot?: React.ReactNode;
pending?: boolean;
position?: string;
style?: React.CSSProperties;
label?: React.ReactNode;
}
// for compatibililty
// https://github.com/ant-design/ant-design/pull/26832
export interface TimeLineItemProps extends TimelineItemProps {
__deprecated_do_not_use_it__?: any; // eslint-disable-line camelcase
}
const TimelineItem: React.FC<TimelineItemProps> = props => {
const { getPrefixCls } = React.useContext(ConfigContext);
const {
prefixCls: customizePrefixCls,
className,
color,
children,
pending,
dot,
label,
...restProps
} = props;
const prefixCls = getPrefixCls('timeline', customizePrefixCls);
const itemClassName = classNames(
{
[`${prefixCls}-item`]: true,
[`${prefixCls}-item-pending`]: pending,
},
className,
);
const dotClassName = classNames({
[`${prefixCls}-item-head`]: true,
[`${prefixCls}-item-head-custom`]: dot,
[`${prefixCls}-item-head-${color}`]: true,
});
return (
<li {...omit(restProps, ['position'])} className={itemClassName}>
{label && <div className={`${prefixCls}-item-label`}>{label}</div>}
<div className={`${prefixCls}-item-tail`} />
<div
className={dotClassName}
style={{ borderColor: /blue|red|green|gray/.test(color || '') ? undefined : color }}
>
{dot}
</div>
<div className={`${prefixCls}-item-content`}>{children}</div>
</li>
);
};
TimelineItem.defaultProps = {
color: 'blue',
pending: false,
position: '',
};
export default TimelineItem;