bigbuffet-rw/app/soapbox/components/svg_icon.js

34 lines
708 B
JavaScript
Raw Normal View History

2021-09-12 16:54:38 -07:00
/**
* SvgIcon: abstact component to render SVG icons.
* @module soapbox/components/svg_icon
* @see soapbox/components/icon
*/
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
2021-09-12 16:54:38 -07:00
import InlineSVG from 'react-inlinesvg';
export default class SvgIcon extends React.PureComponent {
static propTypes = {
src: PropTypes.string.isRequired,
2022-03-05 11:16:11 -08:00
alt: PropTypes.string,
2021-09-12 16:54:38 -07:00
className: PropTypes.string,
};
render() {
2022-03-05 11:16:11 -08:00
const { src, className, alt, ...other } = this.props;
2021-09-12 16:54:38 -07:00
return (
<div
className={classNames('svg-icon', className)}
{...other}
>
2022-03-05 11:16:11 -08:00
<InlineSVG src={src} title={alt} />
2021-09-12 16:54:38 -07:00
</div>
);
}
}