@@ -9,27 +9,20 @@ import {
9
9
useAttachment ,
10
10
} from "@assistant-ui/react" ;
11
11
import styled from "styled-components" ;
12
+ import { Modal } from "antd" ;
12
13
import {
13
14
Tooltip ,
14
15
TooltipContent ,
15
16
TooltipTrigger ,
16
17
} from "./tooltip" ;
17
- import {
18
- Dialog ,
19
- DialogTitle ,
20
- DialogTrigger ,
21
- DialogOverlay ,
22
- DialogPortal ,
23
- DialogContent ,
24
- } from "./dialog" ;
25
18
import { Avatar , AvatarImage , AvatarFallback } from "./avatar" ;
26
19
import { TooltipIconButton } from "../assistant-ui/tooltip-icon-button" ;
27
20
28
21
// ============================================================================
29
22
// STYLED COMPONENTS
30
23
// ============================================================================
31
24
32
- const StyledDialogTrigger = styled ( DialogTrigger ) `
25
+ const StyledModalTrigger = styled . div `
33
26
cursor: pointer;
34
27
transition: background-color 0.2s;
35
28
padding: 2px;
@@ -136,13 +129,7 @@ const StyledComposerButton = styled(TooltipIconButton)`
136
129
transition: opacity 0.2s ease-in;
137
130
` ;
138
131
139
- const ScreenReaderOnly = styled . span `
140
- position: absolute;
141
- left: -10000px;
142
- width: 1px;
143
- height: 1px;
144
- overflow: hidden;
145
- ` ;
132
+ // ScreenReaderOnly component removed as it's no longer needed with ANTD Modal
146
133
147
134
148
135
const useAttachmentSrc = ( ) => {
@@ -244,21 +231,37 @@ const AttachmentPreview: FC<AttachmentPreviewProps> = ({ src }) => {
244
231
245
232
const AttachmentPreviewDialog : FC < PropsWithChildren > = ( { children } ) => {
246
233
const src = useAttachmentSrc ( ) ;
234
+ const [ isModalOpen , setIsModalOpen ] = useState ( false ) ;
247
235
248
236
if ( ! src ) return < > { children } </ > ;
249
237
250
238
return (
251
- < Dialog >
252
- < StyledDialogTrigger asChild >
239
+ < >
240
+ < StyledModalTrigger onClick = { ( ) => setIsModalOpen ( true ) } >
253
241
{ children }
254
- </ StyledDialogTrigger >
255
- < AttachmentDialogContent >
256
- < DialogTitle >
257
- < ScreenReaderOnly > Image Attachment Preview</ ScreenReaderOnly >
258
- </ DialogTitle >
242
+ </ StyledModalTrigger >
243
+ < Modal
244
+ title = "Image Attachment Preview"
245
+ open = { isModalOpen }
246
+ onCancel = { ( ) => setIsModalOpen ( false ) }
247
+ footer = { null }
248
+ width = "auto"
249
+ style = { {
250
+ maxWidth : "80vw" ,
251
+ top : 20 ,
252
+ } }
253
+ styles = { {
254
+ body : {
255
+ display : "flex" ,
256
+ justifyContent : "center" ,
257
+ alignItems : "center" ,
258
+ padding : "20px" ,
259
+ }
260
+ } }
261
+ >
259
262
< AttachmentPreview src = { src } />
260
- </ AttachmentDialogContent >
261
- </ Dialog >
263
+ </ Modal >
264
+ </ >
262
265
) ;
263
266
} ;
264
267
@@ -363,13 +366,4 @@ export const ComposerAddAttachment: FC = () => {
363
366
</ StyledComposerButton >
364
367
</ ComposerPrimitive . AddAttachment >
365
368
) ;
366
- } ;
367
-
368
- const AttachmentDialogContent : FC < PropsWithChildren > = ( { children } ) => (
369
- < DialogPortal >
370
- < DialogOverlay />
371
- < DialogContent className = "aui-dialog-content" >
372
- { children }
373
- </ DialogContent >
374
- </ DialogPortal >
375
- ) ;
369
+ } ;
0 commit comments