dify/web/app/components/base/image-uploader/audio-preview.tsx
Coding On Star 8581a68174
refactor(web): drop headless-ui, migrate overlay to dify-ui (#35963)
Co-authored-by: CodingOnStar <hanxujiang@dify.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
2026-05-09 10:33:25 +00:00

54 lines
1.5 KiB
TypeScript

import type { FC } from 'react'
import { Dialog, DialogContent } from '@langgenius/dify-ui/dialog'
type AudioPreviewProps = {
url: string
title: string
onCancel: () => void
}
const AudioPreview: FC<AudioPreviewProps> = ({
url,
title,
onCancel,
}) => {
return (
<Dialog
open
onOpenChange={(open) => {
if (!open)
onCancel()
}}
disablePointerDismissal
>
<DialogContent
className="inset-0! top-0! left-0! flex h-dvh! max-h-none! w-screen! max-w-none! translate-x-0! translate-y-0! items-center justify-center overflow-hidden! rounded-none! border-none! bg-black/80 p-8! shadow-none!"
backdropClassName="bg-transparent!"
>
<div
aria-label={title}
data-testid="audio-preview-overlay"
tabIndex={-1}
onClick={e => e.stopPropagation()}
>
<audio controls title={title} autoPlay={false} preload="metadata" data-testid="audio-element">
<source
type="audio/mpeg"
src={url}
className="max-h-full max-w-full"
/>
</audio>
</div>
<div
className="absolute top-6 right-6 flex h-8 w-8 cursor-pointer items-center justify-center rounded-lg bg-white/[0.08] backdrop-blur-[2px]"
onClick={onCancel}
data-testid="close-preview"
>
<span className="i-ri-close-line h-4 w-4 text-gray-500" />
</div>
</DialogContent>
</Dialog>
)
}
export default AudioPreview