Spaces:
Sleeping
Sleeping
Download packages/ui/src/components/AuthForm.tsx from Benaah/MicProtocol: direct link, hf CLI and curl.
- Browser
- Download file 4.79 kB
-
https://huggingface.co/spaces/Benaah/MicProtocol/resolve/main/packages/ui/src/components/AuthForm.tsx
- Command line
-
hf download hf://spaces/Benaah/MicProtocol/packages/ui/src/components/AuthForm.tsx
-
curl -L -o AuthForm.tsx https://huggingface.co/spaces/Benaah/MicProtocol/resolve/main/packages/ui/src/components/AuthForm.tsx
4.79 kB
| import React from "react"; | |
| import { cn } from "../lib/cn"; | |
| import { Button } from "./Button"; | |
| import { AuthInput } from "./AuthInput"; | |
| export interface AuthFormProps | |
| extends React.HTMLAttributes<HTMLFormElement> { | |
| /** Form title (e.g. "Sign in") */ | |
| title: string; | |
| /** Form subtitle/description */ | |
| subtitle?: string; | |
| /** Button label (e.g. "Sign in", "Create account") */ | |
| buttonLabel: string; | |
| /** Alternative action text (e.g. "Create an account") */ | |
| altAction?: string; | |
| /** Alt action link label (e.g. "Sign up") */ | |
| altLink?: string; | |
| /** Social login providers to show */ | |
| socialProviders?: ("google" | "github" | "apple")[]; | |
| /** Error message to display at form top */ | |
| error?: string; | |
| /** Children (form fields) */ | |
| children: React.ReactNode; | |
| } | |
| export const AuthForm = React.forwardRef<HTMLFormElement, AuthFormProps>( | |
| ( | |
| { | |
| title, | |
| subtitle, | |
| buttonLabel, | |
| altAction, | |
| altLink, | |
| socialProviders, | |
| error, | |
| className, | |
| children, | |
| ...props | |
| }, | |
| ref, | |
| ) => { | |
| return ( | |
| <form | |
| ref={ref} | |
| className={cn("w-full max-w-[440px] space-y-[var(--space-6)]", className)} | |
| style={{ width: "100%", maxWidth: "440px" }} | |
| {...props} | |
| > | |
| {error && ( | |
| <div | |
| className="rounded-[var(--radius-md)] border border-[var(--color-error)] bg-[rgba(239,68,68,0.1)] p-[var(--space-3)] text-[var(--color-error)] text-[var(--text-sm)]" | |
| role="alert" | |
| > | |
| {error} | |
| </div> | |
| )} | |
| <div className="text-center space-y-[calc(var(--space-2)*0.5)] mb-[var(--space-8)]"> | |
| <h2 | |
| className="font-[var(--font-display)] text-[var(--text-xl)] font-bold text-[var(--text-primary)] tracking-[-0.02em] m-0" | |
| style={{ | |
| fontFamily: "var(--font-display)", | |
| fontSize: "var(--text-xl)", | |
| fontWeight: 700, | |
| color: "var(--text-primary)", | |
| letterSpacing: "-0.02em", | |
| margin: 0, | |
| }} | |
| > | |
| {title} | |
| </h2> | |
| {subtitle && ( | |
| <p | |
| className="text-[var(--text-sm)] text-[var(--text-secondary)] leading-1.5 m-0" | |
| style={{ | |
| fontSize: "var(--text-sm)", | |
| color: "var(--text-secondary)", | |
| lineHeight: 1.5, | |
| margin: 0, | |
| }} | |
| > | |
| {subtitle} | |
| </p> | |
| )} | |
| </div> | |
| {socialProviders && socialProviders.length > 0 && ( | |
| <div className="space-y-[var(--space-3)] mb-[var(--space-6)]"> | |
| <div className="relative flex items-center"> | |
| <div className="flex-grow border-t border-[var(--border-color)]" /> | |
| <span className="px-[var(--space-2)] text-[var(--text-xs)] text-[var(--text-tertiary)] bg-[var(--bg-primary)]"> | |
| Or continue with | |
| </span> | |
| <div className="flex-grow border-t border-[var(--border-color)]" /> | |
| </div> | |
| <div className="grid grid-cols-1 gap-[var(--space-2)]"> | |
| {socialProviders.map((provider) => ( | |
| <Button | |
| key={provider} | |
| variant="ghost" | |
| size="lg" | |
| fullWidth | |
| onClick={() => {}} | |
| className={cn( | |
| "bg-transparent border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]", | |
| provider === "google" && "text-[var(--color-error)]", | |
| )} | |
| > | |
| {provider === "google" && "Google"} | |
| {provider === "github" && "GitHub"} | |
| {provider === "apple" && "Apple"} | |
| </Button> | |
| ))} | |
| </div> | |
| </div> | |
| )} | |
| {children} | |
| <Button | |
| type="submit" | |
| variant="primary" | |
| size="lg" | |
| fullWidth | |
| className="w-full" | |
| > | |
| {buttonLabel} | |
| </Button> | |
| {altAction && altLink && ( | |
| <p | |
| className="text-center text-[var(--text-sm)] text-[var(--text-secondary)] mt-[var(--space-6)] m-0" | |
| style={{ textAlign: "center", fontSize: "var(--text-sm)", color: "var(--text-secondary)", marginTop: "var(--space-6)", margin: 0 }} | |
| > | |
| {altAction} | |
| <a | |
| href="#" | |
| className="text-[var(--color-primary)] font-medium hover:underline" | |
| style={{ color: "var(--color-primary)", fontWeight: 500 }} | |
| > | |
| {altLink} | |
| </a> | |
| </p> | |
| )} | |
| </form> | |
| ); | |
| }, | |
| ); | |
| AuthForm.displayName = "AuthForm"; | |