2017-05-03 09:04:16 +09:00
|
|
|
import React from 'react';
|
2017-04-22 03:05:35 +09:00
|
|
|
import PropTypes from 'prop-types';
|
2017-10-08 09:55:58 +09:00
|
|
|
import { Link } from 'react-router-dom';
|
2016-12-12 22:27:52 +09:00
|
|
|
|
2018-01-23 10:05:13 +09:00
|
|
|
const ColumnLink = ({ icon, text, to, onClick, href, method, badge }) => {
|
|
|
|
const badgeElement = typeof badge !== 'undefined' ? <span className='column-link__badge'>{badge}</span> : null;
|
|
|
|
|
2016-12-12 22:27:52 +09:00
|
|
|
if (href) {
|
|
|
|
return (
|
2017-07-26 20:46:53 +09:00
|
|
|
<a href={href} className='column-link' data-method={method}>
|
2017-04-23 11:26:55 +09:00
|
|
|
<i className={`fa fa-fw fa-${icon} column-link__icon`} />
|
2016-12-12 22:27:52 +09:00
|
|
|
{text}
|
2018-01-23 10:05:13 +09:00
|
|
|
{badgeElement}
|
2016-12-12 22:27:52 +09:00
|
|
|
</a>
|
|
|
|
);
|
2017-06-29 14:00:54 +09:00
|
|
|
} else if (to) {
|
2016-12-12 22:27:52 +09:00
|
|
|
return (
|
2017-07-26 20:46:53 +09:00
|
|
|
<Link to={to} className='column-link'>
|
2017-04-23 11:26:55 +09:00
|
|
|
<i className={`fa fa-fw fa-${icon} column-link__icon`} />
|
2016-12-12 22:27:52 +09:00
|
|
|
{text}
|
2018-01-23 10:05:13 +09:00
|
|
|
{badgeElement}
|
2016-12-12 22:27:52 +09:00
|
|
|
</Link>
|
|
|
|
);
|
2017-06-29 14:00:54 +09:00
|
|
|
} else {
|
|
|
|
return (
|
2017-08-02 05:46:52 +09:00
|
|
|
<a onClick={onClick} className='column-link' role='button' tabIndex='0' data-method={method}>
|
2017-06-29 14:00:54 +09:00
|
|
|
<i className={`fa fa-fw fa-${icon} column-link__icon`} />
|
|
|
|
{text}
|
2018-01-23 10:05:13 +09:00
|
|
|
{badgeElement}
|
2017-06-29 14:00:54 +09:00
|
|
|
</a>
|
|
|
|
);
|
2016-12-12 22:27:52 +09:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ColumnLink.propTypes = {
|
2017-04-22 03:05:35 +09:00
|
|
|
icon: PropTypes.string.isRequired,
|
|
|
|
text: PropTypes.string.isRequired,
|
|
|
|
to: PropTypes.string,
|
2017-06-29 14:00:54 +09:00
|
|
|
onClick: PropTypes.func,
|
2017-04-22 03:05:35 +09:00
|
|
|
href: PropTypes.string,
|
|
|
|
method: PropTypes.string,
|
2018-01-23 10:05:13 +09:00
|
|
|
badge: PropTypes.node,
|
2016-12-12 22:27:52 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
export default ColumnLink;
|