soapbox/app/soapbox/components/badge.tsx

30 wiersze
882 B
TypeScript
Czysty Zwykły widok Historia

2023-02-06 18:01:03 +00:00
import clsx from 'clsx';
import React from 'react';
2020-03-27 20:59:38 +00:00
interface IBadge {
title: React.ReactNode
slug: string
}
/** Badge to display on a user's profile. */
2022-09-12 01:17:40 +00:00
const Badge: React.FC<IBadge> = ({ title, slug }) => {
const fallback = !['patron', 'admin', 'moderator', 'opaque', 'badge:donor'].includes(slug);
2022-09-12 01:17:40 +00:00
return (
<span
data-testid='badge'
2023-02-06 18:06:44 +00:00
className={clsx('inline-flex items-center rounded px-2 py-0.5 text-xs font-medium', {
2022-09-12 01:17:40 +00:00
'bg-fuchsia-700 text-white': slug === 'patron',
'bg-emerald-800 text-white': slug === 'badge:donor',
2022-09-12 01:17:40 +00: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 18:06:44 +00:00
'bg-white/75 text-gray-900': slug === 'opaque',
2022-09-12 01:17:40 +00:00
})}
>
{title}
</span>
);
};
2020-04-14 21:37:17 +00:00
2020-03-27 20:59:38 +00:00
export default Badge;