video-preview.tsx 1016 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import type { FC } from 'react'
  2. import { createPortal } from 'react-dom'
  3. import { RiCloseLine } from '@remixicon/react'
  4. type VideoPreviewProps = {
  5. url: string
  6. title: string
  7. onCancel: () => void
  8. }
  9. const VideoPreview: FC<VideoPreviewProps> = ({
  10. url,
  11. title,
  12. onCancel,
  13. }) => {
  14. return createPortal(
  15. <div className='fixed inset-0 p-8 flex items-center justify-center bg-black/80 z-[1000]' onClick={e => e.stopPropagation()}>
  16. <div>
  17. <video controls title={title} autoPlay={false} preload="metadata">
  18. <source
  19. type="video/mp4"
  20. src={url}
  21. className='max-w-full max-h-full'
  22. />
  23. </video>
  24. </div>
  25. <div
  26. className='absolute top-6 right-6 flex items-center justify-center w-8 h-8 bg-white/[0.08] rounded-lg backdrop-blur-[2px] cursor-pointer'
  27. onClick={onCancel}
  28. >
  29. <RiCloseLine className='w-4 h-4 text-gray-500'/>
  30. </div>
  31. </div>
  32. ,
  33. document.body,
  34. )
  35. }
  36. export default VideoPreview