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.

badgetooltip

Steven Teyde902b4b0bd2
diff --git a/apps/web/ui/analytics/toggle.tsx b/apps/web/ui/analytics/toggle.tsx
index 43b505fa58..159895d5e8 100644
--- a/apps/web/ui/analytics/toggle.tsx
+++ b/apps/web/ui/analytics/toggle.tsx
@@ -3,7 +3,7 @@ import useDomains from "@/lib/swr/use-domains";
import useProject from "@/lib/swr/use-project";
import { DomainProps } from "@/lib/types";
import {
- Badge,
+ BadgeTooltip,
BlurImage,
Copy,
ExpandingArrow,
@@ -87,19 +87,11 @@ export default function Toggle() {
{primaryDomain}
</h2>
{allDomains && allDomains.length > 1 && (
- <Tooltip
+ <BadgeTooltip
content={<DomainsFilterTooltip domains={allDomains} />}
- side="bottom"
>
- <div className="flex cursor-pointer items-center">
- <Badge
- variant="gray"
- className="border-gray-300 transition-all hover:bg-gray-200"
- >
- +{allDomains.length - 1}
- </Badge>
- </div>
- </Tooltip>
+ +{allDomains.length - 1}
+ </BadgeTooltip>
)}
</div>
)}
diff --git a/apps/web/ui/links/link-card.tsx b/apps/web/ui/links/link-card.tsx
index d2ed78fdbb..34f6122117 100644
--- a/apps/web/ui/links/link-card.tsx
+++ b/apps/web/ui/links/link-card.tsx
@@ -9,6 +9,7 @@ import { useLinkQRModal } from "@/ui/modals/link-qr-modal";
import { Chart, Delete, ThreeDots } from "@/ui/shared/icons";
import {
Avatar,
+ BadgeTooltip,
BlurImage,
Button,
CopyButton,
@@ -19,7 +20,6 @@ import {
Tooltip,
TooltipContent,
useIntersectionObserver,
- useMediaQuery,
useRouterStuff,
} from "@dub/ui";
import { LinkifyTooltipContent } from "@dub/ui/src/tooltip";
@@ -75,16 +75,14 @@ export default function LinkCard({
user,
} = props;
- const { isMobile } = useMediaQuery();
-
const [primaryTags, additionalTags] = useMemo(() => {
- const primaryTagsCount = isMobile ? 1 : 2;
+ const primaryTagsCount = 1;
return [
tags.filter((_, idx) => idx < primaryTagsCount),
tags.filter((_, idx) => idx >= primaryTagsCount),
];
- }, [tags, isMobile]);
+ }, [tags]);
const apexDomain = getApexDomain(url);
@@ -339,7 +337,7 @@ export default function LinkCard({
<TagButton {...tag} />
))}
{additionalTags.length > 0 && (
- <Tooltip
+ <BadgeTooltip
content={
<div className="flex flex-wrap gap-1.5 p-3">
{additionalTags.map((tag) => (
@@ -347,11 +345,10 @@ export default function LinkCard({
))}
</div>
}
+ side="top"
>
- <div className="flex select-none items-center space-x-1.5 whitespace-nowrap rounded-md bg-gray-100 p-1.5 text-sm font-medium text-gray-500 hover:text-gray-600 sm:rounded-md sm:px-2 sm:py-0.5">
- +{additionalTags.length}
- </div>
- </Tooltip>
+ +{additionalTags.length}
+ </BadgeTooltip>
)}
</div>
<div className="flex max-w-fit items-center space-x-1">
diff --git a/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx b/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx
index ff48a5c79b..5018a99afc 100644
--- a/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx
+++ b/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx
@@ -98,7 +98,7 @@ export default function TagsSection({
setOpenCommandList(true);
}
}}
- className="block grow rounded-md border-none px-0 py-0 text-gray-900 placeholder-gray-400 focus:outline-none focus:ring-0 sm:text-sm"
+ className="block grow rounded-md border-none px-0 py-1 text-gray-900 placeholder-gray-400 focus:outline-none focus:ring-0 sm:text-sm"
/>
);
};
@@ -157,7 +157,7 @@ export default function TagsSection({
<button
type="button"
onClick={() => createTag(inputValue)}
- className="aria-selected:bg-gray-100 aria-selected:text-gray-900 flex w-full cursor-pointer items-center rounded-md bg-gray-100 px-4 py-2 text-sm text-gray-900 hover:text-gray-900"
+ className="flex w-full cursor-pointer items-center rounded-md bg-gray-100 px-4 py-2 text-sm text-gray-900 hover:text-gray-900 aria-selected:bg-gray-100 aria-selected:text-gray-900"
>
Create tag{" "}
<span className="ml-1.5 rounded-md bg-gray-200 px-2 py-0.5 text-gray-800">
@@ -182,7 +182,7 @@ export default function TagsSection({
});
setInputValue("");
}}
- className="aria-selected:bg-gray-100 aria-selected:text-gray-900 group flex cursor-pointer items-center justify-between rounded-md px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 hover:text-gray-900 active:bg-gray-200"
+ className="group flex cursor-pointer items-center justify-between rounded-md px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 hover:text-gray-900 active:bg-gray-200 aria-selected:bg-gray-100 aria-selected:text-gray-900"
>
<TagBadge {...tag} />
{tags.map(({ id }) => id).includes(tag.id) && (
diff --git a/packages/ui/src/tooltip.tsx b/packages/ui/src/tooltip.tsx
index b3fe425e68..efe30c6cb6 100644
--- a/packages/ui/src/tooltip.tsx
+++ b/packages/ui/src/tooltip.tsx
@@ -6,6 +6,7 @@ import Linkify from "linkify-react";
import { HelpCircle } from "lucide-react";
import Link from "next/link";
import { ReactNode, useState } from "react";
+import { Badge } from "./badge";
export function TooltipProvider({ children }: { children: ReactNode }) {
return (
@@ -15,15 +16,13 @@ export function TooltipProvider({ children }: { children: ReactNode }) {
);
}
-export function Tooltip({
- children,
- content,
- side = "top",
-}: {
+interface TooltipProps {
children: ReactNode;
content: ReactNode | string;
side?: "top" | "bottom" | "left" | "right";
-}) {
+}
+
+export function Tooltip({ children, content, side = "top" }: TooltipProps) {
const [open, setOpen] = useState(false);
return (
@@ -180,3 +179,22 @@ export function NumberTooltip({
</Tooltip>
);
}
+
+export function BadgeTooltip({
+ children,
+ content,
+ side = "bottom",
+}: TooltipProps) {
+ return (
+ <Tooltip content={content} side={side}>
+ <div className="flex cursor-pointer items-center">
+ <Badge
+ variant="gray"
+ className="border-gray-300 transition-all hover:bg-gray-200"
+ >
+ {children}
+ </Badge>
+ </div>
+ </Tooltip>
+ );
+}