fix: home tabs highlight
This commit is contained in:
parent
d518981cd2
commit
87d03ba429
|
|
@ -1,33 +1,11 @@
|
|||
import { ConnectButton } from "~/components/common/ConnectButton"
|
||||
import { DarkModeSwitch } from "~/components/common/DarkModeSwitch"
|
||||
import { Logo } from "~/components/common/Logo"
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import HomeTabs from "~/components/home/HomeTabs"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { APP_NAME, DISCORD_LINK, GITHUB_LINK, TWITTER_LINK } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { useTranslation } from "~/lib/i18n"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
name: "Home",
|
||||
link: "/",
|
||||
},
|
||||
{
|
||||
name: "Activities",
|
||||
link: "/activities",
|
||||
},
|
||||
{
|
||||
name: (
|
||||
<Image
|
||||
className="no-optimization w-24"
|
||||
alt="github stars"
|
||||
src="https://img.shields.io/github/stars/Crossbell-Box/xLog?color=white&label=Stars&logo=github&style=social"
|
||||
/>
|
||||
),
|
||||
link: GITHUB_LINK,
|
||||
},
|
||||
]
|
||||
|
||||
export default async function HomeLayout({
|
||||
children,
|
||||
|
|
@ -50,20 +28,7 @@ export default async function HomeLayout({
|
|||
xLog
|
||||
</UniLink>
|
||||
<div className="space-x-14 text-zinc-500 flex">
|
||||
{tabs?.map((tab, index) => (
|
||||
<UniLink
|
||||
className={cn(
|
||||
"cursor-pointer items-center hidden sm:flex hover:text-accent text-lg",
|
||||
{
|
||||
"text-accent": "/" === tab.link,
|
||||
},
|
||||
)}
|
||||
key={tab.link}
|
||||
href={tab.link}
|
||||
>
|
||||
{typeof tab.name === "string" ? t(tab.name) : tab.name}
|
||||
</UniLink>
|
||||
))}
|
||||
<HomeTabs />
|
||||
<ConnectButton size="base" variantColor="black" />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
"use client"
|
||||
|
||||
import { usePathname } from "next/navigation"
|
||||
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import { GITHUB_LINK } from "~/lib/env"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { UniLink } from "../ui/UniLink"
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
name: "Home",
|
||||
link: "/",
|
||||
},
|
||||
{
|
||||
name: "Activities",
|
||||
link: "/activities",
|
||||
},
|
||||
{
|
||||
name: (
|
||||
<Image
|
||||
className="no-optimization w-24"
|
||||
alt="github stars"
|
||||
src="https://img.shields.io/github/stars/Crossbell-Box/xLog?color=white&label=Stars&logo=github&style=social"
|
||||
/>
|
||||
),
|
||||
link: GITHUB_LINK,
|
||||
},
|
||||
]
|
||||
|
||||
export default function HomeTabs() {
|
||||
const pathname = usePathname()
|
||||
const { t } = useTranslation("index")
|
||||
|
||||
return (
|
||||
<>
|
||||
{tabs?.map((tab, index) => (
|
||||
<UniLink
|
||||
className={cn(
|
||||
"cursor-pointer items-center hidden sm:flex hover:text-accent text-lg",
|
||||
{
|
||||
"text-accent": pathname === tab.link,
|
||||
},
|
||||
)}
|
||||
key={tab.link}
|
||||
href={tab.link}
|
||||
>
|
||||
{typeof tab.name === "string" ? t(tab.name) : tab.name}
|
||||
</UniLink>
|
||||
))}
|
||||
</>
|
||||
)
|
||||
}
|
||||
Loading…
Reference in New Issue