Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b41ee25

Browse files
committedDec 19, 2022
update app
1 parent fded067 commit b41ee25

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed
 

‎project-1/project-app/src/App.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function App() {
1414
msg: message,
1515
type: type
1616
})
17+
setTimeout(() => {
18+
setAlert(null);
19+
}, 1500);
1720
}
1821

1922
const toggleMode = () => {
@@ -37,7 +40,7 @@ function App() {
3740
<div className="container my-3">
3841
{/* <TextForm heading = "Enter the text to analyze below"/> */}
3942
{/* <About /> */}
40-
<TextForm mode={mode} />
43+
<TextForm showAlert={showAlert} mode={mode} />
4144
</div>
4245
</>
4346
);

‎project-1/project-app/src/components/Alert.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import React from 'react';
22

33
function Alert(props) {
4+
5+
const capitalize = (word) =>{
6+
const lower = word.toLowerCase();
7+
return lower.charAt(0).toUpperCase() + lower.slice(1);
8+
}
49
return (
5-
props.alert && <div className="alert alert-warning alert-dismissible fade show" role="alert">
6-
<strong>{props.alert.type}</strong>: {props.alert.msg}
7-
<button type="button" className="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
10+
props.alert && <div className={`alert alert-${props.alert.type} alert-dismissible fade show`} role="alert">
11+
<strong>{capitalize(props.alert.type)}</strong>: {props.alert.msg}
812
</div>
913
)
1014
}

‎project-1/project-app/src/components/TextForm.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@ export default function TextForm(props) {
88
console.log("upperCase was clicked" + text);
99
let newText = text.toUpperCase();
1010
setText(newText);
11+
props.showAlert("Converted to upperCase!" , "success");
1112
}
1213

1314
const handleLoClick = () => {
1415
console.log("lowerCase was clicked" + text);
1516
let newText = text.toLowerCase();
1617
setText(newText);
18+
props.showAlert("Converted to lowerCase!" , "success");
1719
}
1820

1921
const handleClearClick = () => {
2022
console.log("clear the text" + text);
2123
let newText = "";
2224
setText(newText);
25+
props.showAlert("cleared the text!" , "success");
2326
}
2427

2528
const handleReverseClick = () => {
@@ -34,6 +37,7 @@ export default function TextForm(props) {
3437
return output.join("");
3538
};
3639
setText(newText);
40+
props.showAlert("Converted to reverse form!" , "success");
3741
}
3842

3943
const handleCapitalizeClick = () => {
@@ -48,6 +52,7 @@ export default function TextForm(props) {
4852
return finalStr;
4953
}
5054
setText(newText);
55+
props.showAlert("Converted to captilize of each word!" , "success");
5156
}
5257

5358

@@ -61,6 +66,7 @@ export default function TextForm(props) {
6166
<div className="container" style={{color: props.mode ==='dark' ? 'white' : 'black'}}>
6267
<h1>{props.heading}</h1>
6368
<div className="mb-3">
69+
<label htmlFor="exampleFormControlTextarea1" className="form-label"><h2>Enter the text</h2></label>
6470
<textarea className="form-control" value={text} onChange={handleOnChange} style={{backgroundColor: props.mode ==='dark' ? 'gray' : 'white' , color: props.mode ==='dark' ? 'white' : 'black' }} id="myBox" rows="8" ></textarea>
6571
</div>
6672
<button className="btn btn-primary mx-2" onClick={handleUpClick}>Convert to UpperCase</button>
@@ -70,7 +76,7 @@ export default function TextForm(props) {
7076
<button className="btn btn-primary mx-2" onClick={handleReverseClick}>reverse words</button>
7177
</div>
7278
<div className="container my-4" style={{color: props.mode ==='dark' ? 'white' : 'black'}}>
73-
<h1>your text summary</h1>
79+
<h2>your text summary</h2>
7480
<p>{text.split(" ").length} words and {text.length} characters </p>
7581
<p>{0.008 * text.split(" ").length} Minutes read</p>
7682
<h2>Preview</h2>

0 commit comments

Comments
 (0)
Please sign in to comment.