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

34 lines
809 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';
import InlineSVG from 'react-inlinesvg'; // eslint-disable-line no-restricted-imports
2021-09-12 16:54:38 -07:00
export default class SvgIcon extends React.PureComponent {
static propTypes = {
2022-04-04 12:05:15 -07:00
src: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).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-04-10 10:56:15 -07:00
<InlineSVG src={src} title={alt} loader={<></>} />
2021-09-12 16:54:38 -07:00
</div>
);
}
}