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

30 lines
884 B
TypeScript
Raw Normal View History

2023-02-06 10:01:03 -08:00
import clsx 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'
2023-02-06 10:06:44 -08:00
className={clsx('inline-flex items-center rounded px-2 py-0.5 text-xs font-medium', {
2022-09-11 18:17:40 -07:00
'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,
2023-02-06 10:06:44 -08:00
'bg-white/75 text-gray-900': slug === 'opaque',
2022-09-11 18:17:40 -07:00
})}
>
{title}
</span>
);
};
2020-04-14 14:37:17 -07:00
2020-03-27 13:59:38 -07:00
export default Badge;