From f6938720bed75c49ff49e180348cc096744b2451 Mon Sep 17 00:00:00 2001 From: saml33 Date: Mon, 19 Apr 2021 11:58:16 +1000 Subject: [PATCH] connect wallet button to seperate componenet and secondary connect wallet button styling --- components/ConnectWalletButton.tsx | 44 ++++++++++++++++++++++++++++++ components/TopBar.tsx | 38 ++------------------------ components/TradeForm.tsx | 26 ++++++++++++------ components/WalletIcon.jsx | 25 ----------------- components/WalletSelect.tsx | 10 +++++-- 5 files changed, 71 insertions(+), 72 deletions(-) create mode 100644 components/ConnectWalletButton.tsx delete mode 100644 components/WalletIcon.jsx diff --git a/components/ConnectWalletButton.tsx b/components/ConnectWalletButton.tsx new file mode 100644 index 0000000..16fb5a9 --- /dev/null +++ b/components/ConnectWalletButton.tsx @@ -0,0 +1,44 @@ +import styled from '@emotion/styled' +import useMangoStore from '../stores/useMangoStore' +import { WALLET_PROVIDERS, DEFAULT_PROVIDER } from '../hooks/useWallet' +import useLocalStorageState from '../hooks/useLocalStorageState' +import WalletSelect from './WalletSelect' +import { WalletIcon } from './icons' + +const StyledWalletTypeLabel = styled.div` + font-size: 0.6rem; +` + +const ConnectWalletButton = () => { + const wallet = useMangoStore((s) => s.wallet.current) + const [savedProviderUrl] = useLocalStorageState( + 'walletProvider', + DEFAULT_PROVIDER.url + ) + + return ( +
+ +
+ +
+
+ ) +} + +export default ConnectWalletButton diff --git a/components/TopBar.tsx b/components/TopBar.tsx index 631583f..57bee27 100644 --- a/components/TopBar.tsx +++ b/components/TopBar.tsx @@ -14,10 +14,8 @@ import ThemeSwitch from './ThemeSwitch' import { WalletIcon } from './icons' import UiLock from './UiLock' import { useRouter } from 'next/router' -import WalletSelect from './WalletSelect' import useMangoStore from '../stores/useMangoStore' -import { WALLET_PROVIDERS, DEFAULT_PROVIDER } from '../hooks/useWallet' -import useLocalStorageState from '../hooks/useLocalStorageState' +import ConnectWalletButton from './ConnectWalletButton' const Code = styled.code` border: 1px solid hsla(0, 0%, 39.2%, 0.2); @@ -26,20 +24,12 @@ const Code = styled.code` font-size: 13px; ` -const StyledWalletTypeLabel = styled.div` - font-size: 0.6rem; -` - const TopBar = () => { const { asPath } = useRouter() const connected = useMangoStore((s) => s.wallet.connected) const wallet = useMangoStore((s) => s.wallet.current) const [showMenu, setShowMenu] = useState(false) const [isCopied, setIsCopied] = useState(false) - const [savedProviderUrl] = useLocalStorageState( - 'walletProvider', - DEFAULT_PROVIDER.url - ) useEffect(() => { if (isCopied) { @@ -132,31 +122,7 @@ const TopBar = () => { )} ) : ( -
- - {!connected && ( -
- -
- )} -
+ )} diff --git a/components/TradeForm.tsx b/components/TradeForm.tsx index a4b8fc8..e1fd97c 100644 --- a/components/TradeForm.tsx +++ b/components/TradeForm.tsx @@ -15,6 +15,8 @@ import Button from './Button' import TradeType from './TradeType' import Input from './Input' import Switch from './Switch' +import { WalletIcon } from './icons' +import WalletSelect from './WalletSelect' const StyledRightInput = styled(Input)` border-left: 1px solid transparent; @@ -304,14 +306,14 @@ export default function TradeForm() { ) : null} -
+
{ipAllowed ? ( connected ? ( side === 'buy' ? ( +
+ +
+ +
+
) ) : (