Skip to content

Commit c845adc

Browse files
committed
replace shadcn dialog with antD modal
1 parent a2160b9 commit c845adc

File tree

2 files changed

+29
-265
lines changed

2 files changed

+29
-265
lines changed

client/packages/lowcoder/src/comps/comps/chatComp/components/ui/attachment.tsx

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,20 @@ import {
99
useAttachment,
1010
} from "@assistant-ui/react";
1111
import styled from "styled-components";
12+
import { Modal } from "antd";
1213
import {
1314
Tooltip,
1415
TooltipContent,
1516
TooltipTrigger,
1617
} from "./tooltip";
17-
import {
18-
Dialog,
19-
DialogTitle,
20-
DialogTrigger,
21-
DialogOverlay,
22-
DialogPortal,
23-
DialogContent,
24-
} from "./dialog";
2518
import { Avatar, AvatarImage, AvatarFallback } from "./avatar";
2619
import { TooltipIconButton } from "../assistant-ui/tooltip-icon-button";
2720

2821
// ============================================================================
2922
// STYLED COMPONENTS
3023
// ============================================================================
3124

32-
const StyledDialogTrigger = styled(DialogTrigger)`
25+
const StyledModalTrigger = styled.div`
3326
cursor: pointer;
3427
transition: background-color 0.2s;
3528
padding: 2px;
@@ -136,13 +129,7 @@ const StyledComposerButton = styled(TooltipIconButton)`
136129
transition: opacity 0.2s ease-in;
137130
`;
138131

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
146133

147134

148135
const useAttachmentSrc = () => {
@@ -244,21 +231,37 @@ const AttachmentPreview: FC<AttachmentPreviewProps> = ({ src }) => {
244231

245232
const AttachmentPreviewDialog: FC<PropsWithChildren> = ({ children }) => {
246233
const src = useAttachmentSrc();
234+
const [isModalOpen, setIsModalOpen] = useState(false);
247235

248236
if (!src) return <>{children}</>;
249237

250238
return (
251-
<Dialog>
252-
<StyledDialogTrigger asChild>
239+
<>
240+
<StyledModalTrigger onClick={() => setIsModalOpen(true)}>
253241
{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+
>
259262
<AttachmentPreview src={src} />
260-
</AttachmentDialogContent>
261-
</Dialog>
263+
</Modal>
264+
</>
262265
);
263266
};
264267

@@ -363,13 +366,4 @@ export const ComposerAddAttachment: FC = () => {
363366
</StyledComposerButton>
364367
</ComposerPrimitive.AddAttachment>
365368
);
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+
};

client/packages/lowcoder/src/comps/comps/chatComp/components/ui/dialog.tsx

Lines changed: 0 additions & 230 deletions
This file was deleted.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy