-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
154 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { twMerge } from "tailwind-merge"; | ||
import clsx, { ClassValue } from "clsx"; | ||
|
||
export function cn(...inputs: ClassValue[]) { | ||
return twMerge(clsx(inputs)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import { ComponentProps } from "react"; | ||
import { cn } from "../../app/utils/cn"; | ||
|
||
interface ButtonProps extends ComponentProps<'button'> {} | ||
|
||
export function Button(props: ButtonProps) { | ||
export function Button({ className, ...props }: ButtonProps) { | ||
return ( | ||
<button | ||
{...props} | ||
className="bg-teal-900 hover:bg-teal-800 disabled:bg-gray-100 disabled:text-gray-400 disabled:cursor-not-allowed | ||
px-6 h-12 rounded-2xl font-medium text-white transition-all" | ||
className={cn( | ||
"bg-teal-900 hover:bg-teal-800 disabled:bg-gray-100 disabled:text-gray-400 disabled:cursor-not-allowed px-6 h-12 rounded-2xl font-medium text-white transition-all", | ||
className, | ||
)} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,46 @@ | ||
import { ComponentProps } from "react"; | ||
import { ComponentProps, forwardRef } from "react"; | ||
import { CrossCircledIcon } from "@radix-ui/react-icons"; | ||
import { cn } from "../../app/utils/cn"; | ||
|
||
interface InputProps extends ComponentProps<'input'> { | ||
name: string; | ||
error?: string; | ||
} | ||
|
||
export function Input({ placeholder, name, id, ...props }: InputProps) { | ||
const inputId = id ?? name; | ||
export const Input = forwardRef<HTMLInputElement, InputProps>( | ||
({ placeholder, name, id, error, className, ...props }, ref) => { | ||
const inputId = id ?? name; | ||
|
||
return ( | ||
<div className="relative"> | ||
<input | ||
{...props} | ||
name={name} | ||
id={inputId} | ||
className="bg-white w-full rounded-lg border border-gray-500 px-3 h-[52px] | ||
text-gray-800 pt-4 peer placeholder-shown:pt-0 focus:border-gray-800 transition-all | ||
outline-none" | ||
placeholder=" " | ||
/> | ||
return ( | ||
<div className="relative"> | ||
<input | ||
{...props} | ||
ref={ref} | ||
name={name} | ||
id={inputId} | ||
placeholder=" " | ||
className={cn( | ||
"bg-white w-full rounded-lg border border-gray-500 px-3 h-[52px] text-gray-800 pt-4 peer placeholder-shown:pt-0 focus:border-gray-800 transition-all outline-none", | ||
error && "!border-red-900", | ||
className, | ||
)} | ||
/> | ||
|
||
<label | ||
htmlFor={inputId} | ||
className="absolute text-xs left-[13px] top-2 pointer-events-none text-gray-700 | ||
peer-placeholder-shown:text-base peer-placeholder-shown:top-3.5 transition-all" | ||
> | ||
{placeholder} | ||
</label> | ||
</div> | ||
); | ||
} | ||
<label | ||
htmlFor={inputId} | ||
className="absolute text-xs left-[13px] top-2 pointer-events-none text-gray-700 | ||
peer-placeholder-shown:text-base peer-placeholder-shown:top-3.5 transition-all" | ||
> | ||
{placeholder} | ||
</label> | ||
|
||
{error && ( | ||
<div className="flex gap-2 items-center mt-2 text-red-900"> | ||
<CrossCircledIcon /> | ||
<span className="text-xs">{error}</span> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useForm } from 'react-hook-form'; | ||
import { zodResolver } from '@hookform/resolvers/zod'; | ||
import { z } from 'zod'; | ||
|
||
const schema = z.object({ | ||
email: z.string().min(1, "E-mail é obrigatório").email("Informe um e-mail válido"), | ||
password: z.string().min(8, "Senha deve ter no mínimo 8 caracteres"), | ||
}); | ||
|
||
type FormData = z.infer<typeof schema>; | ||
|
||
export function useLoginController() { | ||
const { | ||
register, | ||
handleSubmit: hookFormHandleSubmit, | ||
formState: { errors }, | ||
} = useForm<FormData>({ | ||
resolver: zodResolver(schema), | ||
}); | ||
|
||
const handleSubmit = hookFormHandleSubmit((data) => { | ||
console.log("Chama a Api com:", data); | ||
}); | ||
|
||
return { handleSubmit, register, errors }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters