diff --git a/apps/web/app/(base-org)/layout.tsx b/apps/web/app/(base-org)/layout.tsx index ecb05bb49f1..49f29a7f971 100644 --- a/apps/web/app/(base-org)/layout.tsx +++ b/apps/web/app/(base-org)/layout.tsx @@ -2,6 +2,7 @@ import type { Metadata } from 'next'; import Sidebar from 'apps/web/src/components/Layout/Navigation/Sidebar'; import { Footer } from 'apps/web/src/components/Layout/Footer/Footer'; import MobileNav from 'apps/web/src/components/Layout/Navigation/MobileNav'; +import { DynamicWrappedGasPriceDropdown } from 'apps/web/src/components/Layout/Navigation/GasPriceDropdown'; import AnalyticsProvider from 'apps/web/contexts/Analytics'; export const metadata: Metadata = { @@ -29,7 +30,7 @@ export default async function BaseOrgLayout({ children: React.ReactNode; }) { return ( -
+
@@ -40,6 +41,11 @@ export default async function BaseOrgLayout({
+ + {/* Gas Price Dropdown - Top Right */} +
+ +
); } diff --git a/apps/web/app/(base-org-dark)/layout.tsx b/apps/web/app/(base-org-dark)/layout.tsx index 175d52f9045..d570f8d5bad 100644 --- a/apps/web/app/(base-org-dark)/layout.tsx +++ b/apps/web/app/(base-org-dark)/layout.tsx @@ -2,6 +2,7 @@ import type { Metadata } from 'next'; import Sidebar from 'apps/web/src/components/Layout/Navigation/Sidebar'; import { Footer } from 'apps/web/src/components/Layout/Footer/Footer'; import MobileNav from 'apps/web/src/components/Layout/Navigation/MobileNav'; +import { DynamicWrappedGasPriceDropdown } from 'apps/web/src/components/Layout/Navigation/GasPriceDropdown'; import AnalyticsProvider from 'apps/web/contexts/Analytics'; export const metadata: Metadata = { @@ -40,6 +41,11 @@ export default function BaseOrgLayoutDark({
+ + {/* Gas Price Dropdown - Top Right */} +
+ +
); } diff --git a/apps/web/src/components/Layout/Navigation/GasPriceDropdown.tsx b/apps/web/src/components/Layout/Navigation/GasPriceDropdown.tsx new file mode 100644 index 00000000000..a117c11f4e7 --- /dev/null +++ b/apps/web/src/components/Layout/Navigation/GasPriceDropdown.tsx @@ -0,0 +1,111 @@ +'use client'; + +import Card from 'apps/web/src/components/base-org/Card'; +import { Icon } from 'apps/web/src/components/Icon/Icon'; +import { base, mainnet } from 'viem/chains'; +import { useGasPrice } from 'wagmi'; +import { DynamicCryptoProviders } from 'apps/web/app/CryptoProviders.dynamic'; + +const convertWeiToMwei = (weiValue: bigint): number => { + // 1 mwei = 10^6 wei + const mweiValue = Number(weiValue) / 1_000_000; + return Number(mweiValue.toFixed(2)); // Round to 2 decimal places +}; + +export function DynamicWrappedGasPriceDropdown() { + return ( + + + + ); +} + +export function GasPriceDropdown() { + const { data: baseGasPriceInWei } = useGasPrice({ + chainId: base.id, + query: { + refetchInterval: 10_000, + }, + }); + + const { data: mainnetGasPriceInWei } = useGasPrice({ + chainId: mainnet.id, + query: { + refetchInterval: 10_000, + }, + }); + + return ( +
+
+ + + +
+ + {baseGasPriceInWei ? convertWeiToMwei(baseGasPriceInWei) : <>—} + + Mwei +
+
+
+ +
    +
  • + {base.name} +
    + + {baseGasPriceInWei ? convertWeiToMwei(baseGasPriceInWei) : <>—} + + Mwei +
    +
  • +
  • + {mainnet.name} +
    + + {mainnetGasPriceInWei ? convertWeiToMwei(mainnetGasPriceInWei) : <>—} + + Mwei +
    +
  • +
+
+
+
+ ); +} + +export function DynamicWrappedGasPriceDropdownItem() { + return ( + + + + ); +} + +export function GasPriceDropdownItem() { + const { data: baseGasPriceInWei } = useGasPrice({ + chainId: base.id, + query: { + refetchInterval: 10_000, + }, + }); + + return ( +
+ + + +
+ + {baseGasPriceInWei ? convertWeiToMwei(baseGasPriceInWei) : <>—} + + Mwei +
+
+ ); +} diff --git a/apps/web/src/components/Layout/Navigation/MobileNav/index.tsx b/apps/web/src/components/Layout/Navigation/MobileNav/index.tsx index eb95a7f3a01..ea2a7805621 100644 --- a/apps/web/src/components/Layout/Navigation/MobileNav/index.tsx +++ b/apps/web/src/components/Layout/Navigation/MobileNav/index.tsx @@ -19,6 +19,7 @@ import { ButtonSizes, ButtonVariants, } from 'apps/web/src/components/Button/Redesign/Button'; +import { DynamicWrappedGasPriceDropdownItem } from 'apps/web/src/components/Layout/Navigation/GasPriceDropdown'; const navItemVariants = { initial: { opacity: 0, x: -20 }, @@ -81,110 +82,117 @@ export default function MobileNav({ className }: { className?: string }) { className, )} > - + - - - - - - - + + + - Mobile Menu - - Mobile site navigation menu. - - -
- -
- ) : ( - - )} - -
-
-
+ ) : ( + + )} + + + + + ); } function MenuIcon({ isOpen }: { isOpen: boolean }) { return ( -
+