Skip to content

Commit 12cb10e

Browse files
authored
Merge pull request #99 from boostcampwm-2022/feat/#98-B
Feat/#98-B: 클립보드 복사 버튼 구현
2 parents 8c4a5ca + 61495b0 commit 12cb10e

File tree

1 file changed

+21
-0
lines changed
  • client/src/components/common/CopyButton

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { BiCopy } from '@react-icons/all-files/bi/BiCopy';
2+
3+
interface CopyButtonProps {
4+
target: string;
5+
className?: string;
6+
}
7+
8+
function CopyButton({ target, className }: CopyButtonProps) {
9+
const onCopy = async () => {
10+
try {
11+
await navigator.clipboard.writeText(target);
12+
alert('참여 코드가 복사되었습니다.');
13+
} catch (e) {
14+
alert('실패');
15+
}
16+
};
17+
18+
return <BiCopy className={className} onClick={onCopy} />;
19+
}
20+
21+
export default CopyButton;

0 commit comments

Comments
 (0)