From c2a14953d0236ca9fb70aa2334abee137b7c81a8 Mon Sep 17 00:00:00 2001 From: AmirReza Jamali Date: Wed, 5 Nov 2025 15:39:16 +0330 Subject: [PATCH] feat(marketing): add contacts section and improve checkbox UI This commit introduces a new "Contacts" section to the marketing page, which is now the fifth step in the page's flow. Additionally, the Checkbox component has been enhanced with a smooth transition effect on state change. This provides better visual feedback and a more polished user experience. --- src/app/forms/form-elements/page.tsx | 4 +- .../form-layout/_components/sign-in-form.tsx | 2 +- .../marketing/_components/ContactsStep.tsx | 92 +++++++++++++++++++ .../_components/useContactsStepPresenter.ts | 62 +++++++++++++ src/app/marketing/page.tsx | 8 +- src/components/FormElements/checkbox.tsx | 2 +- 6 files changed, 165 insertions(+), 5 deletions(-) create mode 100644 src/app/marketing/_components/ContactsStep.tsx create mode 100644 src/app/marketing/_components/useContactsStepPresenter.ts diff --git a/src/app/forms/form-elements/page.tsx b/src/app/forms/form-elements/page.tsx index 6d8e987..ff616c7 100644 --- a/src/app/forms/form-elements/page.tsx +++ b/src/app/forms/form-elements/page.tsx @@ -113,9 +113,9 @@ export default function FormElementsPage() { title="Checkbox and radio" className="space-y-5.5 !p-6.5" > - + {/* - + */} diff --git a/src/app/forms/form-layout/_components/sign-in-form.tsx b/src/app/forms/form-layout/_components/sign-in-form.tsx index 1be902a..a5f8aff 100644 --- a/src/app/forms/form-layout/_components/sign-in-form.tsx +++ b/src/app/forms/form-layout/_components/sign-in-form.tsx @@ -21,7 +21,7 @@ export function SignInForm() { /> */}
- + {/* */} Forgot password? diff --git a/src/app/marketing/_components/ContactsStep.tsx b/src/app/marketing/_components/ContactsStep.tsx new file mode 100644 index 0000000..bbad051 --- /dev/null +++ b/src/app/marketing/_components/ContactsStep.tsx @@ -0,0 +1,92 @@ +"use client"; +import { Checkbox } from "@/components/FormElements/checkbox"; +import InputGroup from "@/components/FormElements/InputGroup"; +import { TextAreaGroup } from "@/components/FormElements/InputGroup/text-area"; +import { ShowcaseSection } from "@/components/Layouts/showcase-section"; +import { FormErrorMessages } from "@/constants/Texts"; +import useContactsStepPresenter from "./useContactsStepPresenter"; + +const ContactsStep = () => { + const { errors, handleSubmit, onSubmit, register, fields } = + useContactsStepPresenter(); + return ( +
+ +
+ + {errors.title && ( +

+ {errors.title.message as string} +

+ )} + + +
+
+ + {fields.map((field, index) => ( +
+ + + + +
+ ))} +
+
+ ); +}; + +export default ContactsStep; diff --git a/src/app/marketing/_components/useContactsStepPresenter.ts b/src/app/marketing/_components/useContactsStepPresenter.ts new file mode 100644 index 0000000..b899130 --- /dev/null +++ b/src/app/marketing/_components/useContactsStepPresenter.ts @@ -0,0 +1,62 @@ +"use client"; +import { useFieldArray, useForm } from "react-hook-form"; + +export interface IContactsStepFields { + title: string; + description: string; + submit_button_title: string; + fields: { + field_name: string; + label: string; + placeholder: string; + required: boolean; + }[]; +} + +const useContactsStepPresenter = () => { + const { + register, + handleSubmit, + control, + formState: { errors }, + } = useForm({ + defaultValues: { + fields: [ + { + field_name: "first_name", + label: "", + placeholder: "", + required: false, + }, + { + field_name: "last_name", + label: "", + placeholder: "", + required: false, + }, + { field_name: "email", label: "", placeholder: "", required: false }, + { field_name: "phone", label: "", placeholder: "", required: false }, + ], + }, + }); + + const { fields } = useFieldArray({ + control, + name: "fields", + }); + + const onSubmit = (data: IContactsStepFields) => { + console.log(data); + }; + + return { + register, + handleSubmit, + errors, + onSubmit, + fields, + control, + }; +}; + +export default useContactsStepPresenter; diff --git a/src/app/marketing/page.tsx b/src/app/marketing/page.tsx index 63ad840..90bb94d 100644 --- a/src/app/marketing/page.tsx +++ b/src/app/marketing/page.tsx @@ -6,11 +6,12 @@ import { useState } from "react"; import { ShowcaseSection } from "../../components/Layouts/showcase-section"; import ChallengesStep from "./_components/ChallengesStep"; import ChartStep from "./_components/ChartStep"; +import ContactsStep from "./_components/ContactsStep"; import FeaturesStep from "./_components/FeaturesStep"; import HeroStep from "./_components/HeroStep"; const Marketing = () => { - const [step, setStep] = useState(0); + const [step, setStep] = useState(5); const breadcrumbItems: BreadcrumbItem[] = [ { href: "/", @@ -47,6 +48,11 @@ const Marketing = () => { description: "create benefits section", content: , }, + { + title: "Contacts", + description: "Create contacts section", + content: , + }, ]; return ( <> diff --git a/src/components/FormElements/checkbox.tsx b/src/components/FormElements/checkbox.tsx index d644f89..00e7784 100644 --- a/src/components/FormElements/checkbox.tsx +++ b/src/components/FormElements/checkbox.tsx @@ -43,7 +43,7 @@ export function Checkbox({
*]:block", + "mr-2 flex size-5 items-center justify-center rounded border border-dark-5 peer-checked:border-primary dark:border-dark-6 peer-checked:[&>*]:block transition-all duration-300", withBg ? "peer-checked:bg-primary [&>*]:text-white" : "peer-checked:bg-gray-2 dark:peer-checked:bg-transparent",