Commit 663171f3 authored by Max Alekseenko's avatar Max Alekseenko

fix tooltip

parent cb844b8a
...@@ -70,13 +70,13 @@ const WalletMenuDesktop = ({ isHomePage, className, size = 'md' }: Props) => { ...@@ -70,13 +70,13 @@ const WalletMenuDesktop = ({ isHomePage, className, size = 'md' }: Props) => {
isOpen={ isPopoverOpen } isOpen={ isPopoverOpen }
onClose={ setIsPopoverOpen.off } onClose={ setIsPopoverOpen.off }
> >
<Box ml={ 2 }>
<PopoverTrigger>
<WalletTooltip <WalletTooltip
isDisabled={ isMobile === undefined || isMobile } isDisabled={ isMobile === undefined || isMobile }
isWalletConnected={ isWalletConnected } isWalletConnected={ isWalletConnected }
isAutoConnectDisabled={ isAutoConnectDisabled } isAutoConnectDisabled={ isAutoConnectDisabled }
> >
<Box ml={ 2 }>
<PopoverTrigger>
<Button <Button
className={ className } className={ className }
variant={ variant } variant={ variant }
...@@ -96,9 +96,9 @@ const WalletMenuDesktop = ({ isHomePage, className, size = 'md' }: Props) => { ...@@ -96,9 +96,9 @@ const WalletMenuDesktop = ({ isHomePage, className, size = 'md' }: Props) => {
</> </>
) : 'Connect wallet' } ) : 'Connect wallet' }
</Button> </Button>
</WalletTooltip>
</PopoverTrigger> </PopoverTrigger>
</Box> </Box>
</WalletTooltip>
{ isWalletConnected && ( { isWalletConnected && (
<PopoverContent w="235px"> <PopoverContent w="235px">
<PopoverBody padding="24px 16px 16px 16px"> <PopoverBody padding="24px 16px 16px 16px">
......
import { Tooltip, useBoolean, useOutsideClick } from '@chakra-ui/react'; import { Tooltip, useBoolean, useOutsideClick, Box } from '@chakra-ui/react';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import React from 'react'; import React from 'react';
...@@ -15,11 +15,11 @@ type Props = { ...@@ -15,11 +15,11 @@ type Props = {
const LOCAL_STORAGE_KEY = 'wallet-connect-tooltip-shown'; const LOCAL_STORAGE_KEY = 'wallet-connect-tooltip-shown';
const WalletTooltip = ({ children, isDisabled, isMobile, isWalletConnected, isAutoConnectDisabled }: Props) => { const WalletTooltip = ({ children, isDisabled, isMobile, isWalletConnected, isAutoConnectDisabled }: Props, ref: React.ForwardedRef<HTMLDivElement>) => {
const router = useRouter(); const router = useRouter();
const [ isTooltipShown, setIsTooltipShown ] = useBoolean(false); const [ isTooltipShown, setIsTooltipShown ] = useBoolean(false);
const ref = React.useRef(null); const innerRef = React.useRef(null);
useOutsideClick({ ref, handler: setIsTooltipShown.off }); useOutsideClick({ ref: innerRef, handler: setIsTooltipShown.off });
const label = React.useMemo(() => { const label = React.useMemo(() => {
if (isWalletConnected) { if (isWalletConnected) {
...@@ -62,6 +62,7 @@ const WalletTooltip = ({ children, isDisabled, isMobile, isWalletConnected, isAu ...@@ -62,6 +62,7 @@ const WalletTooltip = ({ children, isDisabled, isMobile, isWalletConnected, isAu
}, [ setIsTooltipShown, isDisabled, router, isAppPage ]); }, [ setIsTooltipShown, isDisabled, router, isAppPage ]);
return ( return (
<Box ref={ ref }>
<Tooltip <Tooltip
label={ label } label={ label }
textAlign="center" textAlign="center"
...@@ -71,11 +72,12 @@ const WalletTooltip = ({ children, isDisabled, isMobile, isWalletConnected, isAu ...@@ -71,11 +72,12 @@ const WalletTooltip = ({ children, isDisabled, isMobile, isWalletConnected, isAu
isOpen={ isTooltipShown || (isMobile ? false : undefined) } isOpen={ isTooltipShown || (isMobile ? false : undefined) }
onClose={ setIsTooltipShown.off } onClose={ setIsTooltipShown.off }
display={ isMobile ? { base: 'flex', lg: 'none' } : { base: 'none', lg: 'flex' } } display={ isMobile ? { base: 'flex', lg: 'none' } : { base: 'none', lg: 'flex' } }
ref={ ref } ref={ innerRef }
> >
{ children } { children }
</Tooltip> </Tooltip>
</Box>
); );
}; };
export default WalletTooltip; export default React.forwardRef(WalletTooltip);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment