react-toolbox/components/link/Link.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-05-29 21:03:41 +03:00
import React, { PropTypes } from 'react';
2016-05-22 19:18:47 +03:00
import classnames from 'classnames';
import { themr } from 'react-css-themr';
2016-05-29 21:03:41 +03:00
import { LINK } from '../identifiers.js';
import FontIcon from '../font_icon/FontIcon.js';
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 = {
2016-05-29 21:03:41 +03:00
active: PropTypes.bool,
children: PropTypes.node,
className: PropTypes.string,
count: PropTypes.number,
icon: PropTypes.oneOfType([
PropTypes.string,
PropTypes.element
]),
2016-05-29 21:03:41 +03:00
label: PropTypes.string,
theme: PropTypes.shape({
active: PropTypes.string,
icon: PropTypes.string,
link: PropTypes.string
2016-05-22 19:18:47 +03:00
})
};
2015-09-19 19:20:11 +03:00
Link.defaultProps = {
active: false,
className: ''
};
2015-11-01 11:14:36 +03:00
2016-05-29 21:03:41 +03:00
export default themr(LINK)(Link);
export { Link };