Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add InputOTP component for OTP input functionality #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lightyfr
Copy link
Contributor

@lightyfr lightyfr commented Dec 9, 2024

This pull request introduces a new InputOTP component, along with its associated styles, to the once-ui library. The most important changes include adding the InputOTP component, defining its styles, and updating the component exports.

New InputOTP component:

Styling for InputOTP:

Component export updates:

Prop OnComplete and OnError integrates with Toaster

Ex.

 const [toasts, setToasts] = useState<Toast[]>([]);
  const removeToast = (id: string) => {
    setToasts((prev) => prev.filter((toast) => toast.id !== id));
  };

  const addToast = (message: string, variant: "success" | "danger") => {
    const newToast = {
      id: uuidv4(),
      message,
      variant,
    };
    setToasts((prev) => [...prev, newToast]);
  };
<Toaster toasts={toasts} removeToast={removeToast} />
<InputOTP
        onComplete={(code) => {
          console.log("Complete:", code);
          addToast("OTP verified successfully!", "success");
        }}
        onError={(message) => {
          addToast(message, "danger");
        }}
      />

Demo

Note that the card below the InputOTP is not part of the design but now that i think idea it may look better lol
https://github.com/user-attachments/assets/422a499c-010d-404b-b801-e80b7191e2f4

Copy link

vercel bot commented Dec 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
once-ui-starter ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 9, 2024 2:57am

@zsofiakm
Copy link
Contributor

Thanks very much for this new component, @lightyfr! We'll be adding to the upcoming v0.5 release this month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants