Skip to content

Commit

Permalink
only share if sharable
Browse files Browse the repository at this point in the history
  • Loading branch information
skedwards88 committed Apr 21, 2024
1 parent d1d860d commit 705e04a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/components/Heart.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function Heart({setDisplay}) {
<div className="heartText">
{"Like this game? Share it with your friends.\n\n"}
{<Share text={"Check out this logic grid game!"}></Share>}
{`\n\n`}
{`\n`}
{<hr></hr>}
{`\n`}
{`Want more games? Check `}
Expand Down
12 changes: 1 addition & 11 deletions src/components/Share.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,10 @@ function handleShare(text) {
sendAnalytics("share");
}

function handleCopy(text) {
try {
navigator.clipboard.writeText(
`${text}\n\nhttps://skedwards88.github.io/logic-grid/`,
);
} catch (error) {
console.log(error);
}
}

export default function Share({text}) {
if (navigator.canShare) {
return <button onClick={() => handleShare(text)}>Share</button>;
} else {
return <button onClick={() => handleCopy(text)}>Copy sharing link</button>;
return <></>;
}
}

0 comments on commit 705e04a

Please sign in to comment.