Skip to content

Commit 9122b26

Browse files
committed
Create AssistantModal.tsx
1 parent b530b67 commit 9122b26

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import React from "react";
2+
import { Standard } from "@typebot.io/react";
3+
4+
function AssistantModal({ isOpen, onClose }) {
5+
if (!isOpen) return null; // Prevent modal from rendering when isOpen is false.
6+
7+
// Get the current page URL.
8+
const currentUrl = window.location.href;
9+
10+
return (
11+
<div className="modal" style={styles.modal}>
12+
<div className="modal-content" style={styles.modalContent}>
13+
{/* Close the button. */}
14+
<span className="close" onClick={onClose} style={styles.closeButton}>
15+
&times;
16+
</span>
17+
<Standard
18+
typebot="en-us-scalar-docs-ai-assistant-for-scalar-membership-program-members-201712"
19+
style={{ width: "100%", height: "600px" }}
20+
prefilledVariables={{
21+
"Current page URL": `${currentUrl}`, // Pass page URL as a query parameter.
22+
}}
23+
/>
24+
</div>
25+
</div>
26+
);
27+
}
28+
29+
const styles = {
30+
modal: {
31+
display: "block",
32+
position: "fixed",
33+
zIndex: 1000,
34+
left: 0,
35+
top: 0,
36+
width: "100%",
37+
height: "100%",
38+
backgroundColor: "rgba(0, 0, 0, 0.7)",
39+
},
40+
modalContent: {
41+
backgroundColor: "#fff",
42+
margin: "10% auto",
43+
padding: "20px",
44+
borderRadius: "10px",
45+
width: "90%",
46+
maxWidth: "900px",
47+
position: "relative", // Allow absolute positioning of the close button.
48+
},
49+
closeButton: {
50+
position: "absolute",
51+
top: "10px",
52+
right: "20px",
53+
fontSize: "30px",
54+
fontWeight: "bold",
55+
cursor: "pointer",
56+
color: "#333",
57+
backgroundColor: "transparent",
58+
border: "none",
59+
padding: "0",
60+
zIndex: 1100, // Ensure the close button is above the modal content.
61+
},
62+
};
63+
64+
export default AssistantModal;

0 commit comments

Comments
 (0)