QueueStatsBar.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { Play, Clock, Timer, Weight, CheckCircle } from 'lucide-react';
  2. import { formatDuration } from '../utils/date';
  3. function formatWeight(g: number): string {
  4. if (g >= 1000) return `${(g / 1000).toFixed(1)}kg`;
  5. return `${Math.round(g)}g`;
  6. }
  7. export function QueueStatsBar({
  8. activeCount,
  9. pendingCount,
  10. totalTime,
  11. totalWeight,
  12. historyCount,
  13. t,
  14. }: {
  15. activeCount: number;
  16. pendingCount: number;
  17. totalTime: number;
  18. totalWeight: number;
  19. historyCount: number;
  20. t: (key: string) => string;
  21. }) {
  22. const stats = [
  23. { icon: Play, value: activeCount, label: t('queue.summary.printing'), color: 'text-blue-600 dark:text-blue-400' },
  24. { icon: Clock, value: pendingCount, label: t('queue.summary.queued'), color: 'text-yellow-600 dark:text-yellow-400' },
  25. { icon: Timer, value: formatDuration(totalTime), label: t('queue.summary.totalTime'), color: 'text-bambu-green' },
  26. { icon: Weight, value: formatWeight(totalWeight), label: t('queue.summary.totalWeight'), color: 'text-purple-600 dark:text-purple-400' },
  27. { icon: CheckCircle, value: historyCount, label: t('queue.summary.history'), color: 'text-bambu-gray' },
  28. ];
  29. return (
  30. <div className="flex items-center gap-3 sm:gap-5 flex-wrap px-4 py-3 bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary mb-6">
  31. {stats.map((stat, i) => (
  32. <div key={i} className="flex items-center gap-3">
  33. {i > 0 && <span className="hidden sm:block text-bambu-dark-tertiary">|</span>}
  34. <div className="flex items-center gap-1.5">
  35. <stat.icon className={`w-4 h-4 ${stat.color}`} />
  36. <span className="text-sm font-semibold text-white">{stat.value}</span>
  37. <span className="text-xs sm:text-sm text-bambu-gray">{stat.label}</span>
  38. </div>
  39. </div>
  40. ))}
  41. </div>
  42. );
  43. }