From 821ccfe06fd67e18592b24d31c7b23a725b697fa Mon Sep 17 00:00:00 2001 From: hugolxt <87241914+hugolxt@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:03:13 +0100 Subject: [PATCH] Fix/preprod (#30) * fix: update fallback prop for Image component in WalletConnectors * fix: update Tooltip component styles for improved layout and responsiveness * Sort wallets and add icons for walletconnect and coinbase * lint --------- Signed-off-by: hugolxt <87241914+hugolxt@users.noreply.github.com> --- src/assets/walletCoinbase.svg | 4 +++ src/assets/walletConnect.svg | 20 +++++++++++ src/components/dapp/WalletConnectors.tsx | 45 ++++++++++++++++++++++-- src/components/primitives/Tooltip.tsx | 6 ++-- 4 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 src/assets/walletCoinbase.svg create mode 100644 src/assets/walletConnect.svg diff --git a/src/assets/walletCoinbase.svg b/src/assets/walletCoinbase.svg new file mode 100644 index 000000000..c47fdf94b --- /dev/null +++ b/src/assets/walletCoinbase.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/assets/walletConnect.svg b/src/assets/walletConnect.svg new file mode 100644 index 000000000..64b078c4f --- /dev/null +++ b/src/assets/walletConnect.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + diff --git a/src/components/dapp/WalletConnectors.tsx b/src/components/dapp/WalletConnectors.tsx index 634666555..05d009926 100644 --- a/src/components/dapp/WalletConnectors.tsx +++ b/src/components/dapp/WalletConnectors.tsx @@ -1,3 +1,7 @@ +import { useMemo } from "react"; +import type { Connector } from "wagmi"; +import walletCoinbaseIcon from "../../assets/walletCoinbase.svg"; +import walletConnectIcon from "../../assets/walletConnect.svg"; import { useWalletContext } from "../../context/Wallet.context"; import Group from "../extenders/Group"; import Button from "../primitives/Button"; @@ -10,20 +14,44 @@ import Text from "../primitives/Text"; export default function WalletConnectors() { const { config, connect, connector: _connected } = useWalletContext(); + const sortedConnectors = useMemo( + () => + [...config.connectors].sort((a, b) => { + const priority = (connector: Connector) => { + switch (connector.name.toLowerCase()) { + case "metamask": + return 0; + case "rabby wallet": + return 1; + case "walletconnect": + return 2; + default: + return 3; + } + }; + return priority(a) - priority(b); + }), + [config.connectors], + ); + return (
- {config.connectors.map(connector => { + {sortedConnectors.map(connector => { return ( @@ -38,3 +66,14 @@ export default function WalletConnectors() { ); } + +const overrideIcons = (connector: Connector) => { + switch (connector.name.toLowerCase()) { + case "coinbase wallet": + return walletCoinbaseIcon; + case "walletconnect": + return walletConnectIcon; + default: + return connector.icon; + } +}; diff --git a/src/components/primitives/Tooltip.tsx b/src/components/primitives/Tooltip.tsx index 5e3995f1a..2f4a1ada0 100644 --- a/src/components/primitives/Tooltip.tsx +++ b/src/components/primitives/Tooltip.tsx @@ -16,7 +16,7 @@ export default function Tooltip({ helper, children, icon = true }: TooltipProps) - +
{children}
{!!icon && }
@@ -24,9 +24,9 @@ export default function Tooltip({ helper, children, icon = true }: TooltipProps) - + {helper}