import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { get } from 'lodash'; import { numbers, cssClasses, strings } from '@douyinfe/semi-foundation/popover/constants'; export interface ArrowProps { position?: string; className?: string; arrowStyle?: React.CSSProperties; popStyle?: React.CSSProperties; } const Arrow: React.FC = (props = {}) => { const { position = '', className, arrowStyle, popStyle, ...rest } = props; const isVertical = position.indexOf('top') === 0 || position.indexOf('bottom') === 0; const cls = classnames(className, cssClasses.ARROW); const borderOpacity = get(arrowStyle, 'borderOpacity', strings.DEFAULT_ARROW_STYLE.borderOpacity); const bgColor = get( arrowStyle, 'backgroundColor', get(popStyle, 'backgroundColor', strings.DEFAULT_ARROW_STYLE.backgroundColor) ); const borderColor = get( arrowStyle, 'borderColor', get(popStyle, 'borderColor', strings.DEFAULT_ARROW_STYLE.borderColor) ); const wrapProps = { ...rest, width: numbers.ARROW_BOUNDING.width, height: numbers.ARROW_BOUNDING.height, xmlns: 'http://www.w3.org/2000/svg', className: cls, }; return isVertical ? ( ) : ( ); }; Arrow.propTypes = { position: PropTypes.string, className: PropTypes.string, arrowStyle: PropTypes.object, popStyle: PropTypes.object, }; export default Arrow;