Skip to content

Commit 2d7d9b4

Browse files
committed
fix UI after switching to useChain
1 parent e70c057 commit 2d7d9b4

File tree

1 file changed

+40
-39
lines changed

1 file changed

+40
-39
lines changed

examples/stake-tokens/components/wallet.tsx

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import {
66
GridItem,
77
Icon,
88
Stack,
9-
useColorModeValue,
10-
Text,
9+
useColorMode,
1110
} from '@chakra-ui/react';
1211
import { MouseEventHandler, useEffect, useMemo, useState } from 'react';
1312
import { FiAlertTriangle } from 'react-icons/fi';
@@ -29,6 +28,7 @@ import {
2928
ChainCard,
3029
ChooseChain,
3130
ChainOption,
31+
ConnectWalletButton,
3232
} from '../components';
3333
import { defaultChainName } from '../config';
3434
import { ChainName } from '@cosmos-kit/core';
@@ -52,14 +52,14 @@ export const WalletSection = ({
5252
message,
5353
wallet,
5454
chain: chainInfo,
55-
logoUrl,
5655
} = useChain(providedChainName || defaultChainName);
56+
const { colorMode } = useColorMode();
5757

5858
const chain = {
59-
chainName: providedChainName,
59+
chainName: defaultChainName,
6060
label: chainInfo.pretty_name,
61-
value: providedChainName,
62-
icon: logoUrl,
61+
value: defaultChainName,
62+
icon: getChainLogo(defaultChainName),
6363
};
6464

6565
const chainOptions = useMemo(
@@ -124,9 +124,7 @@ export const WalletSection = ({
124124
);
125125

126126
useEffect(() => {
127-
setChainName?.(
128-
window.localStorage.getItem('selected-chain') || 'cosmoshub'
129-
);
127+
setChainName?.(window.localStorage.getItem('selected-chain') || 'osmosis');
130128
}, [setChainName]);
131129

132130
const onChainChange: handleSelectChainDropdown = async (
@@ -171,37 +169,40 @@ export const WalletSection = ({
171169
{isMultiChain ? (
172170
<GridItem>{chooseChain}</GridItem>
173171
) : (
174-
providedChainName && (
175-
<GridItem marginBottom={'20px'}>
176-
<ChainCard
177-
prettyName={chain?.label || providedChainName}
178-
icon={chain?.icon}
179-
/>
180-
</GridItem>
181-
)
172+
<GridItem marginBottom={'20px'}>
173+
<ChainCard
174+
prettyName={chain?.label || defaultChainName}
175+
icon={chain?.icon}
176+
/>
177+
</GridItem>
178+
)}
179+
{!providedChainName && isMultiChain ? (
180+
<ConnectWalletButton buttonText={'Connect Wallet'} isDisabled />
181+
) : (
182+
<GridItem px={6}>
183+
<Stack
184+
justifyContent="center"
185+
alignItems="center"
186+
borderRadius="lg"
187+
bg={colorMode === 'light' ? 'white' : 'blackAlpha.400'}
188+
boxShadow={
189+
colorMode === 'light'
190+
? '0 0 2px #dfdfdf, 0 0 6px -2px #d3d3d3'
191+
: '0 0 2px #363636, 0 0 8px -2px #4f4f4f'
192+
}
193+
spacing={4}
194+
px={4}
195+
py={{ base: 6, md: 12 }}
196+
>
197+
{userInfo}
198+
{addressBtn}
199+
<Box w="full" maxW={{ base: 52, md: 64 }}>
200+
{connectWalletButton}
201+
</Box>
202+
{connectWalletWarn && <GridItem>{connectWalletWarn}</GridItem>}
203+
</Stack>
204+
</GridItem>
182205
)}
183-
<GridItem px={6}>
184-
<Stack
185-
justifyContent="center"
186-
alignItems="center"
187-
borderRadius="lg"
188-
bg={useColorModeValue('white', 'blackAlpha.400')}
189-
boxShadow={useColorModeValue(
190-
'0 0 2px #dfdfdf, 0 0 6px -2px #d3d3d3',
191-
'0 0 2px #363636, 0 0 8px -2px #4f4f4f'
192-
)}
193-
spacing={4}
194-
px={4}
195-
py={{ base: 6, md: 12 }}
196-
>
197-
{userInfo}
198-
{addressBtn}
199-
<Box w="full" maxW={{ base: 52, md: 64 }}>
200-
{connectWalletButton}
201-
</Box>
202-
{connectWalletWarn && <GridItem>{connectWalletWarn}</GridItem>}
203-
</Stack>
204-
</GridItem>
205206
</Grid>
206207
</Center>
207208
);

0 commit comments

Comments
 (0)