You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { Link } from 'react-router-dom';
  4. const ColumnLink = ({ icon, text, to, onClick, href, method, badge }) => {
  5. const badgeElement = typeof badge !== 'undefined' ? <span className='column-link__badge'>{badge}</span> : null;
  6. if (href) {
  7. return (
  8. <a href={href} className='column-link' data-method={method}>
  9. <i className={`fa fa-fw fa-${icon} column-link__icon`} />
  10. {text}
  11. {badgeElement}
  12. </a>
  13. );
  14. } else if (to) {
  15. return (
  16. <Link to={to} className='column-link'>
  17. <i className={`fa fa-fw fa-${icon} column-link__icon`} />
  18. {text}
  19. {badgeElement}
  20. </Link>
  21. );
  22. } else {
  23. return (
  24. <a onClick={onClick} className='column-link' role='button' tabIndex='0' data-method={method}>
  25. <i className={`fa fa-fw fa-${icon} column-link__icon`} />
  26. {text}
  27. {badgeElement}
  28. </a>
  29. );
  30. }
  31. };
  32. ColumnLink.propTypes = {
  33. icon: PropTypes.string.isRequired,
  34. text: PropTypes.string.isRequired,
  35. to: PropTypes.string,
  36. onClick: PropTypes.func,
  37. href: PropTypes.string,
  38. method: PropTypes.string,
  39. badge: PropTypes.node,
  40. };
  41. export default ColumnLink;