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

36 lines
885 B
TypeScript
Raw Normal View History

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