ant-design/components/divider/index.tsx

35 lines
958 B
TypeScript
Raw Normal View History

import * as React from 'react';
import classNames from 'classnames';
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
}
export default function Divider({
prefixCls = 'ant',
type = 'horizontal',
orientation = '',
className,
children,
2017-10-26 20:59:36 +08:00
dashed,
...restProps
2017-11-21 20:48:22 +08:00
}: DividerProps) {
const orientationPrefix = (orientation.length > 0) ? '-' + orientation : orientation;
2017-10-26 20:59:36 +08:00
const classString = classNames(
className, `${prefixCls}-divider`, `${prefixCls}-divider-${type}`, {
[`${prefixCls}-divider-with-text${orientationPrefix}`]: children,
2017-10-26 20:59:36 +08:00
[`${prefixCls}-divider-dashed`]: !!dashed,
});
return (
<div className={classString} {...restProps}>
{children && <span className={`${prefixCls}-divider-inner-text`}>{children}</span>}
</div>
);
}