output-block.tsx 843 B

12345678910111213141516171819202122232425262728293031
  1. 'use client';
  2. import QRCode from 'react-qr-code';
  3. import { CopyButton } from './copy-button';
  4. export function OutputBlock({
  5. label,
  6. value,
  7. qr = false,
  8. }: {
  9. label: string;
  10. value: string;
  11. qr?: boolean;
  12. }) {
  13. return (
  14. <div className="overflow-hidden rounded-xl border">
  15. <div className="flex items-center justify-between gap-2 border-b bg-fd-muted/40 px-3 py-2">
  16. <span className="text-xs font-medium text-fd-muted-foreground">{label}</span>
  17. <CopyButton value={value} />
  18. </div>
  19. <pre dir="ltr" className="max-h-80 overflow-auto p-3 text-start text-xs leading-relaxed">
  20. <code>{value}</code>
  21. </pre>
  22. {qr && value ? (
  23. <div className="flex justify-center border-t bg-white p-4">
  24. <QRCode value={value} size={180} />
  25. </div>
  26. ) : null}
  27. </div>
  28. );
  29. }