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

34 lines
825 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 PropTypes from 'prop-types';
import React from 'react';
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,
2022-04-04 12:05:15 -07:00
src: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
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
};
render() {
2022-03-23 10:14:42 -07:00
const { id, src, fixedWidth, ...rest } = this.props;
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} />;
}
2020-03-27 13:59:38 -07:00
}
}