Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update tag-badge.tsx

Tim Wilson10a7d94ac1a1
diff --git a/apps/web/ui/links/tag-badge.tsx b/apps/web/ui/links/tag-badge.tsx
index 201d47d2f0..4ca3e719ba 100644
--- a/apps/web/ui/links/tag-badge.tsx
+++ b/apps/web/ui/links/tag-badge.tsx
@@ -1,6 +1,6 @@
import { TagColorProps } from "@/lib/types";
import { useMediaQuery } from "@dub/ui";
-import { cn, truncate as truncateFn } from "@dub/utils";
+import { cn, truncate } from "@dub/utils";
import { Tag } from "lucide-react";
export default function TagBadge({
@@ -8,43 +8,32 @@ export default function TagBadge({
color,
withIcon,
plus,
- /** Whether the tag badge is primary information and should avoid truncating/collapsing */
- primary = false,
- className,
}: {
name: string;
color: TagColorProps;
withIcon?: boolean;
plus?: number;
- primary?: boolean;
- className?: string;
}) {
const { isDesktop } = useMediaQuery();
return (
<span
className={cn(
- "my-auto flex items-center gap-x-1.5 whitespace-nowrap rounded-md border px-2 py-0.5 text-sm",
- ((withIcon && !primary) || plus) &&
- "rounded-full p-1.5 sm:rounded-md sm:px-2 sm:py-0.5",
+ "my-auto whitespace-nowrap rounded-md border px-2 py-0.5 text-sm",
+ (withIcon || plus) &&
+ "flex items-center gap-x-1.5 rounded-full p-1.5 sm:rounded-md sm:px-2 sm:py-0.5",
color === "red" && "border-red-300 bg-red-100 text-red-600",
color === "yellow" && "border-yellow-300 bg-yellow-100 text-yellow-600",
color === "green" && "border-green-300 bg-green-100 text-green-600",
color === "blue" && "border-blue-300 bg-blue-100 text-blue-600",
color === "purple" && "border-purple-300 bg-purple-100 text-purple-600",
color === "brown" && "border-brown-300 bg-brown-100 text-brown-600",
- className,
)}
>
{withIcon && <Tag className="h-3 w-3 shrink-0" />}
- <span
- className={cn(
- withIcon && !primary && "hidden sm:inline-block",
- "min-w-0 truncate",
- )}
- >
- {primary ? name : truncateFn(name || "", !isDesktop ? 20 : 24)}
- </span>
+ <p {...(withIcon && { className: "hidden sm:inline-block" })}>
+ {truncate(name || "", !isDesktop ? 20 : 24)}
+ </p>
{!!plus && (
<span className="hidden sm:block">
<span className="pr-1.5 opacity-30 md:pl-1 md:pr-2.5">|</span>+{plus}