🧑‍💻 create button delay helper

This commit is contained in:
2025-07-13 16:21:05 +07:00
parent 0f4bfdfe1c
commit cfd8015cd5
5 changed files with 38 additions and 5 deletions

7
app/(clear)/layout.tsx Normal file
View File

@ -0,0 +1,7 @@
import React from "react";
const clearLayout = ({ children }: Readonly<{ children: React.ReactNode }>) => {
return <div>{children}</div>;
};
export default clearLayout;

View File

@ -0,0 +1,7 @@
import React from "react";
const page = () => {
return <div>page</div>;
};
export default page;

View File

@ -0,0 +1,7 @@
import React from "react";
const page = () => {
return <div>Sign Up</div>;
};
export default page;

View File

@ -0,0 +1,11 @@
import { useRouter } from "next/navigation";
export const delayButtonClick = (
router: ReturnType<typeof useRouter>,
href: string,
timeout: number = 300
) => {
setTimeout(() => {
router.push(href);
}, timeout);
};

View File

@ -1,6 +1,5 @@
"use client";
import V from "next/link";
import {
Button,
Link,
@ -12,8 +11,9 @@ import {
NavbarMenuItem,
NavbarMenuToggle,
} from "@heroui/react";
import { usePathname } from "next/navigation";
import { usePathname, useRouter } from "next/navigation";
import React, { useState } from "react";
import { delayButtonClick } from "../lib/delayButtonClick";
export const AcmeLogo = () => {
return (
@ -29,7 +29,9 @@ export const AcmeLogo = () => {
};
const NavbarUI = () => {
const router = useRouter();
const pathNameNow = usePathname();
const [isMenuOpen, setIsMenuOpen] = useState(false);
const navbarItems = [
@ -86,17 +88,16 @@ const NavbarUI = () => {
</NavbarContent>
<NavbarContent justify="end">
<NavbarItem className="hidden lg:flex">
<Link href="#" className="font-medium">
<Link href="/login" className="font-medium">
Login
</Link>
</NavbarItem>
<NavbarItem>
<Button
as={Link}
color="primary"
href="#"
variant="solid"
radius="sm"
onPress={() => delayButtonClick(router, "/signup")}
>
Sign Up
</Button>