The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add "View Events" button
Tim Wilson4a2f2cf339c9
diff --git a/apps/web/ui/analytics/main.tsx b/apps/web/ui/analytics/main.tsxindex 4e8561a6bc..2ec04aee52 100644--- a/apps/web/ui/analytics/main.tsx+++ b/apps/web/ui/analytics/main.tsx@@ -1,6 +1,12 @@import { EventType } from "@/lib/analytics/types";import useWorkspace from "@/lib/swr/use-workspace";-import { CountingNumbers, NumberTooltip, useRouterStuff } from "@dub/ui";+import {+ Button,+ CountingNumbers,+ NumberTooltip,+ useRouterStuff,+} from "@dub/ui";+import { SquareLayoutGrid6 } from "@dub/ui/src/icons";import { cn } from "@dub/utils";import { ChevronRight, Lock } from "lucide-react";import Link from "next/link";@@ -15,10 +21,10 @@ type Tab = {};export default function Main() {- const { flags } = useWorkspace();+ const { flags, slug } = useWorkspace();const { totalEvents, requiresUpgrade, demoPage, selectedTab } =useContext(AnalyticsContext);- const { queryParams } = useRouterStuff();+ const { router, queryParams, getQueryString } = useRouterStuff();const tabs = useMemo(() =>@@ -50,91 +56,102 @@ export default function Main() {return (<div className="w-full overflow-hidden border border-gray-200 bg-white sm:rounded-xl">- <div className="scrollbar-hide mb-5 flex w-full divide-x overflow-y-hidden overflow-x-scroll border-b border-gray-200">- {tabs.map(({ id, label, colorClassName }, idx) => {- const total = {- clicks: totalEvents?.clicks,- leads: totalEvents?.leads,- sales: totalEvents ? totalEvents.amount / 100 : undefined,- }[id];+ <div className="flex justify-between overflow-x-scroll border-b border-gray-200">+ <div className="scrollbar-hide flex shrink-0 grow divide-x overflow-y-hidden">+ {tabs.map(({ id, label, colorClassName }, idx) => {+ const total = {+ clicks: totalEvents?.clicks,+ leads: totalEvents?.leads,+ sales: totalEvents ? totalEvents.amount / 100 : undefined,+ }[id];- return (- <div key={id} className="relative z-0">- {idx > 0 && (- <div className="absolute left-0 top-1/2 z-10 -translate-x-1/2 -translate-y-1/2 rounded-full border border-gray-200 bg-white p-1.5">- <ChevronRight- className="h-3 w-3 text-gray-400"- strokeWidth={2.5}- />- </div>- )}- <Link- className={cn(- "border-box relative block h-full min-w-[110px] flex-none px-4 py-3 sm:min-w-[240px] sm:px-8 sm:py-6",- "transition-colors hover:bg-gray-50 focus:outline-none active:bg-gray-100",- "ring-inset ring-gray-500 focus-visible:ring-1 sm:first:rounded-tl-xl",+ return (+ <div key={id} className="relative z-0">+ {idx > 0 && (+ <div className="absolute left-0 top-1/2 z-10 -translate-x-1/2 -translate-y-1/2 rounded-full border border-gray-200 bg-white p-1.5">+ <ChevronRight+ className="h-3 w-3 text-gray-400"+ strokeWidth={2.5}+ />+ </div>)}- href={- (tab.id === id- ? queryParams({- del: "tab",- getNewPath: true,- })- : queryParams({- set: {- tab: id,- },- getNewPath: true,- })) as string- }- aria-current- >- {/* Active tab indicator */}- <div+ <LinkclassName={cn(- "absolute bottom-0 left-0 h-0.5 w-full bg-black transition-transform duration-100",- tab.id !== id && "translate-y-[3px]", // Translate an extra pixel to avoid sub-pixel issues+ "border-box relative block h-full min-w-[110px] flex-none px-4 py-3 sm:min-w-[240px] sm:px-8 sm:py-6",+ "transition-colors hover:bg-gray-50 focus:outline-none active:bg-gray-100",+ "ring-inset ring-gray-500 focus-visible:ring-1 sm:first:rounded-tl-xl",)}- />-- <div className="flex items-center gap-2.5 text-sm text-gray-600">+ href={+ (tab.id === id+ ? queryParams({+ del: "tab",+ getNewPath: true,+ })+ : queryParams({+ set: {+ tab: id,+ },+ getNewPath: true,+ })) as string+ }+ aria-current+ >+ {/* Active tab indicator */}<divclassName={cn(- "h-2 w-2 rounded-sm bg-current shadow-[inset_0_0_0_1px_#00000019]",- colorClassName,+ "absolute bottom-0 left-0 h-0.5 w-full bg-black transition-transform duration-100",+ tab.id !== id && "translate-y-[3px]", // Translate an extra pixel to avoid sub-pixel issues)}/>- <span>{label}</span>- </div>- <div className="mt-1 flex">- {total || total === 0 ? (- <NumberTooltip- value={id === "sales" ? totalEvents?.sales : total}- unit={label.toLowerCase()}- >- <CountingNumbers- as="h1"- className="text-2xl font-medium sm:text-3xl"- prefix={id === "sales" && "$"}- {...(id === "sales" && { fullNumber: true })}++ <div className="flex items-center gap-2.5 text-sm text-gray-600">+ <div+ className={cn(+ "h-2 w-2 rounded-sm bg-current shadow-[inset_0_0_0_1px_#00000019]",+ colorClassName,+ )}+ />+ <span>{label}</span>+ </div>+ <div className="mt-1 flex">+ {total || total === 0 ? (+ <NumberTooltip+ value={id === "sales" ? totalEvents?.sales : total}+ unit={label.toLowerCase()}>- {total}- </CountingNumbers>- </NumberTooltip>- ) : requiresUpgrade ? (- <div className="block rounded-full bg-gray-100 p-2.5">- <Lock className="h-4 w-4 text-gray-500" />- </div>- ) : (- <div className="h-8 w-12 animate-pulse rounded-md bg-gray-200 sm:h-9" />- )}- </div>- </Link>- </div>- );- })}+ <CountingNumbers+ as="h1"+ className="text-2xl font-medium sm:text-3xl"+ prefix={id === "sales" && "$"}+ {...(id === "sales" && { fullNumber: true })}+ >+ {total}+ </CountingNumbers>+ </NumberTooltip>+ ) : requiresUpgrade ? (+ <div className="block rounded-full bg-gray-100 p-2.5">+ <Lock className="h-4 w-4 text-gray-500" />+ </div>+ ) : (+ <div className="h-8 w-12 animate-pulse rounded-md bg-gray-200 sm:h-9" />+ )}+ </div>+ </Link>+ </div>+ );+ })}+ </div>+ <div className="shrink-0 pr-2 pt-2 sm:pr-6 sm:pt-6">+ <Button+ variant="secondary"+ className="h-9 border-transparent px-2 hover:border-gray-200"+ icon={<SquareLayoutGrid6 className="h-4 w-4 text-gray-600" />}+ text="View Events"+ onClick={() => router.push(`/${slug}/events${getQueryString()}`)}+ />+ </div></div>- <div className="p-5 sm:p-10">+ <div className="mt-5 p-5 sm:p-10"><AnalyticsAreaChart resource={tab.id} /></div></div>diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.tsindex 61bc78bc4c..0d0a6201e5 100644--- a/packages/ui/src/icons/nucleo/index.ts+++ b/packages/ui/src/icons/nucleo/index.ts@@ -56,6 +56,7 @@ export * from "./refresh2";export * from "./robot";export * from "./shield-check";export * from "./sliders";+export * from "./square-layout-grid6";export * from "./stars2";export * from "./table-rows2";export * from "./tablet";diff --git a/packages/ui/src/icons/nucleo/square-layout-grid6.tsx b/packages/ui/src/icons/nucleo/square-layout-grid6.tsxnew file mode 100644index 0000000000..671471348d--- /dev/null+++ b/packages/ui/src/icons/nucleo/square-layout-grid6.tsx@@ -0,0 +1,73 @@+import { SVGProps } from "react";++export function SquareLayoutGrid6(props: SVGProps<SVGSVGElement>) {+ return (+ <svg+ height="18"+ width="18"+ viewBox="0 0 18 18"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ <g fill="currentColor">+ <line+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ x1="15.25"+ x2="2.75"+ y1="6.75"+ y2="6.75"+ />+ <line+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ x1="15.25"+ x2="2.75"+ y1="11.25"+ y2="11.25"+ />+ <line+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ x1="11.25"+ x2="11.25"+ y1="15.25"+ y2="2.75"+ />+ <line+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ x1="6.75"+ x2="6.75"+ y1="15.25"+ y2="2.75"+ />+ <rect+ height="12.5"+ width="12.5"+ fill="none"+ rx="2"+ ry="2"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ x="2.75"+ y="2.75"+ />+ </g>+ </svg>+ );+}