mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 19:19:26 +08:00
e2d119dd0e
close #16987
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import * as React from 'react';
|
|
import classNames from 'classnames';
|
|
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
|
|
|
export interface DividerProps {
|
|
prefixCls?: string;
|
|
type?: 'horizontal' | 'vertical';
|
|
orientation?: 'left' | 'right' | 'center';
|
|
className?: string;
|
|
children?: React.ReactNode;
|
|
dashed?: boolean;
|
|
style?: React.CSSProperties;
|
|
}
|
|
|
|
const Divider: React.SFC<DividerProps> = props => (
|
|
<ConfigConsumer>
|
|
{({ getPrefixCls }: ConfigConsumerProps) => {
|
|
const {
|
|
prefixCls: customizePrefixCls,
|
|
type = 'horizontal',
|
|
orientation = 'center',
|
|
className,
|
|
children,
|
|
dashed,
|
|
...restProps
|
|
} = props;
|
|
const prefixCls = getPrefixCls('divider', customizePrefixCls);
|
|
const orientationPrefix = orientation.length > 0 ? '-' + orientation : orientation;
|
|
const classString = classNames(className, prefixCls, `${prefixCls}-${type}`, {
|
|
[`${prefixCls}-with-text${orientationPrefix}`]: children,
|
|
[`${prefixCls}-dashed`]: !!dashed,
|
|
});
|
|
return (
|
|
<div className={classString} {...restProps}>
|
|
{children && <span className={`${prefixCls}-inner-text`}>{children}</span>}
|
|
</div>
|
|
);
|
|
}}
|
|
</ConfigConsumer>
|
|
);
|
|
|
|
export default Divider;
|