The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
improve analytics tabs
Steven Teya64a384e9011
diff --git a/apps/web/ui/analytics/main.tsx b/apps/web/ui/analytics/main.tsxindex 3370b74eca..59eb6cb83a 100644--- a/apps/web/ui/analytics/main.tsx+++ b/apps/web/ui/analytics/main.tsx@@ -50,98 +50,94 @@ export default function Main() {return (<div className="w-full overflow-hidden border border-gray-200 bg-white sm:rounded-xl">- <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">- <NumberFlowGroup>- {tabs.map(({ id, label, colorClassName }, idx) => {- 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>+ <div className="scrollbar-hide grid w-full grid-cols-3 divide-x overflow-y-hidden border-b border-gray-200">+ <NumberFlowGroup>+ {tabs.map(({ id, label, colorClassName }, idx) => {+ 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",)}- <Link+ href={+ (tab.id === id+ ? queryParams({+ del: "event",+ getNewPath: true,+ })+ : queryParams({+ set: {+ event: id,+ },+ getNewPath: true,+ })) as string+ }+ aria-current+ >+ {/* Active tab indicator */}+ <divclassName={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",+ "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)}- href={- (tab.id === id- ? queryParams({- del: "event",- getNewPath: true,- })- : queryParams({- set: {- event: id,- },- getNewPath: true,- })) as string- }- aria-current- >- {/* Active tab indicator */}+ />++ <div className="flex items-center gap-2.5 text-sm text-gray-600"><divclassName={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+ "h-2 w-2 rounded-sm bg-current shadow-[inset_0_0_0_1px_#00000019]",+ colorClassName,)}/>-- <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 items-center gap-2">- {totalEvents?.[id] || totalEvents?.[id] === 0 ? (- <>+ <span>{label}</span>+ </div>+ <div className="mt-1 flex items-center gap-2">+ {totalEvents?.[id] || totalEvents?.[id] === 0 ? (+ <>+ <NumberFlow+ value={totalEvents[id]}+ className="text-2xl font-medium sm:text-3xl"+ format={{+ notation:+ totalEvents[id] > 999999 ? "compact" : "standard",+ }}+ />+ {id === "sales" && (<NumberFlow- value={totalEvents[id]}- className="text-2xl font-medium sm:text-3xl"+ className="text-lg font-medium text-gray-500 sm:text-xl"+ value={totalEvents.saleAmount / 100}format={{- notation:- totalEvents[id] > 999999- ? "compact"- : "standard",+ style: "currency",+ currency: "USD",+ // @ts-ignore – this is a valid option but TS is outdated+ trailingZeroDisplay: "stripIfInteger",}}/>- {id === "sales" && (- <NumberFlow- className="text-lg font-medium text-gray-500 sm:text-xl"- value={totalEvents.saleAmount / 100}- format={{- style: "currency",- currency: "USD",- // @ts-ignore – this is a valid option but TS is outdated- trailingZeroDisplay: "stripIfInteger",- }}- />- )}- </>- ) : requiresUpgrade ? (- <div className="block rounded-full bg-gray-100 p-2.5">- <Lock className="h-4 w-4 text-gray-500" />- </div>- ) : (- <div className="my-1 h-8 w-12 animate-pulse rounded-md bg-gray-200 sm:h-9" />- )}- </div>- </Link>- </div>- );- })}- </NumberFlowGroup>- </div>+ )}+ </>+ ) : requiresUpgrade ? (+ <div className="block rounded-full bg-gray-100 p-2.5">+ <Lock className="h-4 w-4 text-gray-500" />+ </div>+ ) : (+ <div className="my-1 h-8 w-12 animate-pulse rounded-md bg-gray-200 sm:h-9" />+ )}+ </div>+ </Link>+ </div>+ );+ })}+ </NumberFlowGroup></div><div className="relative">{view === "default" && (@@ -150,43 +146,38 @@ export default function Main() {</div>)}{view === "funnel" && <AnalyticsFunnelChart />}- {showConversions && <ViewButtons />}+ {showConversions && (+ <ToggleGroup+ className="absolute right-3 top-3 flex w-fit shrink-0 items-center gap-1 border-neutral-100 bg-neutral-100"+ optionClassName="size-8 p-0 flex items-center justify-center"+ indicatorClassName="border border-neutral-200 bg-white"+ options={[+ {+ label: <ChartLine className="size-4 text-neutral-600" />,+ value: "default",+ },+ {+ label: (+ <Filter2 className="size-4 -rotate-90 text-neutral-600" />+ ),+ value: "funnel",+ },+ ]}+ selected={view}+ selectAction={(option) => {+ if (option === "default") {+ queryParams({+ del: "view",+ });+ } else {+ queryParams({+ set: { view: option },+ });+ }+ }}+ />+ )}</div></div>);}--function ViewButtons() {- const { view } = useContext(AnalyticsContext);- const { queryParams } = useRouterStuff();-- return (- <ToggleGroup- className="absolute right-4 top-4 flex w-fit shrink-0 items-center gap-1 border-neutral-100 bg-neutral-100"- optionClassName="size-8 sm:size-9 p-0 flex items-center justify-center"- indicatorClassName="border border-neutral-200 bg-white"- options={[- {- label: <ChartLine className="size-4 text-neutral-600" />,- value: "default",- },- {- label: <Filter2 className="size-4 -rotate-90 text-neutral-600" />,- value: "funnel",- },- ]}- selected={view}- selectAction={(option) => {- if (option === "default") {- queryParams({- del: "view",- });- } else {- queryParams({- set: { view: option },- });- }- }}- />- );-}