react-toolbox/components/link/index.jsx

35 lines
866 B
React
Raw Normal View History

import React from 'react';
2015-09-19 19:20:11 +03:00
import style from './style';
import FontIcon from '../font_icon';
const Link = props => {
let className = style.root;
2015-10-21 13:25:07 +03:00
if (props.className) className += ` ${props.className}`;
return (
<a
2015-10-21 13:25:07 +03:00
{...props}
data-react-toolbox='link'
2015-10-21 13:25:07 +03:00
href={props.route}
className={className}
>
2015-10-21 13:25:07 +03:00
{ props.icon ? <FontIcon className={style.icon} value={props.icon} /> : null }
{ props.label ? <abbr>{props.label}</abbr> : null }
{ props.count && parseInt(props.count) !== 0 ? <small>{props.count}</small> : null}
</a>
);
};
2015-09-19 19:20:11 +03:00
Link.propTypes = {
label: React.PropTypes.string,
className: React.PropTypes.string,
count: React.PropTypes.number,
icon: React.PropTypes.string,
onClick: React.PropTypes.func,
route: React.PropTypes.string
};
2015-09-19 19:20:11 +03:00
Link.defaultProps = {
attributes: '',
className: ''
};