2021-08-26 14:15:34 -07:00
|
|
|
/**
|
|
|
|
* 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
|
2021-08-26 14:15:34 -07:00
|
|
|
*/
|
|
|
|
|
2020-03-27 13:59:38 -07:00
|
|
|
import PropTypes from 'prop-types';
|
2022-01-10 14:17:52 -08:00
|
|
|
import React from 'react';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2021-08-26 14:15:34 -07:00
|
|
|
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,
|
2022-03-23 10:14:42 -07:00
|
|
|
fixedWidth: PropTypes.bool,
|
2020-03-27 13:59:38 -07:00
|
|
|
};
|
|
|
|
|
2020-04-14 14:47:35 -07:00
|
|
|
render() {
|
2022-03-23 10:14:42 -07:00
|
|
|
const { id, src, fixedWidth, ...rest } = this.props;
|
2021-08-26 14:15:34 -07:00
|
|
|
|
2021-09-20 13:33:28 -07:00
|
|
|
if (src) {
|
|
|
|
return <SvgIcon src={src} {...rest} />;
|
|
|
|
} else {
|
2022-03-23 10:14:42 -07:00
|
|
|
return <ForkAwesomeIcon id={id} fixedWidth={fixedWidth} {...rest} />;
|
2021-08-26 14:15:34 -07:00
|
|
|
}
|
2020-03-27 13:59:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|