Skip to content

Commit b4983a7

Browse files
committed
feat: add ShareModal to Start with Crypto page
1 parent 47d0c73 commit b4983a7

File tree

2 files changed

+77
-9
lines changed

2 files changed

+77
-9
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { useState } from "react"
2+
import { FaLink, FaXTwitter } from "react-icons/fa6"
3+
import { MdCheck } from "react-icons/md"
4+
5+
import { Button } from "@/components/ui/buttons/Button"
6+
import {
7+
Dialog,
8+
DialogContent,
9+
DialogDescription,
10+
DialogHeader,
11+
DialogTitle,
12+
DialogTrigger,
13+
} from "@/components/ui/dialog-modal"
14+
15+
import { useClipboard } from "@/hooks/useClipboard"
16+
17+
export const shareOnTwitter = (): void => {
18+
const url = "https://ethereum.org/start"
19+
const hashtags = ["ethereum", "web3", "startwithethereum"]
20+
const tweet = `${encodeURI(`I connected to ethereum on ethereum.org! Try it yourself at ${url}`)}`
21+
22+
window.open(
23+
`https://twitter.com/intent/tweet?text=${tweet}&hashtags=${hashtags}`
24+
)
25+
}
26+
27+
const ShareModal = () => {
28+
const [isOpen, setIsOpen] = useState(false)
29+
const { onCopy, hasCopied } = useClipboard()
30+
31+
return (
32+
<Dialog open={isOpen} onOpenChange={setIsOpen}>
33+
<DialogTrigger>
34+
<Button>Share this page</Button>
35+
</DialogTrigger>
36+
<DialogContent>
37+
<DialogHeader>
38+
<DialogTitle>Share this page</DialogTitle>
39+
</DialogHeader>
40+
<DialogDescription>
41+
Share this page with your friends and family.
42+
</DialogDescription>
43+
<div className="flex flex-row justify-center">
44+
<Button
45+
onClick={() => onCopy(window.location.href)}
46+
variant="ghost"
47+
className="flex flex-col hover:bg-background-highlight"
48+
>
49+
{hasCopied ? (
50+
<>
51+
<MdCheck />
52+
<p className="text-sm">Copied!</p>
53+
</>
54+
) : (
55+
<>
56+
<FaLink />
57+
<p className="text-sm">Share</p>
58+
</>
59+
)}
60+
</Button>
61+
<Button
62+
variant="ghost"
63+
className="flex flex-col hover:bg-background-highlight"
64+
onClick={() => shareOnTwitter()}
65+
>
66+
<FaXTwitter />
67+
<p className="text-sm">Twitter</p>
68+
</Button>
69+
</div>
70+
</DialogContent>
71+
</Dialog>
72+
)
73+
}
74+
75+
export default ShareModal

src/pages/[locale]/start/index.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Image } from "@/components/Image"
66
import MainArticle from "@/components/MainArticle"
77
import PageMetadata from "@/components/PageMetadata"
88
import StartWithEthereumFlow from "@/components/StartWithEthereumFlow"
9-
import { ButtonLink } from "@/components/ui/buttons/Button"
9+
import ShareModal from "@/components/StartWithEthereumFlow/ShareModal"
1010

1111
import { existsNamespace } from "@/lib/utils/existsNamespace"
1212
import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
@@ -89,15 +89,8 @@ const StartWithCryptoPage = () => {
8989
Billions can’t open bank accounts or freely use their money.
9090
Ethereum’s financial system is always open and unbiased.
9191
</p>
92-
{/* TODO: Add share button */}
9392
<div className="flex w-full md:w-auto">
94-
<ButtonLink
95-
href="/start-with-crypto/onboarding-guide"
96-
variant="outline"
97-
className="w-full md:w-auto"
98-
>
99-
Share this page
100-
</ButtonLink>
93+
<ShareModal />
10194
</div>
10295
</div>
10396
<div className="flex max-w-[450px] flex-col items-center justify-center">

0 commit comments

Comments
 (0)