UNPKG

@massds/mayflower-react

Version:

React versions of Mayflower design system UI components

44 lines 1.46 kB
/** * ArrowButton module. * @module @massds/mayflower-react/ArrowButton * @requires module:@massds/mayflower-assets/scss/01-atoms/arrow-button */ import React from "react"; import PropTypes from "prop-types"; import classNames from "classnames"; const ArrowButton = props => { var _classNames; const buttonClasses = classNames((_classNames = { 'ma__arrow-button': true }, _classNames["ma__arrow-button--" + props.direction] = props.direction, _classNames['ma__arrow-button--left'] = !props.direction, _classNames)); const Element = props.href ? 'a' : 'button'; const onClickCallback = e => { if (typeof props.onClick === 'function') { e.preventDefault(); props.onClick(e); } }; return /*#__PURE__*/React.createElement(Element, { className: buttonClasses, onClick: e => onClickCallback(e), href: props.href, title: props.info, "aria-label": props.info }); }; ArrowButton.propTypes = process.env.NODE_ENV !== "production" ? { /** Custom click handler function. */ onClick: PropTypes.func, /** When populated with a url, this component renders a `<a>` vs a `<button>` */ href: PropTypes.string, /** The text which renders in the standard browser tooltip on hover */ info: PropTypes.string, /** Direction of the arrow. */ direction: PropTypes.oneOf(['left', 'right']) } : {}; ArrowButton.defaultProps = { href: '', info: '', direction: 'left' }; export default ArrowButton;