-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
102 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React, { useState } from "react"; | ||
import util from "../styles/Util.module.css"; | ||
|
||
export default () => { | ||
const [email, setEmail] = useState(""); | ||
const [hover, setHover] = useState(false); | ||
|
||
const emailInputStyle = { | ||
display: "flex", | ||
flexDirection: "row", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
display: "block", | ||
fontSize: "1.5rem", | ||
fontWeight: "bold", | ||
cursor: "pointer", | ||
color: hover ? "#fbda61" : "#FFFFFF", | ||
}; | ||
|
||
const labelStyle = { | ||
cursor: "pointer", | ||
}; | ||
|
||
const handleChange = (e) => { | ||
setEmail(e.target.value); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div | ||
style={emailInputStyle} | ||
onMouseEnter={() => setHover(true)} | ||
onMouseLeave={() => setHover(false)} | ||
> | ||
<label htmlFor="email" style={labelStyle}> | ||
</label> | ||
<input | ||
id="email" | ||
type="email" | ||
value={email} | ||
onChange={handleChange} | ||
required | ||
className={util["input"]} | ||
/> | ||
</div> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Import necessary packages, styles, and components | ||
import info from "../styles/Info.module.css"; | ||
import React, { useState } from "react"; | ||
import util from "../styles/Util.module.css"; | ||
import EmailForm from "../components/EmailForm"; | ||
|
||
// Default component function | ||
export default () => { | ||
// Create state for number and darkTheme using useState hook | ||
const [number, setNumber] = useState(() => 0); | ||
|
||
const style = { | ||
color: "#fbda61", | ||
}; | ||
|
||
return ( | ||
<> | ||
{/* Header and Explanation about useId */} | ||
<h1 className={util["header-1"]}>- useId -</h1> | ||
<h2 className={`${info["info"]} ${info["border-bottom"]}`}> | ||
<span>useId</span> is a React hook that generates a unique id for a | ||
component or HTML element. This hook is useful when you need to assign | ||
unique identifiers to elements, especially for accessibility purposes | ||
such as linking labels with form controls. When the component | ||
re-renders, the <span>useId</span> hook ensures the same unique id is | ||
returned, maintaining consistency across re-renders. This approach helps | ||
in avoiding the re-generation of ids, thereby maintaining the | ||
association between elements and improving overall accessibility and | ||
functionality. | ||
</h2> | ||
|
||
{/* */} | ||
<EmailForm /> | ||
<h2 | ||
className={`${info["info"]} ${info["border-top"]} ${info["border-bottom"]}`} | ||
> | ||
By clicking on the <b style={style}>"Email"</b> text{" "} | ||
<b style={style}>below</b>, the corresponding input field{" "} | ||
<b style={style}> above </b> is activated. This interaction is made | ||
possible because both input fields share the same id, generated by the{" "} | ||
<span>useId</span> hook. | ||
</h2> | ||
<EmailForm /> | ||
</> | ||
); | ||
}; |