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

32 lines
715 B
JavaScript
Raw Normal View History

/**
* Icon: abstract icon class that can render icons from multiple sets.
* @module soapbox/components/icon
* @see soapbox/components/fork_awesome_icon
2021-09-20 13:33:28 -07:00
* @see soapbox/components/svg_icon
*/
2020-03-27 13:59:38 -07:00
import React from 'react';
import PropTypes from 'prop-types';
import ForkAwesomeIcon from './fork_awesome_icon';
2021-09-20 13:33:28 -07:00
import SvgIcon from './svg_icon';
2020-03-27 13:59:38 -07:00
export default class Icon extends React.PureComponent {
static propTypes = {
2021-09-20 15:05:59 -07:00
id: PropTypes.string,
2021-09-20 13:33:28 -07:00
src: PropTypes.string,
2020-03-27 13:59:38 -07:00
className: PropTypes.string,
};
render() {
2021-09-20 13:33:28 -07:00
const { id, src, ...rest } = this.props;
2021-09-20 13:33:28 -07:00
if (src) {
return <SvgIcon src={src} {...rest} />;
} else {
return <ForkAwesomeIcon id={id} {...rest} />;
}
2020-03-27 13:59:38 -07:00
}
}