Skip to content

Commit

Permalink
🔥 Remove react-share and open x on a new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
bal7hazar committed Jan 13, 2025
1 parent 2ffdb03 commit 14e2dac
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 50 deletions.
1 change: 0 additions & 1 deletion packages/profile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"react-hook-form": "^7.53.2",
"react-query": "^3.39.2",
"react-router-dom": "^6.27.0",
"react-share": "^5.1.2",
"sonner": "^1.4.41",
"starknet": "^6.11.0",
"viem": "^2.21.32",
Expand Down
42 changes: 23 additions & 19 deletions packages/profile/src/components/achievements/trophy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { useArcade } from "@/hooks/arcade";
import { useConnection } from "@/hooks/context";
import { useAccount } from "@/hooks/account";
import { addAddressPadding } from "starknet";
import { TwitterShareButton } from "react-share";
import { GameModel } from "@bal7hazar/arcade-sdk";

export interface Task {
Expand Down Expand Up @@ -407,30 +406,35 @@ function Share({
});
}, [timestamp]);

if (!url || !xhandle) return null;

return (
<TwitterShareButton
className="grow"
url={url}
title={`I got a new achievement in @${xhandle} game 🧩
const handleShare = useCallback(() => {
if (!url || !xhandle) return;
const content = `I got a new achievement in @${xhandle} game 🏆
${title}
Points: ${earning}
At: ${date}
Think you can get it as well? Join the game ${url}
Play now 👇
`}
Play now 👇`;

const twitterUrl = `https://x.com/intent/tweet?text=${encodeURIComponent(
content,
)}&url=${encodeURIComponent(url)}`;

window.open(twitterUrl, "_blank", "noopener,noreferrer");
}, [url, xhandle, title, earning, date]);

if (!url || !xhandle) return null;

return (
<div
className={cn(
"grow bg-secondary p-2 flex items-center transition-all duration-200 hover:opacity-90 hover:cursor-pointer",
)}
onClick={handleShare}
>
<div
className={cn(
"bg-secondary h-full p-2 flex items-center transition-all duration-200 hover:opacity-90 hover:cursor-pointer",
)}
>
<XIcon size="sm" />
</div>
</TwitterShareButton>
<XIcon size="sm" />
</div>
);
}
30 changes: 0 additions & 30 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 14e2dac

Please sign in to comment.