2024-06-07 20:17:03 +03:00
|
|
|
import clsx from 'clsx';
|
|
|
|
|
|
|
|
import { GramData } from '@/models/language';
|
2024-12-16 23:51:31 +03:00
|
|
|
import { APP_COLORS, colorFgGrammeme } from '@/styling/color';
|
2024-06-07 20:17:03 +03:00
|
|
|
import { labelGrammeme } from '@/utils/labels';
|
|
|
|
|
|
|
|
interface BadgeGrammemeProps {
|
2024-11-21 15:09:31 +03:00
|
|
|
/** Grammeme to display. */
|
2024-06-07 20:17:03 +03:00
|
|
|
grammeme: GramData;
|
|
|
|
}
|
|
|
|
|
2024-11-21 15:09:31 +03:00
|
|
|
/**
|
|
|
|
* Displays a badge with a grammeme tag.
|
|
|
|
*/
|
2024-06-07 20:17:03 +03:00
|
|
|
function BadgeGrammeme({ grammeme }: BadgeGrammemeProps) {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={clsx(
|
|
|
|
'min-w-[3rem]', // prettier: split lines
|
|
|
|
'px-1',
|
|
|
|
'border rounded-md',
|
|
|
|
'text-sm font-medium text-center whitespace-nowrap'
|
|
|
|
)}
|
|
|
|
style={{
|
2024-12-16 23:51:31 +03:00
|
|
|
borderColor: colorFgGrammeme(grammeme),
|
|
|
|
color: colorFgGrammeme(grammeme),
|
|
|
|
backgroundColor: APP_COLORS.bgInput
|
2024-06-07 20:17:03 +03:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
{labelGrammeme(grammeme)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default BadgeGrammeme;
|