2018-10-20 20:32:02 +08:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import cx from 'classnames';
|
|
|
|
|
|
|
|
const Icon = ({ id, width = 20, height = 20, className, ...props }) => {
|
|
|
|
const c = cx('icon', id, className);
|
|
|
|
const href = '#' + id;
|
|
|
|
return (
|
|
|
|
<svg className={c} width={width} height={height} {...props}>
|
|
|
|
<use xlinkHref={href} />
|
|
|
|
</svg>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Icon.propTypes = {
|
|
|
|
id: PropTypes.string.isRequired,
|
|
|
|
width: PropTypes.number,
|
|
|
|
height: PropTypes.number,
|
|
|
|
className: PropTypes.string
|
|
|
|
};
|
|
|
|
|
2018-11-05 18:32:16 +08:00
|
|
|
export default React.memo(Icon);
|