diff --git a/apps/dashboard/src/App.tsx b/apps/dashboard/src/App.tsx index 1de9021..7e898b0 100644 --- a/apps/dashboard/src/App.tsx +++ b/apps/dashboard/src/App.tsx @@ -1,42 +1,46 @@ import { useState } from 'react' import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts' -import { BarChart3, TrendingUp, Users, DollarSign } from 'lucide-react' +import { BarChart3, Clock, Package, FileText } from 'lucide-react' import './App.css' +import rolldownStats from '../../../rolldown-version-stats.json' -// Sample data for different metrics -const salesData = [ - { name: 'Jan', value: 4000 }, - { name: 'Feb', value: 3000 }, - { name: 'Mar', value: 5000 }, - { name: 'Apr', value: 4500 }, - { name: 'May', value: 6000 }, - { name: 'Jun', value: 5500 }, -] +// Transform rolldown stats data for charts +const buildTimeData = rolldownStats.map(stat => ({ + name: `v${stat.version}`, + value: stat.buildTime +})) -const userActivityData = [ - { name: 'Mon', active: 120, inactive: 80 }, - { name: 'Tue', active: 150, inactive: 60 }, - { name: 'Wed', active: 180, inactive: 40 }, - { name: 'Thu', active: 200, inactive: 30 }, - { name: 'Fri', active: 170, inactive: 50 }, - { name: 'Sat', active: 90, inactive: 110 }, - { name: 'Sun', active: 80, inactive: 120 }, -] +const bundleSizeData = rolldownStats.map(stat => ({ + name: `v${stat.version}`, + value: Math.round(stat.totalSize / 1024) // Convert to KB +})) -const revenueData = [ - { name: 'Q1', revenue: 25000 }, - { name: 'Q2', revenue: 32000 }, - { name: 'Q3', revenue: 28000 }, - { name: 'Q4', revenue: 35000 }, -] +// Calculate file type breakdown from all versions +const fileTypeStats = rolldownStats.reduce((acc, stat) => { + stat.files.forEach(file => { + if (!acc[file.type]) { + acc[file.type] = 0 + } + acc[file.type] += file.size + }) + return acc +}, {} as Record) + +const fileTypeData = Object.entries(fileTypeStats).map(([type, size]) => ({ + name: type.toUpperCase(), + js: type === 'js' ? Math.round(size / 1024) : 0, + css: type === 'css' ? Math.round(size / 1024) : 0, + html: type === 'html' ? Math.round(size / 1024) : 0, + other: type === 'other' ? Math.round(size / 1024) : 0, +})).filter(item => item.js > 0 || item.css > 0 || item.html > 0 || item.other > 0) function App() { - const [selectedMetric, setSelectedMetric] = useState('sales') + const [selectedMetric, setSelectedMetric] = useState('buildTime') const metrics = [ - { id: 'sales', name: 'Sales', icon: TrendingUp, data: salesData, color: '#8884d8' }, - { id: 'users', name: 'User Activity', icon: Users, data: userActivityData, color: '#82ca9d' }, - { id: 'revenue', name: 'Revenue', icon: DollarSign, data: revenueData, color: '#ffc658' }, + { id: 'buildTime', name: 'Build Time', icon: Clock, data: buildTimeData, color: '#8884d8' }, + { id: 'bundleSize', name: 'Bundle Size', icon: Package, data: bundleSizeData, color: '#82ca9d' }, + { id: 'fileTypes', name: 'File Types', icon: FileText, data: fileTypeData, color: '#ffc658' }, ] const currentMetric = metrics.find(m => m.id === selectedMetric) || metrics[0] @@ -73,15 +77,17 @@ function App() {

{currentMetric.name}

- {selectedMetric === 'users' ? ( + {selectedMetric === 'fileTypes' ? ( - - + + + + ) : ( @@ -91,9 +97,9 @@ function App() { )} @@ -102,24 +108,24 @@ function App() {
-

Total Sales

-

$124,500

- +12.5% +

Average Build Time

+

{Math.round(buildTimeData.reduce((sum, item) => sum + item.value, 0) / buildTimeData.length)}ms

+ Across {buildTimeData.length} versions
-

Active Users

-

1,245

- +8.2% +

Latest Bundle Size

+

{bundleSizeData[bundleSizeData.length - 1]?.value}KB

+ v{rolldownStats[rolldownStats.length - 1]?.version}
-

Revenue

-

$98,750

- -3.1% +

Total File Types

+

{fileTypeData.length}

+ JS, CSS, HTML, Other
-

Conversion Rate

-

3.2%

- +0.8% +

Versions Tested

+

{rolldownStats.length}

+ {rolldownStats[0]?.version} - {rolldownStats[rolldownStats.length - 1]?.version}