2021-04-25 08:03:30 -07:00
|
|
|
import styled from '@emotion/styled'
|
|
|
|
import useWalletStore from '../stores/useWalletStore'
|
|
|
|
import { WALLET_PROVIDERS, DEFAULT_PROVIDER } from '../hooks/useWallet'
|
|
|
|
import useLocalStorageState from '../hooks/useLocalStorageState'
|
|
|
|
import WalletSelect from './WalletSelect'
|
|
|
|
import WalletIcon from './WalletIcon'
|
|
|
|
|
|
|
|
const StyledWalletTypeLabel = styled.div`
|
|
|
|
font-size: 0.6rem;
|
|
|
|
`
|
|
|
|
|
|
|
|
const ConnectWalletButton = () => {
|
|
|
|
const wallet = useWalletStore((s) => s.current)
|
|
|
|
const [savedProviderUrl] = useLocalStorageState(
|
|
|
|
'walletProvider',
|
|
|
|
DEFAULT_PROVIDER.url
|
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
2021-04-27 06:47:52 -07:00
|
|
|
<div className="flex justify-between border border-primary rounded-md h-11 w-48">
|
2021-04-25 08:03:30 -07:00
|
|
|
<button
|
|
|
|
onClick={() => wallet.connect()}
|
|
|
|
disabled={!wallet}
|
2021-04-27 06:47:52 -07:00
|
|
|
className="text-primary hover:text-fgd-1 focus:outline-none disabled:text-fgd-4 disabled:cursor-wait"
|
2021-04-25 08:03:30 -07:00
|
|
|
>
|
2021-04-27 06:47:52 -07:00
|
|
|
<div className="flex flex-row items-center px-2 justify-center h-full rounded-l default-transition hover:bg-primary hover:text-fgd-1">
|
2021-04-25 08:03:30 -07:00
|
|
|
<WalletIcon className="w-5 h-5 mr-3 fill-current" />
|
|
|
|
<div>
|
|
|
|
<span className="whitespace-nowrap">Connect Wallet</span>
|
2021-04-27 06:47:52 -07:00
|
|
|
<StyledWalletTypeLabel className="font-normal text-fgd-1 text-left leading-3">
|
2021-04-25 08:03:30 -07:00
|
|
|
{WALLET_PROVIDERS.filter((p) => p.url === savedProviderUrl).map(
|
|
|
|
({ name }) => name
|
|
|
|
)}
|
|
|
|
</StyledWalletTypeLabel>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
<div className="relative h-full">
|
|
|
|
<WalletSelect isPrimary />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ConnectWalletButton
|