| // src/components/ViewsChart.tsx | |
| import { | |
| LineChart, | |
| Line, | |
| XAxis, | |
| YAxis, | |
| Tooltip, | |
| ResponsiveContainer, | |
| CartesianGrid, | |
| } from "recharts"; | |
| interface ViewsChartProps { | |
| data: { date: string; count: number }[]; | |
| isLoading?: boolean; | |
| } | |
| // Custom tooltip that adapts to dark mode | |
| const CustomTooltip = ({ active, payload, label }: any) => { | |
| if (active && payload && payload.length) { | |
| return ( | |
| <div className="rounded-xl border border-white/10 bg-slate-900/90 backdrop-blur-xl p-3 shadow-2xl"> | |
| <p className="text-[10px] text-slate-400 font-bold uppercase tracking-wider">{label}</p> | |
| <p className="text-sm font-black text-indigo-400 mt-1">{payload[0].value} views</p> | |
| </div> | |
| ); | |
| } | |
| return null; | |
| }; | |
| export function ViewsChart({ data, isLoading = false }: ViewsChartProps) { | |
| if (isLoading) { | |
| return ( | |
| <div className="rounded-[2rem] premium-glass p-6 border border-white/5 bg-slate-950/20 shadow-md"> | |
| <h3 className="mb-4 text-sm font-bold text-white uppercase tracking-wider">๐ Views Over Time (Last 7 days)</h3> | |
| <div className="flex h-[300px] items-center justify-center"> | |
| <div className="h-8 w-8 animate-spin rounded-full border-2 border-indigo-500 border-t-transparent" /> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| if (!data || data.length === 0) { | |
| return ( | |
| <div className="rounded-[2rem] premium-glass p-6 border border-white/5 bg-slate-950/20 shadow-md"> | |
| <h3 className="mb-4 text-sm font-bold text-white uppercase tracking-wider">๐ Views Over Time (Last 7 days)</h3> | |
| <div className="flex h-[300px] items-center justify-center text-slate-500 text-sm font-medium"> | |
| No view history available for the last 7 days | |
| </div> | |
| </div> | |
| ); | |
| } | |
| return ( | |
| <div className="rounded-[2rem] premium-glass p-6 border border-white/5 bg-slate-950/20 shadow-md"> | |
| <h3 className="mb-4 text-sm font-bold text-white uppercase tracking-wider">๐ Views Over Time (Last 7 days)</h3> | |
| <ResponsiveContainer width="100%" height={300}> | |
| <LineChart data={data}> | |
| <CartesianGrid strokeDasharray="3 3" stroke="rgba(255,255,255,0.05)" /> | |
| <XAxis dataKey="date" stroke="#64748b" fontSize={11} tickLine={false} /> | |
| <YAxis stroke="#64748b" fontSize={11} tickLine={false} /> | |
| <Tooltip content={<CustomTooltip />} /> | |
| <Line | |
| type="monotone" | |
| dataKey="count" | |
| stroke="url(#colorViews)" | |
| strokeWidth={3} | |
| dot={{ r: 4, stroke: "#6366f1", strokeWidth: 2, fill: "#0f172a" }} | |
| activeDot={{ r: 6, stroke: "#a855f7", strokeWidth: 2, fill: "#fff" }} | |
| /> | |
| <defs> | |
| <linearGradient id="colorViews" x1="0" y1="0" x2="1" y2="0"> | |
| <stop offset="0%" stopColor="#6366f1" /> | |
| <stop offset="100%" stopColor="#a855f7" /> | |
| </linearGradient> | |
| </defs> | |
| </LineChart> | |
| </ResponsiveContainer> | |
| </div> | |
| ); | |
| } |
Xet Storage Details
- Size:
- 3.02 kB
- Xet hash:
- 3d47a2f4091eff727c15d75dc0db0e2d5f51c6ed4d0f14abdd1dd48d06ec193f
ยท
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.