2023-12-15 17:34:50 +03:00
|
|
|
import clsx from 'clsx';
|
|
|
|
|
2024-06-26 19:47:31 +03:00
|
|
|
import { useConceptOptions } from '@/context/ConceptOptionsContext';
|
2023-12-13 14:32:57 +03:00
|
|
|
import { GramData } from '@/models/language';
|
2024-01-06 03:15:02 +03:00
|
|
|
import { colorFgGrammeme } from '@/styling/color';
|
2023-12-13 14:32:57 +03:00
|
|
|
import { labelGrammeme } from '@/utils/labels';
|
2023-12-08 19:24:08 +03:00
|
|
|
|
2024-05-16 22:39:28 +03:00
|
|
|
interface BadgeGrammemeProps {
|
2024-11-21 15:09:51 +03:00
|
|
|
/** Grammeme to display. */
|
2023-12-28 14:04:44 +03:00
|
|
|
grammeme: GramData;
|
2023-12-08 19:24:08 +03:00
|
|
|
}
|
|
|
|
|
2024-11-21 15:09:51 +03:00
|
|
|
/**
|
|
|
|
* Displays a badge with a grammeme tag.
|
|
|
|
*/
|
2024-05-16 22:39:28 +03:00
|
|
|
function BadgeGrammeme({ grammeme }: BadgeGrammemeProps) {
|
2024-04-01 19:07:20 +03:00
|
|
|
const { colors } = useConceptOptions();
|
2023-12-08 19:24:08 +03:00
|
|
|
return (
|
2023-12-28 14:04:44 +03:00
|
|
|
<div
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-05-16 22:39:28 +03:00
|
|
|
export default BadgeGrammeme;
|