soapbox/app/soapbox/components/verification-badge.tsx

34 wiersze
1001 B
TypeScript
Czysty Zwykły widok Historia

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