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.

Misc. fixes

Tim Wilsoncd5ea86315b3
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/page-client.tsx
index b257c978fa..664860106e 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/page-client.tsx
@@ -1,8 +1,8 @@
"use client";
import useWorkspace from "@/lib/swr/use-workspace";
+import LinkDisplay from "@/ui/links/link-display";
import { InputSearchBox } from "@/ui/links/link-filters";
-import LinkSort from "@/ui/links/link-sort";
import LinksContainer from "@/ui/links/links-container";
import { useLinkFilters } from "@/ui/links/use-link-filters";
import { useAddEditLinkModal } from "@/ui/modals/add-edit-link-modal";
@@ -26,7 +26,6 @@ import {
Dispatch,
ReactNode,
SetStateAction,
- Suspense,
useEffect,
useState,
} from "react";
@@ -42,24 +41,27 @@ export default function WorkspaceLinksClient() {
<AddEditLinkModal />
<div className="mt-10 flex items-center pt-3">
<MaxWidthWrapper className="flex flex-col gap-y-3">
- <div className="flex items-center justify-between">
- <h1 className="text-2xl font-semibold tracking-tight text-black">
+ <div className="flex flex-wrap items-center justify-between gap-2 md:flex-nowrap">
+ <h1 className="order-1 text-2xl font-semibold tracking-tight text-black">
Links
</h1>
- <div className="flex space-x-2">
- <div className="w-72 max-w-full">
+ <div className="order-4 flex grow flex-wrap justify-end gap-2 md:order-2">
+ <div className="w-full md:w-72">
<InputSearchBox />
</div>
- <Filter.Select
- filters={filters}
- onSelect={onSelect}
- onRemove={onRemove}
- />
- <div className="grow-0">
- <Suspense>
- <LinkSort />
- </Suspense>
+ <div className="grow basis-0 md:grow-0">
+ <Filter.Select
+ filters={filters}
+ onSelect={onSelect}
+ onRemove={onRemove}
+ className="w-full"
+ />
+ </div>
+ <div className="grow basis-0 md:grow-0">
+ <LinkDisplay />
</div>
+ </div>
+ <div className="order-3 flex gap-x-2">
<div className="grow-0">
<AddEditLinkButton />
</div>
diff --git a/apps/web/ui/links/link-controls.tsx b/apps/web/ui/links/link-controls.tsx
index 101c485d7d..5cee2edfae 100644
--- a/apps/web/ui/links/link-controls.tsx
+++ b/apps/web/ui/links/link-controls.tsx
@@ -79,8 +79,8 @@ export function LinkControls({ link }: { link: ResponseLink }) {
<div
className={cn(
"flex items-center justify-end divide-x divide-gray-200 overflow-hidden rounded-md border border-gray-200",
- "sm:divide-transparent sm:border-transparent sm:group-hover/row:divide-gray-200 sm:group-hover/row:border-gray-200", // Only show divider on mobile or when hovered
- "w-[43px] transition-[width] duration-300 sm:group-hover/row:w-[124px]",
+ "divide-transparent border-transparent sm:group-hover/row:divide-gray-200 sm:group-hover/row:border-gray-200", // Only show divider on mobile or when hovered
+ "w-[30px] transition-[width] duration-300 sm:w-[43px] sm:group-hover/row:w-[124px]",
)}
>
{isVisible && (
diff --git a/apps/web/ui/links/link-details-column.tsx b/apps/web/ui/links/link-details-column.tsx
index cd0251e3b9..4cff4f6d6f 100644
--- a/apps/web/ui/links/link-details-column.tsx
+++ b/apps/web/ui/links/link-details-column.tsx
@@ -1,8 +1,8 @@
import { CompositeAnalyticsResponseOptions } from "@/lib/analytics/types";
import useWorkspace from "@/lib/swr/use-workspace";
import { Crosshairs, Tooltip, useIntersectionObserver } from "@dub/ui";
-import { CursorRays, InvoiceDollar } from "@dub/ui/src/icons";
-import { fetcher, nFormatter } from "@dub/utils";
+import { CursorRays, InvoiceDollar, LinesY } from "@dub/ui/src/icons";
+import { cn, fetcher, nFormatter } from "@dub/utils";
import Link from "next/link";
import { useSearchParams } from "next/navigation";
import { useMemo, useRef } from "react";
@@ -41,7 +41,7 @@ export function LinkDetailsColumn({ link }: { link: ResponseLink }) {
);
return (
- <div ref={ref} className="flex items-center justify-end gap-5">
+ <div ref={ref} className="flex items-center justify-end gap-2 sm:gap-5">
{primaryTag && (
<Tooltip
content={
@@ -60,22 +60,35 @@ export function LinkDetailsColumn({ link }: { link: ResponseLink }) {
)}
<Link
href={`/${slug}/analytics?domain=${domain}&key=${key}`}
- className="flex items-center gap-3 rounded-md bg-gray-100 px-2 py-0.5 text-sm text-gray-950 transition-colors hover:bg-gray-200"
+ className="rounded-md bg-gray-100 px-2 py-0.5 text-sm text-gray-950 transition-colors hover:bg-gray-200"
>
- {[
- { id: "clicks", icon: CursorRays, value: totalEvents?.clicks },
- ...(trackConversion
- ? [
- { id: "sales", icon: Crosshairs, value: totalEvents?.sales },
- { id: "leads", icon: InvoiceDollar, value: totalEvents?.leads },
- ]
- : []),
- ].map(({ id, icon: Icon, value }) => (
- <div key={id} className="flex items-center gap-1">
- <Icon className="h-4 w-4 text-gray-600" />
- {nFormatter(totalEvents?.clicks)}
- </div>
- ))}
+ <LinesY className="my-0.5 block h-4 w-4 text-gray-600 sm:hidden" />
+ <div className="hidden items-center gap-3 sm:flex">
+ {[
+ { id: "clicks", icon: CursorRays, value: totalEvents?.clicks },
+ ...(trackConversion
+ ? [
+ {
+ id: "sales",
+ icon: Crosshairs,
+ value: totalEvents?.sales,
+ className: "hidden sm:flex",
+ },
+ {
+ id: "leads",
+ icon: InvoiceDollar,
+ value: totalEvents?.leads,
+ className: "hidden sm:flex",
+ },
+ ]
+ : []),
+ ].map(({ id, icon: Icon, value, className }) => (
+ <div key={id} className={cn("flex items-center gap-1", className)}>
+ <Icon className="h-4 w-4 shrink-0 text-gray-600" />
+ {nFormatter(value)}
+ </div>
+ ))}
+ </div>
</Link>
<LinkControls link={link} />
</div>
diff --git a/apps/web/ui/links/link-display.tsx b/apps/web/ui/links/link-display.tsx
new file mode 100644
index 0000000000..af33fc0d08
--- /dev/null
+++ b/apps/web/ui/links/link-display.tsx
@@ -0,0 +1,37 @@
+import { Button, Popover, useRouterStuff } from "@dub/ui";
+import { Sliders } from "@dub/ui/src/icons";
+import { cn } from "@dub/utils";
+import { ChevronDown } from "lucide-react";
+import { useSearchParams } from "next/navigation";
+import { useState } from "react";
+
+export default function LinkDisplay() {
+ const [openPopover, setOpenPopover] = useState(false);
+ const searchParams = useSearchParams();
+ const sort = searchParams?.get("sort");
+ const { queryParams } = useRouterStuff();
+
+ return (
+ <Popover
+ content={<div className="w-full p-2 md:w-48">options</div>}
+ openPopover={openPopover}
+ setOpenPopover={setOpenPopover}
+ >
+ <Button
+ variant="secondary"
+ className="[&>div]:w-full"
+ text={
+ <div className="flex w-full items-center gap-2">
+ <Sliders className="h-4 w-4" />
+ <span className="grow text-left">Display</span>
+ <ChevronDown
+ className={cn("h-4 w-4 text-gray-400 transition-transform", {
+ "rotate-180": openPopover,
+ })}
+ />
+ </div>
+ }
+ />
+ </Popover>
+ );
+}
diff --git a/apps/web/ui/links/link-filters.tsx b/apps/web/ui/links/link-filters.tsx
index 7abd6dc8c8..a7dcadb1de 100644
--- a/apps/web/ui/links/link-filters.tsx
+++ b/apps/web/ui/links/link-filters.tsx
@@ -104,12 +104,7 @@ const ClearButton = () => {
export const InputSearchBox = () => {
const { isValidating } = useLinks();
- return (
- <SearchBoxPersisted
- loading={isValidating}
- inputClassName="text-base sm:text-sm h-10"
- />
- );
+ return <SearchBoxPersisted loading={isValidating} inputClassName="h-10" />;
};
const DomainsFilter = () => {
diff --git a/apps/web/ui/links/link-title-column.tsx b/apps/web/ui/links/link-title-column.tsx
index 24593f111e..9a1a101c68 100644
--- a/apps/web/ui/links/link-title-column.tsx
+++ b/apps/web/ui/links/link-title-column.tsx
@@ -42,7 +42,7 @@ export function LinkTitleColumn({ link }: { link: ResponseLink }) {
>
{isVisible && (
<>
- <div className="relative flex shrink-0 items-center justify-center">
+ <div className="relative hidden shrink-0 items-center justify-center sm:flex">
{/* Link logo background circle */}
<div className="absolute inset-0 shrink-0 rounded-full border border-gray-200 opacity-0 transition-opacity group-data-[variant=loose-list]/table:sm:opacity-100">
<div className="h-full w-full rounded-full border border-white bg-gradient-to-t from-gray-100" />
@@ -56,7 +56,7 @@ export function LinkTitleColumn({ link }: { link: ResponseLink }) {
</div>
<div className="h-[24px] min-w-0 overflow-hidden transition-[height] group-data-[variant=loose-list]/table:h-[44px]">
<div className="flex items-center gap-2">
- <div className="text-gray-950">
+ <div className="min-w-0 text-gray-950">
<UnverifiedTooltip link={link}>
<span
className="block truncate font-medium"
@@ -114,9 +114,9 @@ function Details({ link, compact }: { link: ResponseLink; compact?: boolean }) {
return (
<div
className={cn(
- "flex min-w-0 items-center gap-1.5 text-xs transition-opacity md:gap-3",
+ "flex min-w-0 items-center gap-1.5 text-xs transition-[opacity,width] delay-[0s,150ms] duration-[150ms,0s] md:gap-3",
compact
- ? "opacity-0 group-data-[variant=compact-list]/table:opacity-100"
+ ? "w-0 opacity-0 group-data-[variant=compact-list]/table:w-auto group-data-[variant=compact-list]/table:opacity-100"
: "opacity-0 group-data-[variant=loose-list]/table:opacity-100",
)}
>
diff --git a/apps/web/ui/links/links-container.tsx b/apps/web/ui/links/links-container.tsx
index 0ed3d86645..1955ef0969 100644
--- a/apps/web/ui/links/links-container.tsx
+++ b/apps/web/ui/links/links-container.tsx
@@ -3,7 +3,13 @@
import useLinks from "@/lib/swr/use-links";
import useLinksCount from "@/lib/swr/use-links-count";
import { LinkWithTagsProps, UserProps } from "@/lib/types";
-import { MaxWidthWrapper, Table, useRouterStuff, useTable } from "@dub/ui";
+import {
+ MaxWidthWrapper,
+ Table,
+ useMediaQuery,
+ useRouterStuff,
+ useTable,
+} from "@dub/ui";
import { PAGINATION_LIMIT } from "@dub/utils";
import { ColumnDef } from "@tanstack/react-table";
import { useSearchParams } from "next/navigation";
@@ -61,6 +67,8 @@ function LinksList({
const searchParams = useSearchParams();
const currentPage = parseInt(searchParams?.get("page") || "1") || 1;
+ const { isMobile } = useMediaQuery();
+
const columns: ColumnDef<ResponseLink, any>[] = useMemo(
() => [
{
@@ -70,6 +78,7 @@ function LinksList({
<LinkTitleColumn link={getValue() as ResponseLink} />
),
enableHiding: false,
+ size: 10000,
},
{
id: "details",
@@ -77,9 +86,10 @@ function LinksList({
cell: ({ getValue }) => (
<LinkDetailsColumn link={getValue() as ResponseLink} />
),
+ size: isMobile ? 80 : 400,
},
],
- [],
+ [isMobile],
);
const [pagination, setPagination] = useState({
diff --git a/apps/web/ui/links/tag-badge.tsx b/apps/web/ui/links/tag-badge.tsx
index 0a7014151c..5a3ee69e82 100644
--- a/apps/web/ui/links/tag-badge.tsx
+++ b/apps/web/ui/links/tag-badge.tsx
@@ -32,7 +32,7 @@ export default function TagBadge({
{truncate(name || "", 24)}
</p>
{plus && (
- <span>
+ <span className="hidden sm:block">
<span className="pl-1 pr-2.5 opacity-30">|</span>+{plus}
</span>
)}
diff --git a/apps/web/ui/links/use-link-filters.tsx b/apps/web/ui/links/use-link-filters.tsx
index 5c9518dd9b..68ab7a3547 100644
--- a/apps/web/ui/links/use-link-filters.tsx
+++ b/apps/web/ui/links/use-link-filters.tsx
@@ -109,7 +109,7 @@ export function useLinkFilters() {
...(tagId ? [{ key: "tagId", value: tagId }] : []),
...(userId ? [{ key: "userId", value: userId }] : []),
...(showArchived
- ? [{ key: "root", value: showArchived === "true" }]
+ ? [{ key: "showArchived", value: showArchived === "true" }]
: []),
];
}, [searchParamsObj]);
diff --git a/packages/ui/src/button.tsx b/packages/ui/src/button.tsx
index e0d97b7f03..2ee9f36e4e 100644
--- a/packages/ui/src/button.tsx
+++ b/packages/ui/src/button.tsx
@@ -66,7 +66,7 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
>
{icon}
{text && (
- <p className={cn(shortcut && "flex-1 text-left")}>{text}</p>
+ <div className={cn(shortcut && "flex-1 text-left")}>{text}</div>
)}
{shortcut && (
<kbd
@@ -100,7 +100,9 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
{...props}
>
{loading ? <LoadingSpinner /> : icon ? icon : null}
- {text && <p className={cn(shortcut && "flex-1 text-left")}>{text}</p>}
+ {text && (
+ <div className={cn(shortcut && "flex-1 text-left")}>{text}</div>
+ )}
{shortcut && (
<kbd
className={cn(
diff --git a/packages/ui/src/table/table.tsx b/packages/ui/src/table/table.tsx
index 4e8c21f53d..e0415c6d78 100644
--- a/packages/ui/src/table/table.tsx
+++ b/packages/ui/src/table/table.tsx
@@ -71,15 +71,27 @@ const tableWrapperVariants = cva("relative sm:rounded-xl", {
});
const tableCellVariants = cva(
- "px-4 py-2.5 text-left text-sm leading-6 whitespace-nowrap border-gray-200 transition-[background-color]",
+ "py-2.5 text-left text-sm leading-6 whitespace-nowrap border-gray-200 transition-[background-color]",
{
variants: {
variant: {
default: "border-r border-b", // Right and left borders, removed from outer columns above
"compact-list": "border-b", // Bottom border, with other sides added above
- "loose-list": "border-y bg-white", // Top and bottom borders, with other sides added above
+ "loose-list": [
+ "border-y bg-white px-2", // Top and bottom borders, with other sides added above
+
+ // Outer cells have extra padding on the outside
+ "[&:first-child]:pl-4",
+ "[&:last-child]:pr-4",
+ ],
},
},
+ compoundVariants: [
+ {
+ variant: ["default", "compact-list"],
+ className: "px-4",
+ },
+ ],
},
);
@@ -100,7 +112,7 @@ const tablePaginationVariants = cva(
variant: {
...variantDefaults,
"loose-list":
- "border rounded-xl [filter:drop-shadow(0_5px_8px_#222A351d)] bottom-4 w-[768px] max-w-full",
+ "border rounded-xl [filter:drop-shadow(0_5px_8px_#222A351d)] bottom-4 max-w-[768px] w-full",
},
},
compoundVariants: [