Commit 82cc270e authored by Max Alekseenko's avatar Max Alekseenko

add new text for wallet button tooltip

parent 0f257b42
import { Tooltip, useBoolean } from '@chakra-ui/react'; import { Tooltip, useBoolean } from '@chakra-ui/react';
import { useRouter } from 'next/router';
import React from 'react'; import React from 'react';
type Props = { type Props = {
...@@ -8,20 +9,31 @@ type Props = { ...@@ -8,20 +9,31 @@ type Props = {
}; };
const WalletTooltip = ({ children, isDisabled, isMobile }: Props) => { const WalletTooltip = ({ children, isDisabled, isMobile }: Props) => {
const router = useRouter();
const [ isTooltipShown, setIsTooltipShown ] = useBoolean(false); const [ isTooltipShown, setIsTooltipShown ] = useBoolean(false);
const { defaultLabel, label, localStorageKey } = React.useMemo(() => {
const isAppPage = router.pathname === '/apps/[id]';
const defaultLabel = <span>Your wallet is used to interact with<br/>apps and contracts in the explorer</span>;
const label = isAppPage ?
<span>Connect once to use your wallet with<br/>all apps in the DAppscout marketplace!</span> :
defaultLabel;
const localStorageKey = `${ isAppPage ? 'dapp-' : '' }wallet-connect-tooltip-shown-${ isMobile ? 'mobile' : 'desktop' }`;
return { defaultLabel, label, localStorageKey };
}, [ router.pathname, isMobile ]);
React.useEffect(() => { React.useEffect(() => {
const key = `wallet-connect-tooltip-shown-${ isMobile ? 'mobile' : 'desktop' }`; const wasShown = window.localStorage.getItem(localStorageKey);
const wasShown = window.localStorage.getItem(key);
if (!wasShown) { if (!wasShown) {
setIsTooltipShown.on(); setIsTooltipShown.on();
window.localStorage.setItem(key, 'true'); window.localStorage.setItem(localStorageKey, 'true');
setTimeout(() => setIsTooltipShown.off(), 3000);
} }
}, [ setIsTooltipShown, isMobile ]); }, [ setIsTooltipShown, localStorageKey ]);
return ( return (
<Tooltip <Tooltip
label={ <span>Your wallet is used to interact with<br/>apps and contracts in the explorer</span> } label={ isTooltipShown ? label : defaultLabel }
textAlign="center" textAlign="center"
padding={ 2 } padding={ 2 }
isDisabled={ isDisabled } isDisabled={ isDisabled }
......
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