/** * Separator * * @author Ivan Marshalkin * @date 2020-05-28 */ import * as React from 'react'; import * as styles from './Divider.m.scss'; import {joinClassNames} from '../../utils/joinClassNames'; export type DividerProps = { orientation?: 'horizontal' | 'vertical' | 'empty'; offset?: number; size?: number; type?: DIVIDER_TYPE; text?: string; } export enum DIVIDER_TYPE { solid = 'solid', dashed = 'dashed', longDashed = 'longDashed' } export class Divider extends React.Component { static defaultProps: DividerProps = { orientation: 'horizontal', offset: 18, type: DIVIDER_TYPE.solid }; override render () { const margin = this.props.orientation === 'vertical' ? `0 ${this.props.offset}px` : `${this.props.offset}px 0`; const size = this.props.size !== undefined ? `${this.props.size}px` : undefined; const style: React.CSSProperties = { margin: margin, [this.props.orientation === 'vertical' ? 'height' : 'width']: size }; if (this.props.text) { return (
{this.props.text}
); } return (
); } }