ConceptPortal-public/rsconcept/frontend/src/components/Shared/GrammemeBadge.tsx

34 lines
823 B
TypeScript
Raw Normal View History

import clsx from 'clsx';
import { useConceptTheme } from '@/context/ThemeContext';
import { GramData } from '@/models/language';
2023-12-26 14:23:51 +03:00
import { colorFgGrammeme } from '@/utils/color';
import { labelGrammeme } from '@/utils/labels';
2023-12-08 19:24:08 +03:00
interface GrammemeBadgeProps {
key?: string
grammeme: GramData
}
function GrammemeBadge({ key, grammeme }: GrammemeBadgeProps) {
const { colors } = useConceptTheme();
return (
<div
key={key}
className={clsx(
'min-w-[3rem]',
'px-1',
'border rounded-md',
'text-sm font-semibold text-center whitespace-nowrap'
)}
2023-12-08 19:24:08 +03:00
style={{
2023-12-26 14:23:51 +03:00
borderColor: colorFgGrammeme(grammeme, colors),
color: colorFgGrammeme(grammeme, colors),
2023-12-08 19:24:08 +03:00
backgroundColor: colors.bgInput
}}
>
{labelGrammeme(grammeme)}
</div>);
}
export default GrammemeBadge;