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

30 lines
907 B
TypeScript
Raw Normal View History

import classNames from 'clsx';
import React from 'react';
2020-03-27 13:59:38 -07:00
interface IBadge {
title: React.ReactNode,
2022-09-11 18:17:40 -07:00
slug: string,
}
/** Badge to display on a user's profile. */
2022-09-11 18:17:40 -07:00
const Badge: React.FC<IBadge> = ({ title, slug }) => {
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',
'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;