File tree Expand file tree Collapse file tree 2 files changed +40
-17
lines changed Expand file tree Collapse file tree 2 files changed +40
-17
lines changed Original file line number Diff line number Diff line change 1+ "use client" ;
2+ import { cn } from "@/lib/utils" ;
3+ import { useLocale , useTranslations } from "next-intl" ;
4+ import Image from "next/image" ;
5+ import { useFormStatus } from "react-dom" ;
6+ import { getLangDir } from "rtl-detect" ;
7+
8+ const FormSubmitButton : React . FC = ( ) => {
9+ const { pending } = useFormStatus ( ) ;
10+
11+ const t = useTranslations ( "landing" ) ;
12+ const tLoading = useTranslations ( "loading" ) ;
13+ const locale = useLocale ( ) ;
14+ const langDir = getLangDir ( locale ) ;
15+
16+ return (
17+ < button
18+ type = "submit"
19+ className = { cn (
20+ "bg-primary-blue h-10" ,
21+ {
22+ "rounded-r" : langDir === "ltr" ,
23+ "rounded-l" : langDir === "rtl" ,
24+ } ,
25+ "text-base text-white-background font-semibold" ,
26+ "px-4 flex gap-2 justify-center items-center" ,
27+ ! pending && "hover:bg-secondary-blue transition cursor-pointer" ,
28+ pending && "bg-stroke animate-pulse" ,
29+ ) }
30+ disabled = { pending }
31+ >
32+ < Image src = "/search.svg" alt = "Search" width = "16" height = "16" />
33+ { pending ? tLoading ( "title" ) : t ( "button" ) }
34+ </ button >
35+ ) ;
36+ } ;
37+
38+ export default FormSubmitButton ;
Original file line number Diff line number Diff line change 22
33import clsx from "clsx" ;
44import { useLocale , useTranslations } from "next-intl" ;
5- import Image from "next/image" ;
65import { getLangDir } from "rtl-detect" ;
76
87import { useRouter } from "@/i18n/routing" ;
8+ import FormSubmitButton from "./components/FormSubmitButton" ;
99
1010const Home : React . FC = ( ) => {
1111 const t = useTranslations ( "landing" ) ;
@@ -60,22 +60,7 @@ const Home: React.FC = () => {
6060 #
6161 </ span >
6262 </ div >
63- < button
64- type = "submit"
65- className = { clsx (
66- "bg-primary-blue h-10" ,
67- {
68- "rounded-r" : langDir === "ltr" ,
69- "rounded-l" : langDir === "rtl" ,
70- } ,
71- "text-base text-white-background font-semibold" ,
72- "px-4 flex gap-2 justify-center items-center" ,
73- "hover:bg-secondary-blue transition" ,
74- ) }
75- >
76- < Image src = "/search.svg" alt = "Search" width = "16" height = "16" />
77- { t ( "button" ) }
78- </ button >
63+ < FormSubmitButton />
7964 </ form >
8065 </ div >
8166 ) ;
You can’t perform that action at this time.
0 commit comments