Skip to content

Commit f68a1bb

Browse files
committed
mobile responsiveness
1 parent be7687f commit f68a1bb

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

apps/dashboard/app/(main)/websites/[id]/_components/tabs/overview-tab.tsx

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
import { useChartPreferences } from "@/hooks/use-chart-preferences";
3232
import { useDateFilters } from "@/hooks/use-date-filters";
3333
import { useBatchDynamicQuery } from "@/hooks/use-dynamic-query";
34+
import { useMediaQuery } from "@/hooks/use-media-query";
3435
import { metricVisibilityAtom } from "@/stores/jotai/chartAtoms";
3536
import {
3637
calculatePercentChange,
@@ -123,6 +124,7 @@ export function WebsiteOverviewTab({
123124
addFilter,
124125
}: Omit<FullTabProps, "isRefreshing" | "setIsRefreshing">) {
125126
const { chartType, chartStepType } = useChartPreferences("overview-stats");
127+
const isMobile = useMediaQuery("(max-width: 640px)");
126128
const calculatePreviousPeriod = useCallback(
127129
(currentRange: typeof dateRange) => {
128130
const startDate = dayjs(currentRange.start_date);
@@ -475,9 +477,11 @@ export function WebsiteOverviewTab({
475477
const entry = info.row.original as TechnologyData;
476478
const IconComponent = type === "browser" ? BrowserIcon : OSIcon;
477479
return (
478-
<div className="flex items-center gap-3">
479-
<IconComponent name={entry.name} size="md" />
480-
<span className="font-medium">{entry.name}</span>
480+
<div className="flex items-center gap-2 sm:gap-3">
481+
<IconComponent className="shrink-0" name={entry.name} size="md" />
482+
<span className="truncate font-medium text-sm sm:text-base">
483+
{entry.name}
484+
</span>
481485
</div>
482486
);
483487
};
@@ -581,6 +585,7 @@ export function WebsiteOverviewTab({
581585
header: "Browser",
582586
cell: createTechnologyCell("browser"),
583587
size: 180,
588+
minSize: 120,
584589
},
585590
{
586591
id: "visitors",
@@ -617,6 +622,7 @@ export function WebsiteOverviewTab({
617622
header: "Operating System",
618623
cell: createTechnologyCell("os"),
619624
size: 200,
625+
minSize: 140,
620626
},
621627
{
622628
id: "visitors",
@@ -789,9 +795,9 @@ export function WebsiteOverviewTab({
789795
}
790796

791797
return (
792-
<div className="space-y-4">
798+
<div className="space-y-3 sm:space-y-4">
793799
<EventLimitIndicator />
794-
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-5">
800+
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-5">
795801
{[
796802
{
797803
id: "pageviews-chart",
@@ -894,24 +900,30 @@ export function WebsiteOverviewTab({
894900

895901
{/* Chart */}
896902
<div className="rounded border bg-sidebar">
897-
<div className="flex flex-col items-start justify-between gap-3 border-b px-4 py-3 sm:flex-row">
898-
<div>
899-
<h2 className="font-semibold text-lg text-sidebar-foreground tracking-tight">
903+
<div className="flex flex-col items-start justify-between gap-3 border-b px-3 py-2.5 sm:flex-row sm:px-4 sm:py-3">
904+
<div className="min-w-0 flex-1">
905+
<h2 className="font-semibold text-base text-sidebar-foreground tracking-tight sm:text-lg">
900906
Traffic Trends
901907
</h2>
902-
<p className="text-sidebar-foreground/70 text-sm">
908+
<p className="text-sidebar-foreground/70 text-xs sm:text-sm">
903909
{dateRange.granularity === "hourly" ? "Hourly" : "Daily"} traffic
904910
data
905911
</p>
906912
{dateRange.granularity === "hourly" && dateDiff > 7 && (
907-
<div className="mt-1 flex items-center gap-1 text-amber-600 text-xs">
908-
<WarningIcon size={16} weight="fill" />
909-
<span>Large date ranges may affect performance</span>
913+
<div className="mt-1 flex items-start gap-1 text-amber-600 text-xs">
914+
<WarningIcon
915+
className="mt-0.5 shrink-0"
916+
size={14}
917+
weight="fill"
918+
/>
919+
<span className="leading-relaxed">
920+
Large date ranges may affect performance
921+
</span>
910922
</div>
911923
)}
912924
</div>
913925
</div>
914-
<div>
926+
<div className="overflow-x-auto">
915927
<MetricsChartWithAnnotations
916928
className="rounded border-0"
917929
data={chartData}
@@ -924,7 +936,7 @@ export function WebsiteOverviewTab({
924936
| "weekly"
925937
| "monthly",
926938
}}
927-
height={350}
939+
height={isMobile ? 250 : 350}
928940
isLoading={isLoading}
929941
onRangeSelect={setDateRangeAction}
930942
websiteId={websiteId}
@@ -933,7 +945,7 @@ export function WebsiteOverviewTab({
933945
</div>
934946

935947
{/* Tables */}
936-
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2">
948+
<div className="grid grid-cols-1 gap-3 sm:gap-4 lg:grid-cols-2">
937949
<DataTable
938950
description="Referrers and campaign data"
939951
isLoading={isLoading}
@@ -960,7 +972,7 @@ export function WebsiteOverviewTab({
960972
/>
961973

962974
{/* Technology */}
963-
<div className="grid grid-cols-1 gap-4 xl:grid-cols-2 2xl:grid-cols-3">
975+
<div className="grid grid-cols-1 gap-3 sm:gap-4 xl:grid-cols-2 2xl:grid-cols-3">
964976
<DataTable
965977
columns={deviceColumns}
966978
data={analytics.device_types || []}

0 commit comments

Comments
 (0)