Skip to content

feat(app2): add tweet button #4493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions app2/src/lib/transfer/normal/steps/IndexStep.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import TransactionHashComponent from "$lib/components/model/TransactionHashCompo
import ErrorComponent from "$lib/components/model/ErrorComponent.svelte"
import SpinnerIcon from "$lib/components/icons/SpinnerIcon.svelte"
import type { WaitForIndex } from "$lib/transfer/normal/steps/steps.ts"
import TwitterIcon from "$lib/components/icons/TwitterIcon.svelte"

type Props = {
newTransfer: () => void
Expand All @@ -31,6 +32,18 @@ const handleRedirect = () => {
transferHashStore.reset()
}
}

const handleTweet = () => {
const packet = Option.isSome(transferHashStore.data) ? transferHashStore.data.value : ""
const transferUrl = `https://app.union.build/explorer/transfers${packet ? `/${packet}` : ""}`

const tweets = [
`Zkgm frens 🤠 Just bridged using ${transferUrl} — smooth like butter on hot cornbread. Yeehaw!\n\nHop on the BTCfi wagon. Bridge your assets with @union_build, stack Union points, and ride into the future of trustless interoperability.`
]

const tweetText = encodeURIComponent(tweets[Math.floor(Math.random() * tweets.length)])
window.open(`https://twitter.com/intent/tweet?text=${tweetText}`, "_blank")
}
</script>

<div class="min-w-full p-6 flex flex-col justify-between h-full">
Expand Down Expand Up @@ -69,9 +82,15 @@ const handleRedirect = () => {
</div>

<div class="flex flex-col justify-between gap-3 mt-6">
<Button onclick={newTransfer} variant="secondary">
New transfer
</Button>
<div class="flex w-full gap-3">
<Button onclick={newTransfer} variant="secondary" class="w-full">
New transfer
</Button>
<Button onclick={handleTweet} variant="secondary" class="w-full">
<span>Share on</span>
<TwitterIcon class="size-4 -ml-1"/>
</Button>
</div>
<Button onclick={handleRedirect} variant="primary">
Check on explorer
</Button>
Expand Down