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

34 lines
1,018 B
TypeScript
Raw Normal View History

import classNames from 'classnames';
2020-03-27 13:59:38 -07:00
import React from 'react';
2022-03-05 11:16:11 -08:00
import { useIntl, defineMessages } from 'react-intl';
2020-03-27 13:59:38 -07:00
2022-03-21 11:09:01 -07:00
import Icon from 'soapbox/components/ui/icon/icon';
2022-04-05 10:32:41 -07:00
import { useSoapboxConfig } from 'soapbox/hooks';
2022-03-05 11:16:11 -08:00
const messages = defineMessages({
verified: { id: 'account.verified', defaultMessage: 'Verified Account' },
});
interface IVerificationBadge {
className?: string,
}
2022-04-05 10:32:41 -07:00
const VerificationBadge: React.FC<IVerificationBadge> = ({ className }) => {
2022-03-05 11:16:11 -08:00
const intl = useIntl();
2022-04-05 10:32:41 -07:00
const soapboxConfig = useSoapboxConfig();
2022-03-05 11:16:11 -08:00
2022-03-05 11:55:41 -08:00
// Prefer a custom icon if found
2022-04-05 10:32:41 -07:00
const icon = soapboxConfig.verifiedIcon || require('icons/verified.svg');
2022-03-05 11:55:41 -08:00
// Render component based on file extension
2022-03-21 11:09:01 -07:00
const Element = icon.endsWith('.svg') ? Icon : 'img';
2022-03-05 11:55:41 -08:00
2022-03-05 11:16:11 -08:00
return (
2022-05-17 10:10:40 -07:00
<span className='verified-icon' data-testid='verified-badge'>
2022-03-21 11:09:01 -07:00
<Element className={classNames('w-4 text-accent-500', className)} src={icon} alt={intl.formatMessage(messages.verified)} />
2022-03-05 11:16:11 -08:00
</span>
);
};
2020-03-27 13:59:38 -07:00
export default VerificationBadge;