Commit 1cf91f6a authored by Max Alekseenko's avatar Max Alekseenko

move get gas button to top bar

parent fdf70b1e
import { Image } from '@chakra-ui/react'; import { Image, Box } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import { route } from 'nextjs-routes'; import { route } from 'nextjs-routes';
import config from 'configs/app'; import config from 'configs/app';
import useIsMobile from 'lib/hooks/useIsMobile';
import * as mixpanel from 'lib/mixpanel/index'; import * as mixpanel from 'lib/mixpanel/index';
import LinkExternal from 'ui/shared/links/LinkExternal'; import LinkExternal from 'ui/shared/links/LinkExternal';
import LinkInternal from 'ui/shared/links/LinkInternal'; import LinkInternal from 'ui/shared/links/LinkInternal';
import TextSeparator from 'ui/shared/TextSeparator';
const getGasFeature = config.features.getGasButton; const getGasFeature = config.features.getGasButton;
const GetGasButton = () => { const GetGasButton = () => {
const isMobile = useIsMobile(false);
const onGetGasClick = React.useCallback(() => { const onGetGasClick = React.useCallback(() => {
mixpanel.logEvent(mixpanel.EventTypes.BUTTON_CLICK, { Content: 'Get gas', Source: 'address' }); mixpanel.logEvent(mixpanel.EventTypes.BUTTON_CLICK, { Content: 'Get gas', Source: 'address' });
}, []); }, []);
if (getGasFeature.isEnabled) { if (getGasFeature.isEnabled && !isMobile) {
try { try {
const dappId = getGasFeature.dappId; const dappId = getGasFeature.dappId;
const urlObj = new URL(getGasFeature.url); const urlObj = new URL(getGasFeature.url);
...@@ -32,12 +34,12 @@ const GetGasButton = () => { ...@@ -32,12 +34,12 @@ const GetGasButton = () => {
return ( return (
<> <>
<TextSeparator mx={ 2 } color="gray.500"/> <Box h="1px" w="8px" bg="divider" mx={ 1 }/>
<Link <Link
href={ href } href={ href }
display="flex" display="flex"
alignItems="center" alignItems="center"
fontSize="sm" fontSize="xs"
lineHeight={ 5 } lineHeight={ 5 }
onClick={ onGetGasClick } onClick={ onGetGasClick }
> >
...@@ -45,10 +47,8 @@ const GetGasButton = () => { ...@@ -45,10 +47,8 @@ const GetGasButton = () => {
<Image <Image
src={ getGasFeature.logoUrl } src={ getGasFeature.logoUrl }
alt={ getGasFeature.name } alt={ getGasFeature.name }
boxSize={ 5 } boxSize="14px"
mr={ 2 } mr={ 1 }
borderRadius="4px"
overflow="hidden"
/> />
) } ) }
{ getGasFeature.name } { getGasFeature.name }
......
...@@ -10,6 +10,8 @@ import GasInfoTooltip from 'ui/shared/gas/GasInfoTooltip'; ...@@ -10,6 +10,8 @@ import GasInfoTooltip from 'ui/shared/gas/GasInfoTooltip';
import GasPrice from 'ui/shared/gas/GasPrice'; import GasPrice from 'ui/shared/gas/GasPrice';
import TextSeparator from 'ui/shared/TextSeparator'; import TextSeparator from 'ui/shared/TextSeparator';
import GetGasButton from './GetGasButton';
const TopBarStats = () => { const TopBarStats = () => {
const isMobile = useIsMobile(); const isMobile = useIsMobile();
...@@ -76,14 +78,17 @@ const TopBarStats = () => { ...@@ -76,14 +78,17 @@ const TopBarStats = () => {
) } ) }
{ data?.coin_price && config.features.gasTracker.isEnabled && <TextSeparator color="divider"/> } { data?.coin_price && config.features.gasTracker.isEnabled && <TextSeparator color="divider"/> }
{ data?.gas_prices && data.gas_prices.average !== null && config.features.gasTracker.isEnabled && ( { data?.gas_prices && data.gas_prices.average !== null && config.features.gasTracker.isEnabled && (
<Skeleton isLoaded={ !isPlaceholderData }> <>
<chakra.span color="text_secondary">Gas </chakra.span> <Skeleton isLoaded={ !isPlaceholderData }>
<GasInfoTooltip data={ data } dataUpdatedAt={ dataUpdatedAt } placement={ !data?.coin_price ? 'bottom-start' : undefined }> <chakra.span color="text_secondary">Gas </chakra.span>
<Link> <GasInfoTooltip data={ data } dataUpdatedAt={ dataUpdatedAt } placement={ !data?.coin_price ? 'bottom-start' : undefined }>
<GasPrice data={ data.gas_prices.average }/> <Link>
</Link> <GasPrice data={ data.gas_prices.average }/>
</GasInfoTooltip> </Link>
</Skeleton> </GasInfoTooltip>
</Skeleton>
{ !isPlaceholderData && <GetGasButton/> }
</>
) } ) }
</Flex> </Flex>
); );
......
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