Files
blitzkit/packages/website-ue/src/components/Badge/index.tsx
T

32 lines
810 B
TypeScript
Raw Normal View History

2026-01-15 12:55:18 -06:00
import type { ComponentProps } from "react";
import { classNames } from "../../core/ui/classNames";
import type { Color } from "../../core/ui/color";
2026-01-17 13:50:53 -06:00
import { LIGHT_TEXT_COLORS } from "../Button";
import styles from "./index.module.css";
2026-01-15 12:55:18 -06:00
export interface BadgeProps extends ComponentProps<"div"> {
color?: Color | "accent";
highContrast?: boolean;
}
export function Badge({
className,
style,
color = "accent",
highContrast,
...props
}: BadgeProps) {
2026-01-17 13:50:53 -06:00
const lightText = LIGHT_TEXT_COLORS.has(color as Color);
2026-01-15 12:55:18 -06:00
return (
<div
2026-01-17 13:50:53 -06:00
className={classNames(styles.badge, className)}
2026-01-15 12:55:18 -06:00
style={{
backgroundColor: `var(--${color}-${highContrast ? 12 : 9})`,
2026-01-17 13:50:53 -06:00
color: `var(--gray-${highContrast || lightText ? 1 : 12})`,
2026-01-15 12:55:18 -06:00
...style,
}}
{...props}
/>
);
}