Skip to content

Commit

Permalink
fat: mini app button (wevm#500)
Browse files Browse the repository at this point in the history
* feat: mini-app deeplink

* chore: changesets
  • Loading branch information
dalechyn authored Oct 12, 2024
1 parent 4e7d5e3 commit 753c8fd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/sixty-olives-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frog": patch
---

Added a `Button.MiniApp` to deeplink to a mini-app.
29 changes: 29 additions & 0 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const buttonPrefix = {
addComposerAction: '_b',
link: '_l',
mint: '_m',
miniApp: '_n',
redirect: '_r',
reset: '_c',
transaction: '_t',
Expand Down Expand Up @@ -90,6 +91,33 @@ export function ButtonLink({
] as unknown as HtmlEscapedString
}

export type ButtonMiniAppProps = ButtonProps & {
href: string
prompt?: boolean
}

ButtonMiniApp.__type = 'button'
export function ButtonMiniApp({
children,
// @ts-ignore - private
index = 1,
href,
prompt,
}: ButtonMiniAppProps) {
return [
<meta
property={`fc:frame:button:${index}`}
content={normalizeChildren(children)}
data-value={buttonPrefix.miniApp}
/>,
<meta property={`fc:frame:button:${index}:action`} content="link" />,
<meta
property={`fc:frame:button:${index}:target`}
content={`https://warpcast.com/~/composer-action?url=${encodeURIComponent(href)}${prompt ? '&view=prompt' : ''}`}
/>,
] as unknown as HtmlEscapedString
}

export type ButtonMintProps = ButtonProps & {
target: string
}
Expand Down Expand Up @@ -214,6 +242,7 @@ export function ButtonSignature({
export const Button = Object.assign(ButtonRoot, {
AddCastAction: ButtonAddCastAction,
Link: ButtonLink,
MiniApp: ButtonMiniApp,
Mint: ButtonMint,
Redirect: ButtonRedirect,
Reset: ButtonReset,
Expand Down

0 comments on commit 753c8fd

Please sign in to comment.