diff --git a/ui/home/Stats.tsx b/ui/home/Stats.tsx
index 2b653b1ab8..f2257ee10c 100644
--- a/ui/home/Stats.tsx
+++ b/ui/home/Stats.tsx
@@ -15,8 +15,8 @@ import walletIcon from 'icons/wallet.svg';
import useApiQuery from 'lib/api/useApiQuery';
import { WEI } from 'lib/consts';
import { HOMEPAGE_STATS } from 'stubs/stats';
+import GasInfoTooltipContent from 'ui/shared/GasInfoTooltipContent/GasInfoTooltipContent';
-import StatsGasPrices from './StatsGasPrices';
import StatsItem from './StatsItem';
const hasGasTracker = config.UI.homepage.showGasTracker;
@@ -52,7 +52,7 @@ const Stats = () => {
!data.gas_prices && itemsCount--;
data.rootstock_locked_btc && itemsCount++;
const isOdd = Boolean(itemsCount % 2);
- const gasLabel = hasGasTracker && data.gas_prices ? : null;
+ const gasLabel = hasGasTracker && data.gas_prices ? : null;
content = (
<>
diff --git a/ui/home/StatsGasPrices.tsx b/ui/shared/GasInfoTooltipContent/GasInfoTooltipContent.tsx
similarity index 85%
rename from ui/home/StatsGasPrices.tsx
rename to ui/shared/GasInfoTooltipContent/GasInfoTooltipContent.tsx
index 103cb6b79e..e1d164867a 100644
--- a/ui/home/StatsGasPrices.tsx
+++ b/ui/shared/GasInfoTooltipContent/GasInfoTooltipContent.tsx
@@ -3,7 +3,7 @@ import React from 'react';
import type { GasPrices } from 'types/api/stats';
-const StatsGasPrices = ({ gasPrices }: {gasPrices: GasPrices}) => {
+const GasInfoTooltipContent = ({ gasPrices }: {gasPrices: GasPrices}) => {
const nameStyleProps = {
color: useColorModeValue('blue.100', 'blue.600'),
};
@@ -20,4 +20,4 @@ const StatsGasPrices = ({ gasPrices }: {gasPrices: GasPrices}) => {
);
};
-export default StatsGasPrices;
+export default React.memo(GasInfoTooltipContent);
diff --git a/ui/snippets/topBar/TopBar.pw.tsx b/ui/snippets/topBar/TopBar.pw.tsx
index 337e622670..555f645707 100644
--- a/ui/snippets/topBar/TopBar.pw.tsx
+++ b/ui/snippets/topBar/TopBar.pw.tsx
@@ -19,7 +19,9 @@ test('default view +@dark-mode +@mobile', async({ mount, page }) => {
,
);
- await component.getByLabel('color mode switch').click();
+ await component.getByText(/gwei/i).hover();
+ await expect(page).toHaveScreenshot({ clip: { x: 0, y: 0, width: 1500, height: 220 } });
+ await component.getByLabel('color mode switch').click();
await expect(page).toHaveScreenshot({ clip: { x: 0, y: 0, width: 1500, height: 220 } });
});
diff --git a/ui/snippets/topBar/TopBarStats.tsx b/ui/snippets/topBar/TopBarStats.tsx
index 2709442f48..31ab9a2a33 100644
--- a/ui/snippets/topBar/TopBarStats.tsx
+++ b/ui/snippets/topBar/TopBarStats.tsx
@@ -1,12 +1,21 @@
-import { Flex, Skeleton } from '@chakra-ui/react';
+import { Flex, LightMode, Link, Skeleton, Tooltip, chakra, useDisclosure } from '@chakra-ui/react';
import React from 'react';
import config from 'configs/app';
import useApiQuery from 'lib/api/useApiQuery';
import { HOMEPAGE_STATS } from 'stubs/stats';
+import GasInfoTooltipContent from 'ui/shared/GasInfoTooltipContent/GasInfoTooltipContent';
import TextSeparator from 'ui/shared/TextSeparator';
const TopBarStats = () => {
+ // have to implement controlled tooltip because of the issue - https://github.com/chakra-ui/chakra-ui/issues/7107
+ const { isOpen, onOpen, onToggle, onClose } = useDisclosure();
+
+ const handleClick = React.useCallback((event: React.MouseEvent) => {
+ event.stopPropagation();
+ onToggle();
+ }, [ onToggle ]);
+
const { data, isPlaceholderData, isError } = useApiQuery('homepage_stats', {
queryOptions: {
placeholderData: HOMEPAGE_STATS,
@@ -26,14 +35,34 @@ const TopBarStats = () => {
>
{ data?.coin_price && (
- { config.chain.governanceToken.symbol || config.chain.currency.symbol }:
+ { config.chain.governanceToken.symbol || config.chain.currency.symbol }
${ Number(data.coin_price).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 6 }) }
) }
{ data?.coin_price && config.UI.homepage.showGasTracker && }
{ data?.gas_prices && config.UI.homepage.showGasTracker && (
- Gas: { data.gas_prices.average } Gwei
+ Gas
+
+ }
+ hasArrow={ false }
+ borderRadius="md"
+ offset={ [ 0, 16 ] }
+ bgColor="blackAlpha.900"
+ p={ 0 }
+ isOpen={ isOpen }
+ >
+
+ { data.gas_prices.average } Gwei
+
+
+
) }
diff --git a/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_dark-color-mode_default-view-dark-mode-mobile-1.png b/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_dark-color-mode_default-view-dark-mode-mobile-1.png
index 3fa188f1d4..6a2b7cbc92 100644
Binary files a/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_dark-color-mode_default-view-dark-mode-mobile-1.png and b/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_dark-color-mode_default-view-dark-mode-mobile-1.png differ
diff --git a/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_dark-color-mode_default-view-dark-mode-mobile-2.png b/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_dark-color-mode_default-view-dark-mode-mobile-2.png
new file mode 100644
index 0000000000..5698b69615
Binary files /dev/null and b/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_dark-color-mode_default-view-dark-mode-mobile-2.png differ
diff --git a/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_default_default-view-dark-mode-mobile-1.png b/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_default_default-view-dark-mode-mobile-1.png
index 0b5c77a4da..5ad894f330 100644
Binary files a/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_default_default-view-dark-mode-mobile-1.png and b/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_default_default-view-dark-mode-mobile-1.png differ
diff --git a/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_default_default-view-dark-mode-mobile-2.png b/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_default_default-view-dark-mode-mobile-2.png
new file mode 100644
index 0000000000..87b4a3ff01
Binary files /dev/null and b/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_default_default-view-dark-mode-mobile-2.png differ
diff --git a/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_mobile_default-view-dark-mode-mobile-1.png b/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_mobile_default-view-dark-mode-mobile-1.png
index 65afff266a..5f14a03434 100644
Binary files a/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_mobile_default-view-dark-mode-mobile-1.png and b/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_mobile_default-view-dark-mode-mobile-1.png differ
diff --git a/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_mobile_default-view-dark-mode-mobile-2.png b/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_mobile_default-view-dark-mode-mobile-2.png
new file mode 100644
index 0000000000..cba6ce62e3
Binary files /dev/null and b/ui/snippets/topBar/__screenshots__/TopBar.pw.tsx_mobile_default-view-dark-mode-mobile-2.png differ