diff --git a/app/contact/page.tsx b/app/contact/page.tsx index 168a1ae..dda181b 100644 --- a/app/contact/page.tsx +++ b/app/contact/page.tsx @@ -1,6 +1,9 @@ -import Form from '@/components/pages/Contact/Form/Form'; -import clsx from 'clsx'; import {Metadata} from 'next'; +import clsx from 'clsx'; +import Form from '@/components/pages/Contact/Form/Form'; +import AppearInViewport from '@/components/shared/AppearInViewport/AppearInViewport'; +import TransitionDuration from '@/lib/framerMotion/TransitionDuration'; +import getTextSlideIntoViewVarinats from '@/lib/framerMotion/variants/getTextSlideIntoViewVarinats'; export const metadata: Metadata = { title: 'Contact', @@ -10,7 +13,10 @@ export const metadata: Metadata = { }, }; -const containerCn = clsx('flex', 'min-h-screen', 'w-full'); +const titleVariants = getTextSlideIntoViewVarinats('left'); + +const containerCn = clsx('flex', 'flex-col', 'min-h-screen', 'w-full'); +const titleCn = clsx('text-8xl', 'mt-24', 'ml-4'); /** * @returns React component. @@ -18,6 +24,13 @@ const containerCn = clsx('flex', 'min-h-screen', 'w-full'); export default function Contact() { return (
+ + CONTACT US +
); diff --git a/components/pages/Contact/Form/Form.tsx b/components/pages/Contact/Form/Form.tsx index 7e596cc..e989223 100644 --- a/components/pages/Contact/Form/Form.tsx +++ b/components/pages/Contact/Form/Form.tsx @@ -1,6 +1,7 @@ 'use client'; import {useFormik} from 'formik'; +import Button from '@/components/shared/Button/Button'; import validationSchema, {ContactFormData} from './validationSchema'; import TextField from '../TextField/TextField'; import formConfig from './formConfig'; @@ -15,19 +16,37 @@ const initialValues = { * @returns React element. */ export default function Form() { - const {name, email, message} = formConfig; - const formik = useFormik({ - initialValues, - onSubmit: values => {}, - validationSchema, - }); + const {name, email, message, tel, telegram} = formConfig; + // eslint-disable-next-line jsdoc/require-jsdoc + const onSubmit = (values: ContactFormData) => { + console.log(values); + }; + + const {handleSubmit, getFieldProps, touched, errors, isSubmitting, isValid, dirty} = + useFormik({ + initialValues, + onSubmit, + validationSchema, + }); return ( - - - + + +
Select your preferred method of contact.
+ ); } diff --git a/components/pages/Contact/Form/formConfig.ts b/components/pages/Contact/Form/formConfig.ts index cd5c325..006e3cc 100644 --- a/components/pages/Contact/Form/formConfig.ts +++ b/components/pages/Contact/Form/formConfig.ts @@ -11,26 +11,31 @@ const formConfig: FormConfig = { label: 'Name', type: 'text', placeholder: 'Name', + name: 'name', }, email: { label: 'Email', type: 'email', placeholder: 'Email', + name: 'email', }, tel: { label: 'Phone', type: 'tel', placeholder: 'Phone', + name: 'tel', }, telegram: { label: 'Telegram', type: 'text', placeholder: 'Telegram', + name: 'telegram', }, message: { label: 'Message', type: 'text', placeholder: 'Message', + name: 'message', }, }; diff --git a/components/pages/Contact/TextField/TextField.tsx b/components/pages/Contact/TextField/TextField.tsx index becb25b..f1cd716 100644 --- a/components/pages/Contact/TextField/TextField.tsx +++ b/components/pages/Contact/TextField/TextField.tsx @@ -20,8 +20,10 @@ type TextFieldNativeProps = Omit< */ type TextFieldOwnProps = { label: string; + name: string; type?: 'text' | 'tel' | 'email' | 'number'; placeholder: string; + hasError?: boolean; }; /** @@ -30,18 +32,26 @@ type TextFieldOwnProps = { export type TextFieldProps = TextFieldOwnProps & Omit; -const labelCn = clsx( - 'block', - 'relative', - 'border-b', - 'border-gray-400', - 'focus-within:border-blue-500', -); +// eslint-disable-next-line jsdoc/require-jsdoc +const labelCn = (hasError: TextFieldProps['hasError']) => + clsx( + 'block', + 'relative', + 'border-b', + 'border-gray-500', + 'focus-within:border-white', + 'overflow-hidden', + 'transition-border', + 'duration-300', + 'ease-in-out', + 'pt-3', + 'rounded-sm', + hasError && 'border-red-500! text-red-500!', + ); const inputCn = clsx( 'bg-transparent', 'peer', - 'w-full', 'border-none', 'outline-none', 'focus:ring-0', @@ -51,9 +61,8 @@ const inputCn = clsx( const spanCn = clsx( 'absolute', - 'bottom-0', - 'left-0', - 'w-full', + 'start-0', + 'top-2', '-translate-y-1/2', 'text-xs', 'text-gray-700', @@ -70,7 +79,7 @@ const spanCn = clsx( * @returns React element. */ const TextFieldComponent: ForwardRefRenderFunction = ( - {label, id: outerId, type = 'text', ...rest}, + {label, id: outerId, type = 'text', hasError, ...rest}, ref, ) => { const innerId = useId(); @@ -79,7 +88,7 @@ const TextFieldComponent: ForwardRefRenderFunction - {label} + {label} ); };