import React from 'react'; import { ReadingStats, VoiceName } from '../types'; import { BarChart3, Clock, BookOpen, Flame, Trophy, Mic } from 'lucide-react'; import { AVAILABLE_VOICES } from '../constants'; interface StatsPanelProps { stats: ReadingStats; onClose: () => void; } export const StatsPanel: React.FC = ({ stats, onClose }) => { const formatTime = (minutes: number): string => { if (minutes < 60) return `${Math.round(minutes)}m`; const hours = Math.floor(minutes / 60); const mins = Math.round(minutes % 60); return `${hours}h ${mins}m`; }; const favoriteVoiceData = AVAILABLE_VOICES.find(v => v.name === stats.favoriteVoice); // Get last 7 days activity const last7Days = Array.from({ length: 7 }, (_, i) => { const date = new Date(); date.setDate(date.getDate() - (6 - i)); const dateStr = date.toISOString().split('T')[0]; return { day: date.toLocaleDateString('en', { weekday: 'short' }), count: stats.articlesPerDay[dateStr] || 0 }; }); const maxCount = Math.max(...last7Days.map(d => d.count), 1); return (
{/* Header */}

Reading Stats

{/* Stats Grid */}
{/* Main Stats */}
Articles Read

{stats.totalArticlesRead}

Time Listened

{formatTime(stats.totalMinutesListened)}

Current Streak

{stats.currentStreak} days

Best Streak

{stats.longestStreak} days

{/* Words Read */}

Total Words Consumed

{stats.totalWordsRead.toLocaleString()}

That's about {Math.round(stats.totalWordsRead / 250)} pages!

{/* Weekly Activity */}

Last 7 Days

{last7Days.map((day, i) => (
0 ? 1 : 0.2 }} />
{day.day}
))}
{/* Favorite Voice */} {favoriteVoiceData && (
{favoriteVoiceData.emoji}

Favorite Voice

{favoriteVoiceData.label}

Used {stats.voiceUsage[stats.favoriteVoice] || 0} times

)}
); };