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';
|
2018-12-05 19:12:18 +08:00
|
|
|
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
2017-08-19 12:39:11 +08:00
|
|
|
|
2017-11-21 20:48:22 +08:00
|
|
|
export interface DividerProps {
|
|
|
|
prefixCls?: string;
|
|
|
|
type?: 'horizontal' | 'vertical';
|
2018-08-01 15:43:47 +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
|
|
|
}
|
|
|
|
|
2018-12-05 19:12:18 +08:00
|
|
|
const Divider: React.SFC<DividerProps> = props => (
|
|
|
|
<ConfigConsumer>
|
|
|
|
{({ getPrefixCls }: ConfigConsumerProps) => {
|
|
|
|
const {
|
|
|
|
prefixCls: customizePrefixCls,
|
|
|
|
type = 'horizontal',
|
|
|
|
orientation = '',
|
|
|
|
className,
|
|
|
|
children,
|
|
|
|
dashed,
|
|
|
|
...restProps
|
|
|
|
} = props;
|
|
|
|
const prefixCls = getPrefixCls('divider', customizePrefixCls);
|
2018-12-07 20:02:01 +08:00
|
|
|
const orientationPrefix = orientation.length > 0 ? '-' + orientation : orientation;
|
|
|
|
const classString = classNames(className, prefixCls, `${prefixCls}-${type}`, {
|
2018-12-05 19:12:18 +08:00
|
|
|
[`${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;
|