Skip to content

input_otp: replace otp.js with pure Rust and fix demo structure#35

Open
krishpranav wants to merge 1 commit intorust-ui:mainfrom
krishpranav:feat/issue-26-otp-rust-migration
Open

input_otp: replace otp.js with pure Rust and fix demo structure#35
krishpranav wants to merge 1 commit intorust-ui:mainfrom
krishpranav:feat/issue-26-otp-rust-migration

Conversation

@krishpranav
Copy link
Copy Markdown
Contributor

Description:

The OTP component still depended on a JavaScript controller and the docs page was rendering the OTP demos through one shared wrapper that made the layout feel wrong.
This patch moves the OTP controller into Rust with web_sys, removes the runtime JS file, and restructures the Input OTP docs page so each demo block behaves independently with its own local Preview and Code controls.

What changed:

  • Replaced the OTP JavaScript controller with a Rust web_sys implementation in use_input_otp
  • Wired InputOTP to initialize the Rust controller directly and removed the script tag
  • Deleted public/app_components/otp.js
  • Updated the registry snapshots and tree entries for the Rust-based OTP implementation
  • Rebuilt demo_input_otp.rs so the OTP page renders independent demo blocks for basic input, 4-digit variant, digit filter, focus/blur, and post-hydration init
  • Added per-block Preview and Code toggles with block-local state for the OTP docs page
  • Bypassed the shared top-level demo wrapper controls for the Input OTP page so the local block controls are the only ones shown

Validation:

cargo build
cargo clippy -- -D warnings

Screenshot

Input OTP demo screenshot 1 Input OTP demo screenshot 2

Input OTP demo screenshot 3

Closes #26

Replace the OTP JavaScript controller with a Rust/web_sys implementation and wire InputOTP to initialize it directly. Update the docs demo so each OTP scenario renders as an independent block with its own local Preview and Code controls, and bypass the shared demo wrapper toolbar for the OTP page so the layout matches the intended structure.
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.

Replace otp.js with a Rust implementation using web_sys

1 participant