From 10fd33b6fcd367beb9ccaf6d450f65d597e5cdb6 Mon Sep 17 00:00:00 2001 From: jyswee Date: Thu, 23 Jul 2026 22:10:34 +0000 Subject: [PATCH] Seed: dashboard template (24 files) --- src/pages/Analytics.tsx | 281 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 src/pages/Analytics.tsx diff --git a/src/pages/Analytics.tsx b/src/pages/Analytics.tsx new file mode 100644 index 0000000..65b9d89 --- /dev/null +++ b/src/pages/Analytics.tsx @@ -0,0 +1,281 @@ +import { useState } from "react"; +import { AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, PieChart, Pie, Cell } from "recharts"; +import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"; +import { Badge } from "@/components/ui/badge"; +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; +import { + Eye, TrendingDown, Clock, UserPlus, ArrowUpRight, ArrowDownRight, + Globe, BarChart3 +} from "lucide-react"; +import Sidebar from "@/components/Sidebar"; +import Header from "@/components/Header"; + +const metricCards = [ + { + title: "Page Views", + value: "284,392", + change: "+14.2%", + trend: "up" as const, + icon: Eye, + color: "text-sky-600 bg-sky-100", + }, + { + title: "Bounce Rate", + value: "42.3%", + change: "-2.4%", + trend: "down" as const, + icon: TrendingDown, + color: "text-orange-600 bg-orange-100", + }, + { + title: "Session Duration", + value: "4m 32s", + change: "+18.7%", + trend: "up" as const, + icon: Clock, + color: "text-emerald-600 bg-emerald-100", + }, + { + title: "New Users", + value: "1,847", + change: "+6.3%", + trend: "up" as const, + icon: UserPlus, + color: "text-violet-600 bg-violet-100", + }, +]; + +const trafficSources = [ + { name: "Organic Search", value: 42, color: "bg-sky-500" }, + { name: "Social Media", value: 28, color: "bg-orange-500" }, + { name: "Direct", value: 18, color: "bg-emerald-500" }, + { name: "Referral", value: 12, color: "bg-violet-500" }, +]; + +const userGrowthData = [ + { month: "Jan", users: 120 }, { month: "Feb", users: 145 }, { month: "Mar", users: 162 }, + { month: "Apr", users: 158 }, { month: "May", users: 190 }, { month: "Jun", users: 210 }, + { month: "Jul", users: 235 }, { month: "Aug", users: 248 }, { month: "Sep", users: 275 }, + { month: "Oct", users: 298 }, { month: "Nov", users: 310 }, { month: "Dec", users: 342 }, +]; + +const trafficPieData = [ + { name: "Direct", value: 42 }, + { name: "Social", value: 28 }, + { name: "Organic", value: 18 }, + { name: "Referral", value: 12 }, +]; +const PIE_COLORS = ["#0ea5e9", "#f97316", "#10b981", "#8b5cf6"]; + +const topPages = [ + { url: "/", views: "45,231", bounce: "32.1%", duration: "3m 45s" }, + { url: "/products", views: "28,492", bounce: "41.8%", duration: "2m 12s" }, + { url: "/pricing", views: "19,847", bounce: "38.5%", duration: "4m 08s" }, + { url: "/blog/getting-started", views: "15,623", bounce: "25.3%", duration: "6m 32s" }, + { url: "/about", views: "12,891", bounce: "45.2%", duration: "1m 55s" }, + { url: "/contact", views: "9,472", bounce: "52.7%", duration: "1m 20s" }, + { url: "/docs/api", views: "8,234", bounce: "28.9%", duration: "5m 48s" }, + { url: "/careers", views: "6,128", bounce: "39.1%", duration: "3m 15s" }, +]; + +const geoBreakdown = [ + { country: "United States", flag: "πŸ‡ΊπŸ‡Έ", pct: 38, visitors: "108,069" }, + { country: "United Kingdom", flag: "πŸ‡¬πŸ‡§", pct: 22, visitors: "62,566" }, + { country: "Germany", flag: "πŸ‡©πŸ‡ͺ", pct: 15, visitors: "42,659" }, + { country: "Canada", flag: "πŸ‡¨πŸ‡¦", pct: 11, visitors: "31,283" }, +]; + +export default function AnalyticsPage() { + const [dateRange, setDateRange] = useState("30d"); + + return ( +
+ +
+
+
+ {/* ── Date Range ── */} +
+
+

Analytics

+

Track your site performance and user behavior

+
+
+ + +
+
+ + {/* ── Quick Stats Pills ── */} +
+
+ Page Views: 12.4K +
+
+ Bounce: 34% +
+
+ Avg Duration: 4m 32s +
+
+ New Users: 1.2K +
+
+ + {/* ── Metric Cards ── */} +
+ {metricCards.map((metric) => ( + + +
+
+ +
+
+ {metric.trend === "up" ? : } + {metric.change} +
+
+
+

{metric.value}

+

{metric.title}

+
+
+
+ ))} +
+ + {/* ── Charts Section ── */} +
+ {/* Traffic Sources */} + + + Traffic Sources + Where your visitors are coming from + + +
+ + + + {trafficPieData.map((entry, index) => ( + + ))} + + + + +
+
+ {trafficSources.map((source) => ( +
+
+ {source.name} + {source.value}% +
+ ))} +
+ + + + {/* User Growth */} + + + User Growth + New user registrations over time + + + + + + + + + + + + + + + + + + + +
+ + {/* ── Top Pages ── */} + + + Top Pages + Most visited pages on your site + + + + + + Page URL + Views + Bounce Rate + Avg. Duration + + + + {topPages.map((page) => ( + + {page.url} + {page.views} + {page.bounce} + {page.duration} + + ))} + +
+
+
+ + {/* ── Geographic Breakdown ── */} + + + Geographic Breakdown + Visitor distribution by country + + + {geoBreakdown.map((geo) => ( +
+ {geo.flag} +
+
+ {geo.country} + {geo.visitors} visitors +
+
+
+
+
+ {geo.pct}% +
+ ))} + + +
+
+
+ ); +}