Skip to content

Commit

Permalink
feat: add fallback link for uninstalled wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
totraev committed Dec 19, 2024
1 parent 571711d commit e05222f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/tasty-scissors-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@babylonlabs-io/bbn-wallet-connect": patch
---

add fallback link
13 changes: 6 additions & 7 deletions package-lock.json

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

19 changes: 15 additions & 4 deletions src/components/WalletButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,31 @@ interface WalletButtonProps {
disabled?: boolean;
name: string;
label?: string;
fallbackLink?: string;
installed?: boolean;
onClick?: () => void;
}

export function WalletButton({ className, disabled = false, name, logo, label, onClick }: WalletButtonProps) {
export function WalletButton({
className,
disabled = false,
name,
logo,
label,
fallbackLink,
installed = true,
onClick,
}: WalletButtonProps) {
const btnProps = installed ? { as: "button", disabled, onClick } : { as: "a", href: fallbackLink, target: "_blank" };

return (
<Text
disabled={disabled}
as="button"
className={twMerge(
"b-flex b-h-14 b-w-full b-cursor-pointer b-items-center b-gap-2.5 b-rounded b-border b-border-primary-main/30 b-px-2",
disabled ? "b-cursor-default" : "b-cursor-pointer",
className,
)}
onClick={onClick}
{...btnProps}
>
<Avatar variant="rounded" className="b-shrink-0" alt={name} url={logo} />
{name}
Expand Down
20 changes: 20 additions & 0 deletions src/components/Wallets/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ const wallets: IWallet[] = [
account: null,
label: "Hardware wallet",
},
{
id: "keystone",
name: "Keysone",
installed: true,
icon: "/images/wallets/keystone.svg",
docs: "",
provider: null,
account: null,
label: "Hardware wallet",
},
{
id: "tomo",
name: "Tomo wallet",
installed: false,
icon: "/images/wallets/tomo.png",
docs: "https://docs.tomo.inc/",
provider: null,
account: null,
label: "",
},
];

export const Default: Story = {
Expand Down
3 changes: 3 additions & 0 deletions src/components/Wallets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const Wallets = memo(({ chain, className, append, onClose, onBack, onSele
<div className={twMerge("b-grid b-gap-6", countOfVisibleWallets > 1 ? "b-grid-cols-2" : "b-grid-cols-1")}>
{injectableWallet && (
<WalletButton
installed
name={injectableWallet.name}
logo={injectableWallet.icon}
label={injectableWallet.label}
Expand All @@ -44,10 +45,12 @@ export const Wallets = memo(({ chain, className, append, onClose, onBack, onSele

{wallets.map((wallet) => (
<WalletButton
installed={wallet.installed}
key={wallet.id}
name={wallet.name}
logo={wallet.icon}
label={wallet.label}
fallbackLink={wallet.docs}
onClick={() => onSelectWallet?.(chain, wallet)}
/>
))}
Expand Down

0 comments on commit e05222f

Please sign in to comment.