2017-11-17 14:38:54 +08:00
|
|
|
import * as React from 'react';
|
2017-08-19 12:39:11 +08:00
|
|
|
import classNames from 'classnames';
|
|
|
|
|
2017-11-21 20:48:22 +08:00
|
|
|
export interface DividerProps {
|
|
|
|
prefixCls?: string;
|
|
|
|
type?: 'horizontal' | 'vertical';
|
2018-02-11 11:51:56 +08:00
|
|
|
orientation?: 'left' | 'right';
|
2017-11-21 20:48:22 +08:00
|
|
|
className?: string;
|
|
|
|
children?: React.ReactNode;
|
|
|
|
dashed?: boolean;
|
2017-12-07 23:16:25 +08:00
|
|
|
style?: React.CSSProperties;
|
2017-11-21 20:48:22 +08:00
|
|
|
}
|
|
|
|
|
2017-08-19 12:39:11 +08:00
|
|
|
export default function Divider({
|
|
|
|
prefixCls = 'ant',
|
|
|
|
type = 'horizontal',
|
2018-02-11 11:51:56 +08:00
|
|
|
orientation = '',
|
2017-08-19 12:39:11 +08:00
|
|
|
className,
|
|
|
|
children,
|
2017-10-26 20:59:36 +08:00
|
|
|
dashed,
|
2017-08-19 12:39:11 +08:00
|
|
|
...restProps,
|
2017-11-21 20:48:22 +08:00
|
|
|
}: DividerProps) {
|
2018-02-11 11:51:56 +08:00
|
|
|
const orientationPrefix = (orientation.length > 0) ? '-' + orientation : orientation;
|
2017-10-26 20:59:36 +08:00
|
|
|
const classString = classNames(
|
|
|
|
className, `${prefixCls}-divider`, `${prefixCls}-divider-${type}`, {
|
2018-02-11 11:51:56 +08:00
|
|
|
[`${prefixCls}-divider-with-text${orientationPrefix}`]: children,
|
2017-10-26 20:59:36 +08:00
|
|
|
[`${prefixCls}-divider-dashed`]: !!dashed,
|
2017-08-19 12:39:11 +08:00
|
|
|
});
|
|
|
|
return (
|
|
|
|
<div className={classString} {...restProps}>
|
|
|
|
{children && <span className={`${prefixCls}-divider-inner-text`}>{children}</span>}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|