From c2a170f7c0fcee1365527e5658eaafd7e2d9cfb3 Mon Sep 17 00:00:00 2001 From: Mycroft Kang Date: Sun, 25 Feb 2024 17:38:45 +0900 Subject: [PATCH] Add share button --- public/share.svg | 1 + src/lib/suikaGame/gameOverModal/index.tsx | 5 ++++ src/lib/suikaGame/index.module.scss | 6 +++++ src/lib/suikaGame/index.tsx | 31 +++++++++++++++++++++++ src/lib/suikaGame/intro/index.tsx | 2 +- 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 public/share.svg diff --git a/public/share.svg b/public/share.svg new file mode 100644 index 0000000..9acd1ba --- /dev/null +++ b/public/share.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/lib/suikaGame/gameOverModal/index.tsx b/src/lib/suikaGame/gameOverModal/index.tsx index 9ce358a..2ea82a4 100644 --- a/src/lib/suikaGame/gameOverModal/index.tsx +++ b/src/lib/suikaGame/gameOverModal/index.tsx @@ -72,6 +72,11 @@ const GameOverModal = ({ isVisible, onClick, score }: GameOverModalProps) => { return (
+
+ +
GAME OVER SCORE: {score}
diff --git a/src/lib/suikaGame/index.module.scss b/src/lib/suikaGame/index.module.scss index 0b0ebc4..41c5618 100644 --- a/src/lib/suikaGame/index.module.scss +++ b/src/lib/suikaGame/index.module.scss @@ -42,3 +42,9 @@ cursor: pointer; } } + +// @media screen and (max-height: 739px) and (max-width: 484px) { +// .shareButton { +// display: none; +// } +// } diff --git a/src/lib/suikaGame/index.tsx b/src/lib/suikaGame/index.tsx index 78c2faf..e8ef08e 100644 --- a/src/lib/suikaGame/index.tsx +++ b/src/lib/suikaGame/index.tsx @@ -116,8 +116,39 @@ const SuikaGame = () => { return score > bestScore ? score : bestScore; } + const share = () => { + if (navigator.share) { + navigator.share({ + title: '수박 만들기 게임', + text: '폭탄과 과일들을 모아 수박을 만들어보세요.', + url: 'https://game.mulgyeol.com/', + }) + .then(() => console.log('done')) + .catch((error) => console.log(error)); + } else { + const urlToCopy = window.location.href; + + // Clipboard API를 지원하는지 확인 + if (document.queryCommandSupported("copy")) { + const input = document.createElement("input"); + input.value = urlToCopy; + document.body.appendChild(input); + input.select(); + document.execCommand("copy"); + document.body.removeChild(input); + } else { + navigator.clipboard.writeText(urlToCopy) + } + } + } + return (
+
+ +
diff --git a/src/lib/suikaGame/intro/index.tsx b/src/lib/suikaGame/intro/index.tsx index d3e4377..ab0af14 100644 --- a/src/lib/suikaGame/intro/index.tsx +++ b/src/lib/suikaGame/intro/index.tsx @@ -181,7 +181,7 @@ const Intro = ({isVisible, loadUserInfo,handleGameStart, handleShowRankModal}: I 홈 또는 앱스 화면에 바로가기를 추가하려면 크롬에서 계속하세요. {/* */} - 크롬에서 열기 + 크롬에서 열기