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';
|
2022-01-10 14:17:52 -08:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
2022-04-10 11:18:10 -07:00
|
|
|
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 (
|
2022-02-11 14:57:49 -08:00
|
|
|
<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>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|