Switch to version 2: added src/components/shared/Tag.tsx

This commit is contained in:
2026-03-11 04:49:51 +00:00
parent 5613bf1451
commit cea4e22d4d

View File

@@ -0,0 +1,39 @@
"use client";
import { memo } from "react";
import { cls, shouldUseInvertedText } from "@/lib/utils";
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
import { LucideIcon } from "lucide-react";
interface TagProps {
text: string;
icon?: LucideIcon;
useInvertedBackground?: boolean;
className?: string;
textClassName?: string;
}
const Tag = memo(({
text,
icon: Icon,
useInvertedBackground,
className = "",
textClassName = "",
}: TagProps) => {
const theme = useTheme();
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
return (
<div className={cls(
"relative z-1 px-3 py-1 text-sm rounded-theme card inline-flex items-center gap-2 w-fit",
className
)}>
{Icon && <Icon className={cls("relative z-1 h-[1em] w-auto", shouldUseLightText ? "text-background" : "text-foreground")} />}
<span className={cls(shouldUseLightText ? "text-background" : "text-foreground", textClassName)}>{text}</span>
</div>
);
});
Tag.displayName = "Tag";
export default Tag;