2017-05-02 20:04:16 -04:00
|
|
|
import React from 'react';
|
2017-04-21 14:05:35 -04:00
|
|
|
import PropTypes from 'prop-types';
|
2017-10-07 20:55:58 -04:00
|
|
|
import { Link } from 'react-router-dom';
|
2019-01-31 18:14:05 -05:00
|
|
|
import Icon from 'mastodon/components/icon';
|
2016-12-12 08:27:52 -05:00
|
|
|
|
2018-01-21 07:20:20 -05:00
|
|
|
const ColumnLink = ({ icon, text, to, href, method, badge }) => {
|
|
|
|
const badgeElement = typeof badge !== 'undefined' ? <span className='column-link__badge'>{badge}</span> : null;
|
|
|
|
|
2016-12-12 08:27:52 -05:00
|
|
|
if (href) {
|
|
|
|
return (
|
2017-07-26 07:46:53 -04:00
|
|
|
<a href={href} className='column-link' data-method={method}>
|
2019-01-31 18:14:05 -05:00
|
|
|
<Icon id={icon} fixedWidth className='column-link__icon' />
|
2016-12-12 08:27:52 -05:00
|
|
|
{text}
|
2018-01-21 07:20:20 -05:00
|
|
|
{badgeElement}
|
2016-12-12 08:27:52 -05:00
|
|
|
</a>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return (
|
2017-07-26 07:46:53 -04:00
|
|
|
<Link to={to} className='column-link'>
|
2019-01-31 18:14:05 -05:00
|
|
|
<Icon id={icon} fixedWidth className='column-link__icon' />
|
2016-12-12 08:27:52 -05:00
|
|
|
{text}
|
2018-01-21 07:20:20 -05:00
|
|
|
{badgeElement}
|
2016-12-12 08:27:52 -05:00
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ColumnLink.propTypes = {
|
2017-04-21 14:05:35 -04:00
|
|
|
icon: PropTypes.string.isRequired,
|
|
|
|
text: PropTypes.string.isRequired,
|
|
|
|
to: PropTypes.string,
|
|
|
|
href: PropTypes.string,
|
|
|
|
method: PropTypes.string,
|
2018-01-21 07:20:20 -05:00
|
|
|
badge: PropTypes.node,
|
2016-12-12 08:27:52 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
export default ColumnLink;
|