react-toolbox/components/link/Link.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

import React from 'react';
2016-05-22 19:18:47 +03:00
import classnames from 'classnames';
2015-09-19 19:20:11 +03:00
import FontIcon from '../font_icon';
2016-05-22 19:18:47 +03:00
import { themr } from 'react-css-themr';
2015-09-19 19:20:11 +03:00
2016-05-22 19:18:47 +03:00
const Link = ({active, children, className, count, icon, label, theme, ...others}) => {
const _className = classnames(theme.link, {
[theme.active]: active
}, className);
return (
2016-05-22 19:18:47 +03:00
<a data-react-toolbox='link' className={_className} {...others}>
{icon ? <FontIcon className={theme.icon} value={icon} /> : null}
{label ? <abbr>{label}</abbr> : null}
{count && parseInt(count) !== 0 ? <small>{count}</small> : null}
{children}
</a>
);
};
2015-09-19 19:20:11 +03:00
Link.propTypes = {
active: React.PropTypes.bool,
children: React.PropTypes.node,
className: React.PropTypes.string,
count: React.PropTypes.number,
icon: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.element
]),
2016-05-22 19:18:47 +03:00
label: React.PropTypes.string,
theme: React.PropTypes.shape({
active: React.PropTypes.string.isRequired,
icon: React.PropTypes.string.isRequired,
link: React.PropTypes.string.isRequired
})
};
2015-09-19 19:20:11 +03:00
Link.defaultProps = {
active: false,
className: ''
};
2015-11-01 11:14:36 +03:00
2016-05-22 19:18:47 +03:00
export default themr('ToolboxLink')(Link);