Skip to content

Commit 3145c51

Browse files
committed
feat: ai Button ์ถ”๊ฐ€
#20
1 parent 4cf6f49 commit 3145c51

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { css, cx } from "@styled-system/css";
2+
import { glassContainer } from "@styled-system/recipes";
3+
4+
export const glassEffect = cx(glassContainer({ border: "md" }));
5+
6+
export const floatingButtonContainer = css({
7+
zIndex: "50",
8+
position: "fixed",
9+
right: "24px",
10+
bottom: "24px",
11+
});
12+
13+
export const buttonContainer = cx(
14+
glassContainer({ border: "md" }),
15+
css({
16+
padding: "12px",
17+
paddingX: "20px",
18+
backgroundColor: "white/40",
19+
cursor: "pointer",
20+
}),
21+
);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { useState, useRef, useEffect } from "react";
2+
import * as style from "./AIButton.style";
3+
import AIModal from "./AIModal";
4+
5+
const AIButton = () => {
6+
const [isOpen, setIsOpen] = useState(false);
7+
const modalRef = useRef<HTMLDivElement>(null);
8+
9+
const handleClose = () => {
10+
setIsOpen(false);
11+
};
12+
13+
useEffect(() => {
14+
const handleClickOutside = (event: MouseEvent) => {
15+
if (modalRef.current && !modalRef.current.contains(event.target as Node)) {
16+
setIsOpen(false);
17+
}
18+
};
19+
20+
document.addEventListener("mousedown", handleClickOutside);
21+
return () => {
22+
document.removeEventListener("mousedown", handleClickOutside);
23+
};
24+
}, []);
25+
26+
return (
27+
<div className={style.floatingButtonContainer}>
28+
<div ref={modalRef}>
29+
{isOpen && <AIModal onCloseButton={handleClose} />}
30+
<button onClick={() => setIsOpen((prev) => !prev)} className={style.buttonContainer}>
31+
<span>AI ๋ฌธ์„œ ์ž‘์„ฑ</span>
32+
</button>
33+
</div>
34+
</div>
35+
);
36+
};
37+
38+
export default AIButton;

0 commit comments

Comments
ย (0)