Skip to content

Commit

Permalink
Feat: gas price in header
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Aug 16, 2023
1 parent 2966376 commit 797d1c6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/components/common/GasStation/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Box, SvgIcon, Typography } from '@mui/material'
import LocalGasStationIcon from '@mui/icons-material/LocalGasStation'
import useGasPrice from '@/hooks/useGasPrice'
import { formatVisualAmount } from '@/utils/formatters'

const GasStation = () => {
const [gasPrice] = useGasPrice()
const maxFeePerGas = gasPrice?.maxFeePerGas
const gasGwei = maxFeePerGas ? formatVisualAmount(maxFeePerGas, 'gwei', 0) : ''

return (
<Box display="flex" alignItems="center">
<Typography sx={{ minWidth: '1.4em' }}>{gasGwei}</Typography>
<SvgIcon component={LocalGasStationIcon} inheritViewBox fontSize="small" />
</Box>
)
}

export default GasStation
5 changes: 5 additions & 0 deletions src/components/common/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import SafeLogo from '@/public/images/logo.svg'
import Link from 'next/link'
import useSafeAddress from '@/hooks/useSafeAddress'
import BatchIndicator from '@/components/batch/BatchIndicator'
import GasStation from '../GasStation'

type HeaderProps = {
onMenuToggle?: Dispatch<SetStateAction<boolean>>
Expand Down Expand Up @@ -66,6 +67,10 @@ const Header = ({ onMenuToggle, onBatchToggle }: HeaderProps): ReactElement => {
</div>
)}

<div className={css.element}>
<GasStation />
</div>

<div className={classnames(css.element, css.hideMobile)}>
<BatchIndicator onClick={handleBatchToggle} />
</div>
Expand Down

0 comments on commit 797d1c6

Please sign in to comment.