ColorSubstitutionNotes.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { AlertCircle } from 'lucide-react';
  2. import type { ColorSubstitution } from '../api/client';
  3. import { getColorName } from '../utils/colors';
  4. /**
  5. * One line per slot sent with a spool of another colour than the file asks
  6. * for (#3279). Shared by the queue row and the compact history row, so a job
  7. * says the same thing while it prints and once it is done.
  8. */
  9. export function ColorSubstitutionNotes({
  10. substitutions,
  11. t,
  12. className,
  13. }: {
  14. substitutions: ColorSubstitution[] | null | undefined;
  15. t: (key: string, options?: Record<string, unknown>) => string;
  16. className: string;
  17. }) {
  18. if (!substitutions || substitutions.length === 0) return null;
  19. const label = (hex: string, type: string) => `${getColorName(hex, type)} (${hex})`;
  20. return (
  21. <>
  22. {substitutions.map((sub) => (
  23. <p
  24. key={`color-sub-${sub.slot_id}`}
  25. className={`${className} flex items-start gap-1 text-amber-700 dark:text-amber-400`}
  26. title={t('queue.colorSubstitution.rowTooltip')}
  27. >
  28. <AlertCircle className="w-3 h-3 mt-0.5 flex-shrink-0" />
  29. <span>
  30. {t('queue.colorSubstitution.rowBadge', {
  31. slot: sub.slot_id,
  32. got: label(sub.got, sub.type),
  33. wanted: label(sub.wanted, sub.type),
  34. })}
  35. </span>
  36. </p>
  37. ))}
  38. </>
  39. );
  40. }