Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas tracker page #1524

Merged
merged 24 commits into from
Feb 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
dark theme and other tweaks
  • Loading branch information
tom2drum committed Jan 22, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
chraibi Mohcine Chraibi
commit 949314f67f2c6ca091c2661f0d30a482fd88ffea
10 changes: 10 additions & 0 deletions nextjs/getServerSideProps.ts
Original file line number Diff line number Diff line change
@@ -147,3 +147,13 @@ export const accounts: GetServerSideProps<Props> = async(context) => {

return base(context);
};

export const gasTracker: GetServerSideProps<Props> = async(context) => {
if (!config.features.gasTracker.isEnabled) {
return {
notFound: true,
};
}

return base(context);
};
2 changes: 1 addition & 1 deletion pages/gas-tracker.tsx
Original file line number Diff line number Diff line change
@@ -16,4 +16,4 @@ const Page: NextPage = () => {

export default Page;

export { base as getServerSideProps } from 'nextjs/getServerSideProps';
export { gasTracker as getServerSideProps } from 'nextjs/getServerSideProps';
8 changes: 4 additions & 4 deletions ui/gasTracker/GasTrackerPriceSnippet.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Flex, Skeleton } from '@chakra-ui/react';
import { Box, Flex, Skeleton, useColorModeValue } from '@chakra-ui/react';
import React from 'react';

import type { GasPriceInfo, GasPrices } from 'types/api/stats';
@@ -30,8 +30,8 @@ const GasTrackerPriceSnippet = ({ data, type, isLoading }: Props) => {

const bgColors = {
fast: 'transparent',
average: 'gray.50',
slow: 'gray.50',
average: useColorModeValue('gray.50', 'whiteAlpha.200'),
slow: useColorModeValue('gray.50', 'whiteAlpha.200'),
};

return (
@@ -45,7 +45,7 @@ const GasTrackerPriceSnippet = ({ data, type, isLoading }: Props) => {
>
<Skeleton textStyle="h3" display="inline-block" isLoaded={ !isLoading }>{ TITLES[type] }</Skeleton>
<Flex columnGap={ 3 } alignItems="center" mt={ 3 }>
<IconSvg name={ ICONS[type] } boxSize={ 10 } isLoading={ isLoading } flexShrink={ 0 }/>
<IconSvg name={ ICONS[type] } boxSize={{ base: '30px', lg: 10 }} isLoading={ isLoading } flexShrink={ 0 }/>
<Skeleton isLoaded={ !isLoading }>
<GasPrice data={ data } fontSize="48px" lineHeight="48px" fontWeight={ 600 } letterSpacing="-1px" fontFamily="heading"/>
</Skeleton>
4 changes: 2 additions & 2 deletions ui/gasTracker/GasTrackerPrices.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Flex } from '@chakra-ui/react';
import { Flex, useColorModeValue } from '@chakra-ui/react';
import React from 'react';

import type { GasPrices } from 'types/api/stats';
@@ -11,7 +11,7 @@ interface Props {
}

const GasTrackerPrices = ({ prices, isLoading }: Props) => {
const borderColor = 'gray.200';
const borderColor = useColorModeValue('gray.200', 'whiteAlpha.300');

return (
<Flex
19 changes: 8 additions & 11 deletions ui/snippets/topBar/TopBarStats.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import { Flex, Link, Skeleton, Tooltip, chakra, useDisclosure } from '@chakra-ui/react';
import { Flex, Skeleton, Tooltip, chakra, useDisclosure } from '@chakra-ui/react';
import React from 'react';

import { route } from 'nextjs-routes';

import config from 'configs/app';
import useApiQuery from 'lib/api/useApiQuery';
import dayjs from 'lib/date/dayjs';
import { HOMEPAGE_STATS } from 'stubs/stats';
import GasInfoTooltipContent from 'ui/shared/gas/GasInfoTooltipContent';
import GasPrice from 'ui/shared/gas/GasPrice';
import LinkInternal from 'ui/shared/LinkInternal';
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 { isOpen, onOpen, onClose } = useDisclosure();

const { data, isPlaceholderData, isError, refetch, dataUpdatedAt } = useApiQuery('homepage_stats', {
queryOptions: {
@@ -84,14 +82,13 @@ const TopBarStats = () => {
p={ 0 }
isOpen={ isOpen }
>
<Link
_hover={{ textDecoration: 'none', color: 'link_hovered' }}
onClick={ handleClick }
<LinkInternal
href={ route({ pathname: '/gas-tracker' }) }
onMouseEnter={ onOpen }
onMouseLeave={ onClose }
>
<GasPrice data={ data.gas_prices.average }/>
</Link>
</LinkInternal>
</Tooltip>
</Skeleton>
) }