|
1 | 1 | "use client"; |
2 | 2 |
|
3 | 3 | import type { UIMessage } from "ai"; |
4 | | -import { IconSquare2StackedLine } from "@karrotmarket/react-monochrome-icon"; |
| 4 | +import { |
| 5 | + IconCheckmarkCircleLine, |
| 6 | + IconSquare2StackedLine, |
| 7 | +} from "@karrotmarket/react-monochrome-icon"; |
5 | 8 | import { Icon } from "@seed-design/react"; |
6 | 9 | import { DynamicCodeBlock } from "fumadocs-ui/components/dynamic-codeblock"; |
| 10 | +import { AnimatePresence, m } from "motion/react"; |
7 | 11 | import { ActionButton } from "seed-design/ui/action-button"; |
8 | 12 | import { useEffect, useState } from "react"; |
9 | 13 | import { parseMarkdownCodeBlocks } from "./parse-markdown-code-blocks"; |
@@ -250,7 +254,7 @@ export function ChatMessage({ message }: { message: UIMessage }) { |
250 | 254 |
|
251 | 255 | const timeout = window.setTimeout(() => { |
252 | 256 | setIsCopied(false); |
253 | | - }, 1000); |
| 257 | + }, 2000); |
254 | 258 |
|
255 | 259 | return () => window.clearTimeout(timeout); |
256 | 260 | }, [isCopied]); |
@@ -377,7 +381,31 @@ export function ChatMessage({ message }: { message: UIMessage }) { |
377 | 381 | aria-label={isCopied ? "응답 복사됨" : "응답 복사"} |
378 | 382 | disabled={!canCopy} |
379 | 383 | > |
380 | | - <Icon svg={<IconSquare2StackedLine />} /> |
| 384 | + <AnimatePresence mode="wait" initial={false}> |
| 385 | + {isCopied ? ( |
| 386 | + <m.span |
| 387 | + key="copied" |
| 388 | + initial={{ opacity: 0 }} |
| 389 | + animate={{ opacity: 1 }} |
| 390 | + exit={{ opacity: 0 }} |
| 391 | + transition={{ duration: 0.15 }} |
| 392 | + className="inline-flex" |
| 393 | + > |
| 394 | + <Icon svg={<IconCheckmarkCircleLine />} /> |
| 395 | + </m.span> |
| 396 | + ) : ( |
| 397 | + <m.span |
| 398 | + key="copy" |
| 399 | + initial={{ opacity: 0 }} |
| 400 | + animate={{ opacity: 1 }} |
| 401 | + exit={{ opacity: 0 }} |
| 402 | + transition={{ duration: 0.15 }} |
| 403 | + className="inline-flex" |
| 404 | + > |
| 405 | + <Icon svg={<IconSquare2StackedLine />} /> |
| 406 | + </m.span> |
| 407 | + )} |
| 408 | + </AnimatePresence> |
381 | 409 | </ActionButton> |
382 | 410 | </div> |
383 | 411 | )} |
|
0 commit comments