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

28 lines
751 B
TypeScript
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
* @see soapbox/components/svg_icon
*/
import React from 'react';
2022-11-15 06:10:14 -08:00
import ForkAwesomeIcon, { IForkAwesomeIcon } from './fork-awesome-icon';
2022-11-15 08:00:49 -08:00
import SvgIcon, { ISvgIcon } from './svg-icon';
export type IIcon = IForkAwesomeIcon | ISvgIcon;
const Icon: React.FC<IIcon> = (props) => {
if ((props as ISvgIcon).src) {
const { src, ...rest } = (props as ISvgIcon);
return <SvgIcon src={src} {...rest} />;
} else {
const { id, fixedWidth, ...rest } = (props as IForkAwesomeIcon);
return <ForkAwesomeIcon id={id} fixedWidth={fixedWidth} {...rest} />;
}
};
export default Icon;