fix: links instead of buttons for navigation
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { ReactNode } from "react";
|
import { ReactNode } from "react";
|
||||||
import { usePathname, useRouter } from "next/navigation";
|
import Link from "next/link";
|
||||||
import { UnstyledButton } from "@mantine/core";
|
import { usePathname } from "next/navigation";
|
||||||
import styles from "./Footer.module.css";
|
import styles from "./Footer.module.css";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@ -12,17 +12,14 @@ type Props = {
|
|||||||
|
|
||||||
const FooterClickable = ({ children, href }: Props) => {
|
const FooterClickable = ({ children, href }: Props) => {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const onClick = () => router.push(href);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UnstyledButton
|
<Link
|
||||||
onClick={onClick}
|
href={href}
|
||||||
className={styles.link}
|
className={styles.link}
|
||||||
data-active={pathname === href || undefined}>
|
data-active={pathname === href || undefined}>
|
||||||
{children}
|
{children}
|
||||||
</UnstyledButton>
|
</Link>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { ReactNode } from "react";
|
import { ReactNode } from "react";
|
||||||
import { usePathname, useRouter } from "next/navigation";
|
import Link from "next/link";
|
||||||
import { UnstyledButton } from "@mantine/core";
|
import { usePathname } from "next/navigation";
|
||||||
import styles from "./Navbar.module.css";
|
import styles from "./Navbar.module.css";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@ -13,17 +13,14 @@ type Props = {
|
|||||||
|
|
||||||
const NavbarClickable = ({ children, href, active = false }: Props) => {
|
const NavbarClickable = ({ children, href, active = false }: Props) => {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const onClick = () => router.push(href);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UnstyledButton
|
<Link
|
||||||
onClick={onClick}
|
href={href}
|
||||||
className={styles.link}
|
className={styles.link}
|
||||||
data-active={active || pathname === href || undefined}>
|
data-active={active || pathname === href || undefined}>
|
||||||
{children}
|
{children}
|
||||||
</UnstyledButton>
|
</Link>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user