Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

improved input implementation

Steven Teye34507815997
diff --git a/apps/web/app/app.dub.co/(auth)/register/signup-email.tsx b/apps/web/app/app.dub.co/(auth)/register/signup-email.tsx
index b91c3146a4..15eee3b62e 100644
--- a/apps/web/app/app.dub.co/(auth)/register/signup-email.tsx
+++ b/apps/web/app/app.dub.co/(auth)/register/signup-email.tsx
@@ -20,6 +20,7 @@ export const SignUpEmail = () => {
handleSubmit,
formState: { errors, isValid },
getValues,
+ setError,
} = useForm<SignUpProps>({
resolver: zodResolver(signUpSchema),
});
@@ -43,11 +44,12 @@ export const SignUpEmail = () => {
<div className="flex flex-col space-y-4">
<Input
type="email"
- placeholder="Email address"
+ placeholder="[email protected]"
autoComplete="email"
required
{...register("email")}
error={errors.email?.message}
+ onChange={(e) => setError("email", { message: "" })}
/>
<Input
type="password"
@@ -55,11 +57,12 @@ export const SignUpEmail = () => {
required
{...register("password")}
error={errors.password?.message}
+ onChange={(e) => setError("password", { message: "" })}
/>
<Button
type="submit"
text={isExecuting ? "Submitting..." : "Sign Up"}
- disabled={isExecuting || !isValid}
+ disabled={isExecuting}
loading={isExecuting}
/>
</div>
diff --git a/apps/web/emails/verify-email.tsx b/apps/web/emails/verify-email.tsx
index 3594ba7310..c3e6ee299d 100644
--- a/apps/web/emails/verify-email.tsx
+++ b/apps/web/emails/verify-email.tsx
@@ -42,7 +42,7 @@ export default function VerifyEmail({
Enter this code on the Dub verify page to complete your sign up:
</Text>
<Section className="my-8">
- <div className="mx-auto w-20 rounded-xl bg-gray-800 px-6 py-3 text-center text-[20px] font-semibold tracking-widest text-white">
+ <div className="mx-auto w-fit rounded-xl px-6 py-3 text-center font-mono text-2xl font-semibold tracking-[0.25em]">
{code}
</div>
</Section>
diff --git a/packages/ui/src/input.tsx b/packages/ui/src/input.tsx
index fcd220c2c8..d74e629b6c 100644
--- a/packages/ui/src/input.tsx
+++ b/packages/ui/src/input.tsx
@@ -1,5 +1,5 @@
import { cn } from "@dub/utils";
-import { EyeIcon, EyeOffIcon } from "lucide-react";
+import { AlertCircle, EyeIcon, EyeOffIcon } from "lucide-react";
import React, { useCallback, useState } from "react";
export interface InputProps
@@ -17,37 +17,45 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
);
return (
- <div className="relative">
- <input
- type={isPasswordVisible ? "text" : type}
- className={cn(
- "w-full max-w-md rounded-md border border-gray-300 text-gray-900 placeholder-gray-400 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm",
- className,
- )}
- ref={ref}
- {...props}
- />
-
- {type === "password" && (
- <button
- className="absolute inset-y-0 right-0 flex items-center rounded-lg px-2.5"
- type="button"
- onClick={() => toggleIsPasswordVisible()}
- aria-label={isPasswordVisible ? "Hide password" : "Show Password"}
- >
- {isPasswordVisible ? (
- <EyeIcon
- className="size-4 flex-none text-gray-500 transition hover:text-gray-700"
- aria-hidden
- />
- ) : (
- <EyeOffIcon
- className="size-4 flex-none text-gray-500 transition hover:text-gray-700"
- aria-hidden
- />
+ <div>
+ <div className="relative flex">
+ <input
+ type={isPasswordVisible ? "text" : type}
+ className={cn(
+ "w-full max-w-md rounded-md border border-gray-300 text-gray-900 placeholder-gray-400 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm",
+ props.error &&
+ "border-red-500 focus:border-red-500 focus:ring-red-500",
+ className,
)}
- </button>
- )}
+ ref={ref}
+ {...props}
+ />
+
+ {props.error ? (
+ <div className="pointer-events-none absolute inset-y-0 right-2 flex items-center">
+ <AlertCircle className="size-5 flex-none text-white" fill="red" />
+ </div>
+ ) : type === "password" ? (
+ <button
+ className="absolute inset-y-0 right-0 flex items-center rounded-lg px-2.5"
+ type="button"
+ onClick={() => toggleIsPasswordVisible()}
+ aria-label={isPasswordVisible ? "Hide password" : "Show Password"}
+ >
+ {isPasswordVisible ? (
+ <EyeIcon
+ className="size-4 flex-none text-gray-500 transition hover:text-gray-700"
+ aria-hidden
+ />
+ ) : (
+ <EyeOffIcon
+ className="size-4 flex-none text-gray-500 transition hover:text-gray-700"
+ aria-hidden
+ />
+ )}
+ </button>
+ ) : null}
+ </div>
{props.error && (
<span