This repository has been archived on 2026-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
Hayden Hargreaves 7a583ec1d6 (FEAT): Mobile friendly and code cleanup!
Cleaned the formatting with Nvim and created mobile friendly styles.
2025-05-27 22:38:12 -07:00

38 lines
904 B
JavaScript

import {useId, useState} from "react";
import "../index.css"
/**
* The email input element. A unique ID is generated. This element will
* fill the entire width of its parent. (w-full)
* @param {onChange}
* @returns {JSX.Element}
* @constructor
*/
export default function UserInput({onChange}) {
// Example of the controlled input state pattern
const [email, setEmail] = useState("");
// Generate ID for the input element
const id = useId();
/**
* Update the password controlled state
* @param event {InputEvent}
*/
const updateEmail = (event) => {
const email = event.target.value;
setEmail(email);
onChange(email);
}
return <input
type="text"
name={id}
value={email}
onInput={updateEmail}
placeholder="Username"
required={true}
className="border border-gray-300 rounded-sm py-2 px-4 placeholder:italic w-full my-2"
/>
}