react-toolbox/components/font_icon/FontIcon.js

35 lines
790 B
JavaScript
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
2016-05-16 15:18:53 +03:00
import classnames from 'classnames';
2015-11-23 01:41:00 +03:00
2017-01-24 13:12:40 +03:00
const FontIcon = ({ alt, children, className, theme, value, ...other}) => ( // eslint-disable-line
2016-05-16 15:18:53 +03:00
<span
2017-01-26 20:05:32 +03:00
data-react-toolbox="font-icon"
aria-label={alt}
2017-01-26 20:05:32 +03:00
className={classnames({ 'material-icons': typeof value === 'string' || typeof children === 'string' }, className)}
2016-05-16 15:18:53 +03:00
{...other}
>
2017-03-23 13:06:29 +03:00
{value}
2017-01-24 13:07:43 +03:00
{children}
2016-05-16 15:18:53 +03:00
</span>
);
2015-09-19 18:53:31 +03:00
FontIcon.propTypes = {
alt: PropTypes.string,
2017-01-26 20:05:32 +03:00
children: PropTypes.node,
className: PropTypes.string,
2017-01-26 20:05:32 +03:00
theme: PropTypes.object, // eslint-disable-line
value: PropTypes.oneOfType([
PropTypes.string,
2017-01-26 20:05:32 +03:00
PropTypes.element,
]),
};
2015-09-19 18:53:31 +03:00
FontIcon.defaultProps = {
alt: '',
2017-01-26 20:05:32 +03:00
className: '',
};
2015-09-19 18:53:31 +03:00
export default FontIcon;
2016-05-29 20:38:06 +03:00
export { FontIcon };