Skip to content

Commit 497602a

Browse files
committed
added 'Convert to lower case' btn, 'Text summary' div and a 'preview text' div
1 parent f755ca0 commit 497602a

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/componets/TextForm.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ export default function TextForm(props) {
99
setText(e.target.value);
1010
};
1111

12+
const handleLowClick = (e) => {
13+
setText(text.toLowerCase());
14+
};
1215
const [text, setText] = useState("");
1316
return (
1417
<>
15-
<div className="mb-3">
18+
<div className="mb-3 container">
1619
<label htmlFor="myBox" className="form-label">
1720
<h2>{props.heading}:</h2>
1821
</label>
@@ -23,10 +26,26 @@ export default function TextForm(props) {
2326
className="form-control"
2427
id="myBox"
2528
rows="10"></textarea>
29+
<button
30+
onClick={handleUpClick}
31+
className="btn btn-primary my-2">
32+
Convert to UPPER CASE
33+
</button>
34+
<button
35+
onClick={handleLowClick}
36+
className="btn btn-primary my-2 mx-4">
37+
Convert to lower case
38+
</button>
39+
</div>
40+
<div className="container-fluid my-2">
41+
<h1>Your Text Summary</h1>
42+
<p>
43+
{text.split(" ").length} words, {text.length} chars
44+
</p>
45+
<p>{0.008 * text.split(" ").length} to read</p>
46+
<h2>preview text</h2>
47+
<p>{text}</p>
2648
</div>
27-
<button onClick={handleUpClick} className="btn btn-primary">
28-
Convert to UPPER CASE
29-
</button>
3049
</>
3150
);
3251
}

0 commit comments

Comments
 (0)