Skip to content

Commit 527be27

Browse files
Merge pull request #135 from sanjam4747/fix/icons
Fix/icons
2 parents 15adf80 + 3442bba commit 527be27

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

src/lib/components/layout/BottomNavbar.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import Link from "next/link";
22
import Image from "next/image";
33
import { usePathname } from "next/navigation";
44
import { cn } from "@/lib/utils/utils";
5+
import { resolveAssetPath } from "@/lib/utils/asset-path";
56
import { useMediaQuery } from "usehooks-ts";
67
import { useTheme } from "next-themes";
78
import { useEffect, useState } from "react";
9+
import { useRouter } from "next/router";
810

911
const socialLinks = [
1012
{
@@ -36,6 +38,7 @@ const socialLinks = [
3638
export function BottomNavbar() {
3739
const isMobile = useMediaQuery("(max-width: 768px)");
3840
const pathname = usePathname();
41+
const router = useRouter();
3942
const { theme, systemTheme } = useTheme();
4043
const [mounted, setMounted] = useState(false);
4144

@@ -47,7 +50,7 @@ export function BottomNavbar() {
4750
<div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
4851
<div className="flex justify-center space-x-6 py-4">
4952
{socialLinks.map(({ href, label, iconLight, iconDark }) => {
50-
let iconSrc = "/logo/default.svg";
53+
let iconSrc = iconLight;
5154

5255
if (mounted) {
5356
const currentTheme = theme === "system" ? systemTheme : theme;
@@ -63,7 +66,7 @@ export function BottomNavbar() {
6366
className="flex h-8 w-8 items-center justify-center transition-colors hover:text-primary"
6467
aria-label={label}
6568
>
66-
<Image src={iconSrc} alt={label} width={24} height={24} className="h-6 w-6 object-contain" />
69+
<Image src={resolveAssetPath(iconSrc, router.basePath)} alt={label} width={24} height={24} className="h-6 w-6 object-contain" />
6770
</Link>
6871
);
6972
})}

src/lib/components/layout/TopNavbar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Button } from "@/lib/components/ui/button";
66
import { useMediaQuery } from "usehooks-ts";
77
import { ThemeToggle } from "../toggle/ThemeToggle";
88
import { cn } from "@/lib/utils/utils";
9+
import { resolveAssetPath } from "@/lib/utils/asset-path";
910
import { useRouter } from "next/router";
1011
import { WalletConnector } from "../blockchain/connector/WalletConnector";
1112
import { useTheme } from "next-themes";
@@ -25,7 +26,6 @@ const navItems = [
2526
export function TopNavbar() {
2627
const isDesktop = useMediaQuery("(min-width: 768px)");
2728
const pathname = usePathname();
28-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2929
const router = useRouter();
3030
const { theme } = useTheme();
3131

@@ -50,12 +50,12 @@ export function TopNavbar() {
5050

5151
return (
5252
<div className="w-full shadow-sm backdrop-blur-xl dark:shadow-lg">
53-
<div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
53+
<div className="w-full px-4 sm:px-6 lg:px-8">
5454
<div className="flex items-center justify-between py-4">
5555
{/* Left - Logo */}
5656
<div className="flex items-center">
5757
<Link href="/" className="flex items-center">
58-
<Image src={tokenConfig.favicon} alt="Gluon Logo" width={28} height={28} priority />
58+
<Image src={resolveAssetPath(tokenConfig.favicon, router.basePath)} alt="Gluon Logo" width={28} height={28} priority />
5959
{isDesktop && <p className="ml-2 font-sans text-2xl font-medium">{tokenConfig.protocolName}</p>}
6060
</Link>
6161
</div>

src/lib/utils/asset-path.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export const resolveAssetPath = (path: string, basePath?: string): string => {
2+
if (!path || path.startsWith("http://") || path.startsWith("https://")) {
3+
return path;
4+
}
5+
6+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
7+
if (basePath && (normalizedPath === basePath || normalizedPath.startsWith(`${basePath}/`))) {
8+
return normalizedPath;
9+
}
10+
11+
return `${basePath ?? ""}${normalizedPath}`;
12+
};

0 commit comments

Comments
 (0)