The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

38 lines
986 B

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { Link } from 'react-router-dom';
  4. import Icon from 'mastodon/components/icon';
  5. const ColumnLink = ({ icon, text, to, href, method, badge }) => {
  6. const badgeElement = typeof badge !== 'undefined' ? <span className='column-link__badge'>{badge}</span> : null;
  7. if (href) {
  8. return (
  9. <a href={href} className='column-link' data-method={method}>
  10. <Icon id={icon} fixedWidth className='column-link__icon' />
  11. {text}
  12. {badgeElement}
  13. </a>
  14. );
  15. } else {
  16. return (
  17. <Link to={to} className='column-link'>
  18. <Icon id={icon} fixedWidth className='column-link__icon' />
  19. {text}
  20. {badgeElement}
  21. </Link>
  22. );
  23. }
  24. };
  25. ColumnLink.propTypes = {
  26. icon: PropTypes.string.isRequired,
  27. text: PropTypes.string.isRequired,
  28. to: PropTypes.string,
  29. href: PropTypes.string,
  30. method: PropTypes.string,
  31. badge: PropTypes.node,
  32. };
  33. export default ColumnLink;