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.

Analytics responsive consistency (#3717)

Marcus Farrellc44edbdfaeb6
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-chart.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-chart.tsx
index f03acc0503..13c317b84f 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-chart.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-chart.tsx
@@ -3,7 +3,7 @@ import { AnalyticsFunnelChart } from "@/ui/analytics/analytics-funnel-chart";
import { AnalyticsContext } from "@/ui/analytics/analytics-provider";
import { AnalyticsTabs } from "@/ui/analytics/analytics-tabs";
import { ChartViewSwitcher } from "@/ui/analytics/chart-view-switcher";
-import { useRouterStuff } from "@dub/ui";
+import { ToggleGroup, useRouterStuff } from "@dub/ui";
import { LoadingSpinner } from "@dub/ui/icons";
import { fetcher } from "@dub/utils";
import { useContext, useMemo } from "react";
@@ -89,7 +89,30 @@ export function AnalyticsChart() {
) : (
<AnalyticsFunnelChart />
)}
- <ChartViewSwitcher className="absolute right-3 top-3" />
+ <div className="absolute right-3 top-3 flex items-center gap-2">
+ <ToggleGroup
+ className="flex w-fit shrink-0 items-center gap-1 border-neutral-100 bg-neutral-100 sm:hidden"
+ optionClassName="size-8 p-0 flex items-center justify-center"
+ indicatorClassName="border border-neutral-200 bg-white"
+ options={[
+ {
+ label: <div className="text-base">$</div>,
+ value: "saleAmount",
+ },
+ {
+ label: <div className="text-[11px]">123</div>,
+ value: "sales",
+ },
+ ]}
+ selected={saleUnit}
+ selectAction={(option) =>
+ queryParams({
+ set: { saleUnit: option },
+ })
+ }
+ />
+ <ChartViewSwitcher />
+ </div>
</>
)}
</div>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx
index 2321472d5f..4f883e3712 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx
@@ -89,34 +89,46 @@ export function ProgramAnalyticsPageClient() {
programPage: true,
});
+ const filterSelect = (
+ <Filter.Select
+ className="w-full md:w-fit"
+ filters={filters}
+ activeFilters={activeFilters}
+ onSelect={onSelect}
+ onRemove={onRemove}
+ onOpenFilter={onOpenFilter}
+ isAdvancedFilter
+ askAI
+ />
+ );
+
+ const dateRangePicker = (
+ <SimpleDateRangePicker align="start" className="w-full md:w-fit" />
+ );
+
return (
<div className="flex flex-col gap-3 pb-12">
<div>
- <div className="flex items-center gap-2">
- <Filter.Select
- className="w-full md:w-fit"
- filters={filters}
- activeFilters={activeFilters}
- onSelect={onSelect}
- onRemove={onRemove}
- onOpenFilter={onOpenFilter}
- isAdvancedFilter
- askAI
- />
- <SimpleDateRangePicker align="start" className="w-fit" />
- <div className="flex grow justify-end gap-2">
- <Link
- href={`/${slug}/events${getQueryString({ folderId: program?.defaultFolderId, event: selectedTab, interval })}`}
- >
- <Button
- variant="secondary"
- className="w-fit"
- icon={
- <SquareLayoutGrid6 className="h-4 w-4 text-neutral-600" />
- }
- text={isMobile ? undefined : "View Events"}
- />
- </Link>
+ <div className="flex w-full flex-col items-center justify-between gap-2 md:flex-row">
+ <div className="flex w-full flex-col items-center gap-2 min-[550px]:flex-row">
+ {filterSelect}
+ <div className="flex w-full grow items-center gap-2 md:w-auto">
+ {dateRangePicker}
+ <div className="flex grow justify-end gap-2">
+ <Link
+ href={`/${slug}/events${getQueryString({ folderId: program?.defaultFolderId, event: selectedTab, interval })}`}
+ >
+ <Button
+ variant="secondary"
+ className="w-fit"
+ icon={
+ <SquareLayoutGrid6 className="h-4 w-4 text-neutral-600" />
+ }
+ text={isMobile ? undefined : "View Events"}
+ />
+ </Link>
+ </div>
+ </div>
</div>
</div>
<div>
diff --git a/apps/web/ui/analytics/toggle.tsx b/apps/web/ui/analytics/toggle.tsx
index 08e56c3932..579fbb619b 100644
--- a/apps/web/ui/analytics/toggle.tsx
+++ b/apps/web/ui/analytics/toggle.tsx
@@ -225,17 +225,17 @@ export function AnalyticsToggle({
))}
<div
className={cn(
- "flex w-full flex-col-reverse items-center gap-2 min-[550px]:flex-row",
+ "flex w-full flex-col items-center gap-2 min-[550px]:flex-row",
dashboardProps && "md:w-auto",
)}
>
- {isMobile ? dateRangePicker : filterSelect}
+ {filterSelect}
<div
className={cn("flex w-full grow items-center gap-2 md:w-auto", {
"grow-0": dashboardProps,
})}
>
- {isMobile ? filterSelect : dateRangePicker}
+ {dateRangePicker}
{!dashboardProps && (
<div className="flex grow justify-end gap-2">
{page === "analytics" && (