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.

popover and tooltip work

Steven Tey55ce95f5e6f6
diff --git a/apps/web/app/ui/modals/add-edit-link-modal/og-section.tsx b/apps/web/app/ui/modals/add-edit-link-modal/og-section.tsx
index a7cb7c794a..f3d9856932 100644
--- a/apps/web/app/ui/modals/add-edit-link-modal/og-section.tsx
+++ b/apps/web/app/ui/modals/add-edit-link-modal/og-section.tsx
@@ -14,7 +14,7 @@ import Switch from "#/ui/switch";
import { FADE_IN_ANIMATION_SETTINGS, HOME_DOMAIN } from "#/lib/constants";
import { InfoTooltip, SimpleTooltipContent } from "#/ui/tooltip";
import { Link2 } from "lucide-react";
-import Popover from "#/ui/popover";
+import { Popover } from "ui";
import Unsplash from "@/components/shared/icons/unsplash";
import UnsplashSearch from "./unsplash-search";
diff --git a/apps/web/app/ui/modals/link-qr-modal.tsx b/apps/web/app/ui/modals/link-qr-modal.tsx
index 29fb705d89..1c1e5895ab 100644
--- a/apps/web/app/ui/modals/link-qr-modal.tsx
+++ b/apps/web/app/ui/modals/link-qr-modal.tsx
@@ -21,7 +21,7 @@ import useProject from "#/lib/swr-app/use-project";
import { SimpleLinkProps } from "#/lib/types";
import { getApexDomain, linkConstructor } from "#/lib/utils";
import IconMenu from "@/components/shared/icon-menu";
-import Popover from "#/ui/popover";
+import { Popover } from "ui";
import { toast } from "sonner";
import { GOOGLE_FAVICON_URL } from "#/lib/constants";
import { useDebouncedCallback } from "use-debounce";
diff --git a/apps/web/app/ui/popover.tsx b/apps/web/app/ui/popover.tsx
deleted file mode 100644
index fed7632e8c..0000000000
--- a/apps/web/app/ui/popover.tsx
+++ /dev/null
@@ -1,61 +0,0 @@
-"use client";
-
-import { Dispatch, ReactNode, SetStateAction } from "react";
-import * as PopoverPrimitive from "@radix-ui/react-popover";
-import { Drawer } from "vaul";
-import useMediaQuery from "#/lib/hooks/use-media-query";
-
-export default function Popover({
- children,
- content,
- align = "center",
- openPopover,
- setOpenPopover,
- mobileOnly,
-}: {
- children: ReactNode;
- content: ReactNode | string;
- align?: "center" | "start" | "end";
- openPopover: boolean;
- setOpenPopover: Dispatch<SetStateAction<boolean>>;
- mobileOnly?: boolean;
-}) {
- const { isMobile } = useMediaQuery();
-
- if (mobileOnly || isMobile) {
- return (
- <Drawer.Root open={openPopover} onOpenChange={setOpenPopover}>
- <div className="sm:hidden">{children}</div>
- <Drawer.Overlay className="fixed inset-0 z-40 bg-gray-100 bg-opacity-10 backdrop-blur" />
- <Drawer.Portal>
- <Drawer.Content className="fixed bottom-0 left-0 right-0 z-50 mt-24 rounded-t-[10px] border-t border-gray-200 bg-white">
- <div className="sticky top-0 z-20 flex w-full items-center justify-center rounded-t-[10px] bg-inherit">
- <div className="my-3 h-1 w-12 rounded-full bg-gray-300" />
- </div>
- <div className="flex min-h-[150px] w-full items-center justify-center overflow-hidden bg-white pb-8 align-middle shadow-xl">
- {content}
- </div>
- </Drawer.Content>
- <Drawer.Overlay />
- </Drawer.Portal>
- </Drawer.Root>
- );
- }
-
- return (
- <PopoverPrimitive.Root open={openPopover} onOpenChange={setOpenPopover}>
- <PopoverPrimitive.Trigger className="hidden sm:inline-flex" asChild>
- {children}
- </PopoverPrimitive.Trigger>
- <PopoverPrimitive.Portal>
- <PopoverPrimitive.Content
- sideOffset={8}
- align={align}
- className="z-50 hidden animate-slide-up-fade items-center rounded-md border border-gray-200 bg-white drop-shadow-lg sm:block"
- >
- {content}
- </PopoverPrimitive.Content>
- </PopoverPrimitive.Portal>
- </PopoverPrimitive.Root>
- );
-}
diff --git a/apps/web/app/ui/stats/toggle.tsx b/apps/web/app/ui/stats/toggle.tsx
index 3afd7b5b72..20ca609ffe 100644
--- a/apps/web/app/ui/stats/toggle.tsx
+++ b/apps/web/app/ui/stats/toggle.tsx
@@ -5,7 +5,7 @@ import { ExpandingArrow } from "#/ui/icons";
import { INTERVALS } from "#/lib/stats";
import { cn, linkConstructor } from "#/lib/utils";
import IconMenu from "@/components/shared/icon-menu";
-import Popover from "#/ui/popover";
+import { Popover } from "ui";
import useSWR, { mutate } from "swr";
import { fetcher } from "#/lib/utils";
import { toast } from "sonner";
@@ -198,7 +198,7 @@ const SharePopover = () => {
<div className="p-4">
<p className="font-semibold text-gray-800">Share Link</p>
<div className="divide-x-200 mt-2 flex items-center justify-between divide-x overflow-hidden rounded-md border border-gray-200 bg-gray-100">
- <div className="overflow-scroll pl-2 scrollbar-hide">
+ <div className="scrollbar-hide overflow-scroll pl-2">
<p className="whitespace-nowrap text-gray-600">
https://{domain}/stats/{encodeURIComponent(key)}
</p>
diff --git a/apps/web/app/ui/tooltip.tsx b/apps/web/app/ui/tooltip.tsx
index 8d724ba9ef..1db52800fa 100644
--- a/apps/web/app/ui/tooltip.tsx
+++ b/apps/web/app/ui/tooltip.tsx
@@ -1,89 +1,14 @@
"use client";
-/***********************************/
-
-/* Tooltip Contents */
+import { Tooltip } from "ui";
+export { Tooltip as default } from "ui";
import Link from "next/link";
import { ReactNode, useState } from "react";
-import * as TooltipPrimitive from "@radix-ui/react-tooltip";
import Button from "./button";
import Script from "next/script";
-import { ExternalLink, Globe, GlobeIcon, HelpCircle } from "lucide-react";
+import { ExternalLink, HelpCircle } from "lucide-react";
import { DomainProps } from "#/lib/types";
import { CheckCircleFill, XCircleFill } from "@/components/shared/icons";
-import { Drawer } from "vaul";
-import useMediaQuery from "#/lib/hooks/use-media-query";
-
-export default function Tooltip({
- children,
- content,
- fullWidth,
-}: {
- children: ReactNode;
- content: ReactNode | string;
- fullWidth?: boolean;
-}) {
- const { isMobile } = useMediaQuery();
-
- if (isMobile) {
- return (
- <Drawer.Root>
- <Drawer.Trigger
- className={`${fullWidth ? "w-full" : "inline-flex"} md:hidden`}
- onClick={(e) => {
- e.stopPropagation();
- }}
- >
- {children}
- </Drawer.Trigger>
- <Drawer.Overlay className="fixed inset-0 z-40 bg-gray-100 bg-opacity-10 backdrop-blur" />
- <Drawer.Portal>
- <Drawer.Content className="fixed bottom-0 left-0 right-0 z-50 mt-24 rounded-t-[10px] border-t border-gray-200 bg-white">
- <div className="sticky top-0 z-20 flex w-full items-center justify-center rounded-t-[10px] bg-inherit">
- <div className="my-3 h-1 w-12 rounded-full bg-gray-300" />
- </div>
- <div className="flex min-h-[150px] w-full items-center justify-center overflow-hidden bg-white align-middle shadow-xl">
- {typeof content === "string" ? (
- <span className="block text-center text-sm text-gray-700">
- {content}
- </span>
- ) : (
- content
- )}
- </div>
- </Drawer.Content>
- <Drawer.Overlay />
- </Drawer.Portal>
- </Drawer.Root>
- );
- }
- return (
- <TooltipPrimitive.Provider delayDuration={100}>
- <TooltipPrimitive.Root>
- <TooltipPrimitive.Trigger className="hidden md:inline-flex" asChild>
- {children}
- </TooltipPrimitive.Trigger>
- {/*
- We don't use TooltipPrimitive.Portal here because for some reason it
- prevents you from selecting the contents of a tooltip when used inside a modal
- */}
- <TooltipPrimitive.Content
- sideOffset={8}
- side="top"
- className="z-[99] hidden animate-slide-up-fade items-center overflow-hidden rounded-md border border-gray-200 bg-white shadow-md md:block"
- >
- {typeof content === "string" ? (
- <div className="block max-w-xs px-4 py-2 text-center text-sm text-gray-700">
- {content}
- </div>
- ) : (
- content
- )}
- </TooltipPrimitive.Content>
- </TooltipPrimitive.Root>
- </TooltipPrimitive.Provider>
- );
-}
export function TooltipContent({
title,
diff --git a/apps/web/components/app/links/link-card.tsx b/apps/web/components/app/links/link-card.tsx
index 4db5700c4f..f20539dca4 100644
--- a/apps/web/components/app/links/link-card.tsx
+++ b/apps/web/components/app/links/link-card.tsx
@@ -10,7 +10,7 @@ import IconMenu from "@/components/shared/icon-menu";
import BlurImage from "#/ui/blur-image";
import CopyButton from "@/components/shared/copy-button";
import { Chart, Delete, ThreeDots } from "@/components/shared/icons";
-import Popover from "#/ui/popover";
+import { Popover } from "ui";
import Tooltip, { SimpleTooltipContent, TooltipContent } from "#/ui/tooltip";
import useProject from "#/lib/swr/use-project";
import { type Link as LinkProps } from "@prisma/client";
@@ -335,7 +335,7 @@ export default function LinkCard({
<p className="whitespace-nowrap text-sm text-gray-500">
{timeAgo(createdAt)}
</p>
- <p className="hidden xs:block">•</p>
+ <p className="xs:block hidden">•</p>
{rewrite && (
<Tooltip
content={
@@ -346,7 +346,7 @@ export default function LinkCard({
/>
}
>
- <EyeOff className="hidden h-4 w-4 text-gray-500 xs:block" />
+ <EyeOff className="xs:block hidden h-4 w-4 text-gray-500" />
</Tooltip>
)}
<a
@@ -356,7 +356,7 @@ export default function LinkCard({
href={url}
target="_blank"
rel="noopener noreferrer"
- className="hidden max-w-[140px] truncate text-sm font-medium text-gray-700 underline-offset-2 hover:underline xs:block sm:max-w-[300px] md:max-w-[360px] xl:max-w-[440px]"
+ className="xs:block hidden max-w-[140px] truncate text-sm font-medium text-gray-700 underline-offset-2 hover:underline sm:max-w-[300px] md:max-w-[360px] xl:max-w-[440px]"
>
{url}
</a>
diff --git a/apps/web/components/app/links/link-filters.tsx b/apps/web/components/app/links/link-filters.tsx
index d0e12d0ad7..11eb24cd92 100644
--- a/apps/web/components/app/links/link-filters.tsx
+++ b/apps/web/components/app/links/link-filters.tsx
@@ -25,7 +25,7 @@ import useTags from "#/lib/swr/use-tags";
import TagBadge, { COLORS_LIST } from "@/components/app/links/tag-badge";
import { TagProps } from "#/lib/types";
import { ThreeDots } from "@/components/shared/icons";
-import Popover from "#/ui/popover";
+import { Popover } from "ui";
import IconMenu from "@/components/shared/icon-menu";
import { mutate } from "swr";
import Number from "#/ui/number";
diff --git a/apps/web/components/app/links/link-sort.tsx b/apps/web/components/app/links/link-sort.tsx
index ad8c78fbe1..1aab1abfcb 100644
--- a/apps/web/components/app/links/link-sort.tsx
+++ b/apps/web/components/app/links/link-sort.tsx
@@ -3,7 +3,7 @@ import { useMemo, useState } from "react";
import IconMenu from "@/components/shared/icon-menu";
import { Sort, Tick } from "@/components/shared/icons";
import { ChevronDown, SortAsc, SortDesc } from "lucide-react";
-import Popover from "#/ui/popover";
+import { Popover } from "ui";
const sortOptions = [
{
diff --git a/apps/web/components/app/modals/link-qr-modal.tsx b/apps/web/components/app/modals/link-qr-modal.tsx
index d68c47ba13..5a38322da6 100644
--- a/apps/web/components/app/modals/link-qr-modal.tsx
+++ b/apps/web/components/app/modals/link-qr-modal.tsx
@@ -24,7 +24,7 @@ import useProject from "#/lib/swr/use-project";
import { SimpleLinkProps } from "#/lib/types";
import { getApexDomain, linkConstructor } from "#/lib/utils";
import IconMenu from "@/components/shared/icon-menu";
-import Popover from "#/ui/popover";
+import { Popover } from "ui";
import { toast } from "sonner";
import {
APP_HOSTNAMES,
diff --git a/apps/web/components/layout/app/nav-tabs.tsx b/apps/web/components/layout/app/nav-tabs.tsx
index 779be575eb..f72dbb0a47 100644
--- a/apps/web/components/layout/app/nav-tabs.tsx
+++ b/apps/web/components/layout/app/nav-tabs.tsx
@@ -58,7 +58,7 @@ export default function NavTabs() {
if (!error) {
return (
- <div className="-mb-0.5 flex h-12 items-center justify-start space-x-2 overflow-x-auto scrollbar-hide">
+ <div className="scrollbar-hide -mb-0.5 flex h-12 items-center justify-start space-x-2 overflow-x-auto">
{tabs.map(({ name, href }) => (
<Link
key={href}
diff --git a/apps/web/components/layout/app/project-select.tsx b/apps/web/components/layout/app/project-select.tsx
index d47e0ad5be..166f48026f 100644
--- a/apps/web/components/layout/app/project-select.tsx
+++ b/apps/web/components/layout/app/project-select.tsx
@@ -3,7 +3,7 @@ import { useCallback, useContext, useMemo, useState } from "react";
import { useSession } from "next-auth/react";
import { Tick } from "@/components/shared/icons";
import { ChevronsUpDown, PlusCircle } from "lucide-react";
-import Popover from "#/ui/popover";
+import { Popover } from "ui";
import { PlanProps, ProjectWithDomainProps } from "#/lib/types";
import useProjects from "#/lib/swr/use-projects";
import PlanBadge from "@/components/app/projects/plan-badge";
diff --git a/apps/web/components/layout/app/user-dropdown.tsx b/apps/web/components/layout/app/user-dropdown.tsx
index a1b7c838ab..289516da0d 100644
--- a/apps/web/components/layout/app/user-dropdown.tsx
+++ b/apps/web/components/layout/app/user-dropdown.tsx
@@ -1,7 +1,7 @@
-import { useContext, useEffect, useState } from "react";
+import { useEffect, useState } from "react";
import { signOut, useSession } from "next-auth/react";
import { Logout } from "@/components/shared/icons";
-import Popover from "#/ui/popover";
+import { Popover } from "ui";
import IconMenu from "../../shared/icon-menu";
import va from "@vercel/analytics";
import Link from "next/link";
@@ -10,7 +10,6 @@ import { Crisp } from "crisp-sdk-web";
import { LoadingCircle } from "#/ui/icons";
import Badge from "#/ui/badge";
import Cookies from "js-cookie";
-import { ModalContext } from "#/ui/modal-provider";
import { allChangelogPosts } from "contentlayer/generated";
import { HOME_DOMAIN } from "#/lib/constants";
import Avatar from "#/ui/avatar";
diff --git a/apps/web/components/stats/toggle.tsx b/apps/web/components/stats/toggle.tsx
index f97b761dff..33f2251044 100644
--- a/apps/web/components/stats/toggle.tsx
+++ b/apps/web/components/stats/toggle.tsx
@@ -7,7 +7,7 @@ import { INTERVALS } from "#/lib/stats";
import useScroll from "#/lib/hooks/use-scroll";
import { cn, linkConstructor } from "#/lib/utils";
import IconMenu from "@/components/shared/icon-menu";
-import Popover from "#/ui/popover";
+import { Popover } from "ui";
import useSWR, { mutate } from "swr";
import { fetcher } from "#/lib/utils";
import { toast } from "sonner";
@@ -223,7 +223,7 @@ const SharePopover = () => {
<div className="p-4">
<p className="font-semibold text-gray-800">Share Link</p>
<div className="divide-x-200 mt-2 flex items-center justify-between divide-x overflow-hidden rounded-md border border-gray-200 bg-gray-100">
- <div className="overflow-scroll pl-2 scrollbar-hide">
+ <div className="scrollbar-hide overflow-scroll pl-2">
<p className="whitespace-nowrap text-gray-600">
https://{domain}/stats/{encodeURIComponent(key)}
</p>
diff --git a/apps/web/package.json b/apps/web/package.json
index 46bd06ea85..5fc7820910 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -94,6 +94,7 @@
"tailwind-scrollbar-hide": "^1.1.7",
"tailwindcss-radix": "^2.8.0",
"topojson-client": "^3.1.0",
+ "ui": "workspace:*",
"unsplash-js": "^7.0.18",
"use-debounce": "^8.0.4",
"vaul": "^0.6.8"
diff --git a/apps/web/pages/app/[slug]/index.tsx b/apps/web/pages/app/[slug]/index.tsx
index c51cf9fbf5..0e0918e28a 100644
--- a/apps/web/pages/app/[slug]/index.tsx
+++ b/apps/web/pages/app/[slug]/index.tsx
@@ -5,7 +5,7 @@ import AppLayout from "components/layout/app";
import { useRouter } from "next/router";
import useProject from "#/lib/swr/use-project";
import { useState } from "react";
-import Popover from "#/ui/popover";
+import { Popover } from "ui";
import { ChevronDown, FilePlus2, Sheet } from "lucide-react";
import IconMenu from "@/components/shared/icon-menu";
import Tooltip from "#/ui/tooltip";
diff --git a/apps/web/pages/app/[slug]/settings/people.tsx b/apps/web/pages/app/[slug]/settings/people.tsx
index 9ff48ae9c8..a5fb2378bc 100644
--- a/apps/web/pages/app/[slug]/settings/people.tsx
+++ b/apps/web/pages/app/[slug]/settings/people.tsx
@@ -4,7 +4,7 @@ import { useState } from "react";
import BlurImage from "#/ui/blur-image";
import { UserProps } from "#/lib/types";
import { cn, timeAgo } from "#/lib/utils";
-import Popover from "#/ui/popover";
+import { Popover } from "ui";
import IconMenu from "@/components/shared/icon-menu";
import { UserMinus } from "lucide-react";
import { ThreeDots } from "@/components/shared/icons";
diff --git a/apps/web/pages/app/[slug]/settings/security.tsx b/apps/web/pages/app/[slug]/settings/security.tsx
index 8d711c4e59..702d192ef4 100644
--- a/apps/web/pages/app/[slug]/settings/security.tsx
+++ b/apps/web/pages/app/[slug]/settings/security.tsx
@@ -5,7 +5,7 @@ import SettingsLayout from "@/components/layout/app/settings-layout";
import { FolderSync, Lock, ShieldOff } from "lucide-react";
import { Dispatch, SetStateAction, useContext, useMemo, useState } from "react";
import { ThreeDots } from "@/components/shared/icons";
-import Popover from "#/ui/popover";
+import { Popover } from "ui";
import IconMenu from "@/components/shared/icon-menu";
import useSAML from "#/lib/swr/use-saml";
import useSCIM from "#/lib/swr/use-scim";
diff --git a/apps/web/pages/app/settings/tokens.tsx b/apps/web/pages/app/settings/tokens.tsx
index 5d843c0815..7b2cf0d91c 100644
--- a/apps/web/pages/app/settings/tokens.tsx
+++ b/apps/web/pages/app/settings/tokens.tsx
@@ -2,7 +2,7 @@ import { fetcher, timeAgo } from "#/lib/utils";
import { TokenAvatar } from "#/ui/avatar";
import Form from "#/ui/form";
import { LoadingSpinner } from "#/ui/icons";
-import Popover from "#/ui/popover";
+import { Popover } from "ui";
import { useDeleteTokenModal } from "@/components/app/modals/delete-token-modal";
import { useTokenCreatedModal } from "@/components/app/modals/token-created-modal";
import SettingsLayout from "@/components/layout/app/settings-layout";
diff --git a/packages/ui/src/button.tsx b/packages/ui/src/button.tsx
index 48b44efe50..112117ae50 100644
--- a/packages/ui/src/button.tsx
+++ b/packages/ui/src/button.tsx
@@ -13,7 +13,7 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
disabledTooltip?: string | ReactNode;
}
-export default function Button({
+export function Button({
text,
variant = "primary",
loading,
diff --git a/packages/ui/tsup.config.ts b/packages/ui/tsup.config.ts
index 7b2189abb9..f68cd4d7f7 100644
--- a/packages/ui/tsup.config.ts
+++ b/packages/ui/tsup.config.ts
@@ -9,5 +9,6 @@ export default defineConfig((options: Options) => ({
minify: true,
clean: true,
external: ["react"],
+ injectStyle: true,
...options,
}));
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 032692b239..ad7237db38 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -280,6 +280,9 @@ importers:
topojson-client:
specifier: ^3.1.0
version: 3.1.0
+ ui:
+ specifier: workspace:*
+ version: link:../../packages/ui
unsplash-js:
specifier: ^7.0.18
version: 7.0.18