-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
Copy pathConnectWalletButton.tsx
33 lines (28 loc) · 1.03 KB
/
ConnectWalletButton.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { Button, ButtonProps, FlexGap, WalletFilledV2Icon } from '@pancakeswap/uikit'
import { useCallback, useState } from 'react'
import WalletModalManager from 'components/WalletModalManager'
import Trans from './Trans'
interface ConnectWalletButtonProps extends ButtonProps {
withIcon?: boolean
}
const ConnectWalletButton = ({ children, withIcon, ...props }: ConnectWalletButtonProps) => {
const [open, setOpen] = useState(false)
const handleOnDismiss = useCallback(() => setOpen(false), [])
return (
<>
<Button onClick={() => setOpen(true)} {...props}>
<FlexGap gap="8px" justifyContent="center" alignItems="center">
{children || <Trans>Connect Wallet</Trans>} {withIcon && <WalletFilledV2Icon color="invertedContrast" />}
</FlexGap>
</Button>
<style jsx global>{`
w3m-modal {
position: relative;
z-index: 99;
}
`}</style>
<WalletModalManager isOpen={open} onDismiss={handleOnDismiss} />
</>
)
}
export default ConnectWalletButton