2022-08-31 02:35:06 -07:00
|
|
|
import classNames from 'clsx';
|
2022-01-10 14:17:52 -08:00
|
|
|
import React from 'react';
|
2020-03-27 13:59:38 -07:00
|
|
|
|
2022-04-24 15:01:57 -07:00
|
|
|
interface IBadge {
|
2022-05-24 08:16:07 -07:00
|
|
|
title: React.ReactNode,
|
2022-09-11 18:17:40 -07:00
|
|
|
slug: string,
|
2022-04-24 15:01:57 -07:00
|
|
|
}
|
|
|
|
/** Badge to display on a user's profile. */
|
2022-09-11 18:17:40 -07:00
|
|
|
const Badge: React.FC<IBadge> = ({ title, slug }) => {
|
2022-09-11 18:44:49 -07:00
|
|
|
const fallback = !['patron', 'admin', 'moderator', 'opaque', 'badge:donor'].includes(slug);
|
2022-09-11 18:17:40 -07:00
|
|
|
|
|
|
|
return (
|
|
|
|
<span
|
|
|
|
data-testid='badge'
|
|
|
|
className={classNames('inline-flex items-center px-2 py-0.5 rounded text-xs font-medium', {
|
|
|
|
'bg-fuchsia-700 text-white': slug === 'patron',
|
2022-09-11 18:44:49 -07:00
|
|
|
'bg-emerald-800 text-white': slug === 'badge:donor',
|
2022-09-11 18:17:40 -07:00
|
|
|
'bg-black text-white': slug === 'admin',
|
|
|
|
'bg-cyan-600 text-white': slug === 'moderator',
|
|
|
|
'bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-gray-100': fallback,
|
|
|
|
'bg-white bg-opacity-75 text-gray-900': slug === 'opaque',
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
{title}
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
};
|
2020-04-14 14:37:17 -07:00
|
|
|
|
2020-03-27 13:59:38 -07:00
|
|
|
export default Badge;
|