Skip to content

Commit

Permalink
feat(frontend): add browser wallet icons (sifiorg#369)
Browse files Browse the repository at this point in the history
* dependencies: upgrade shared-ui version

* feat: use wallet icons and name in connection modal

* feat: use wallet icon in header menu
  • Loading branch information
immutablegoblin authored Oct 25, 2023
1 parent 6e0052d commit 7f5841a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@headlessui/react": "^1.7.4",
"@heroicons/react": "^2.0.12",
"@sifi/sdk": "^1.9.0",
"@sifi/shared-ui": "^1.8.1",
"@sifi/shared-ui": "^1.8.3",
"@tanstack/react-query": "^4.13.0",
"@types/three": "^0.127.1",
"@uniswap/permit2-sdk": "^1.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type FunctionComponent, useState, useEffect } from 'react';
import { Modal, showToast, WalletOption } from '@sifi/shared-ui';
import { Modal, showToast, WalletOption, useWalletBranding } from '@sifi/shared-ui';
import useConnectWallet from 'src/hooks/useConnectWallet';
import { type SupportedWallet } from 'src/connectors';
import { getViemErrorMessage } from 'src/utils';
Expand All @@ -17,6 +17,7 @@ const ConnectWalletModal: FunctionComponent<ConnectWalletModalProps> = ({
closeModal,
}: ConnectWalletModalProps) => {
const { connectWallet, error } = useConnectWallet();
const { text: injectedWalletText, icon: injectedWalletIcon } = useWalletBranding();

useEffect(() => {
if (error) {
Expand All @@ -29,11 +30,11 @@ const ConnectWalletModal: FunctionComponent<ConnectWalletModalProps> = ({
<div className="pb-6">
{supportedWallets.map(wallet => (
<WalletOption
// Todo(Nathan): Make this dynamic
injectedWalletName={wallet === 'injected' ? 'MetaMask' : undefined}
key={wallet}
walletOption={wallet}
activate={() => connectWallet(wallet)}
injectedWalletName={wallet === 'injected' ? injectedWalletText : undefined}
injectedWalletIcon={wallet === 'injected' ? injectedWalletIcon : undefined}
/>
))}
</div>
Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/src/components/HeaderMenu/HeaderMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionComponent } from 'react';
import { Menu } from '@sifi/shared-ui';
import { Menu, useWalletBranding } from '@sifi/shared-ui';
import { useAccount, useDisconnect, useEnsName, useNetwork } from 'wagmi';
import { formatAddress, formatEnsName } from 'src/utils';

Expand All @@ -8,6 +8,7 @@ const HeaderMenu: FunctionComponent = () => {
const { data: ensName } = useEnsName({ address });
const { chain } = useNetwork();
const { disconnect } = useDisconnect();
const { icon, text } = useWalletBranding();

if (!address || !isConnected) return null;

Expand All @@ -21,7 +22,7 @@ const HeaderMenu: FunctionComponent = () => {
];

return (
<Menu label={label} links={menuLinks}>
<Menu icon={icon ? { src: icon, alt: `${text} icon`} : undefined} label={label} links={menuLinks}>
<div className="px-6 py-4">
<span className="mb-3 block text-sm" id="network-label">
Network
Expand Down
39 changes: 18 additions & 21 deletions pnpm-lock.yaml

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

0 comments on commit 7f5841a

Please sign in to comment.