Skip to content

Commit 8046d5a

Browse files
Video 16 Completed
1 parent f665055 commit 8046d5a

File tree

13 files changed

+169
-10
lines changed

13 files changed

+169
-10
lines changed

package-lock.json

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@testing-library/user-event": "^12.8.3",
99
"react": "^17.0.2",
1010
"react-dom": "^17.0.2",
11+
"react-router-dom": "^5.2.0",
1112
"react-scripts": "4.0.3",
1213
"web-vitals": "^1.1.2"
1314
},

public/favicon-16x16.png

838 Bytes
Loading

public/favicon-32x32.png

996 Bytes
Loading

public/favicon-96x96.png

1.57 KB
Loading

public/favicon.ico

-2.66 KB
Binary file not shown.

public/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
<meta name="theme-color" content="#000000" />
88
<meta
99
name="description"
10-
content="Web site created using create-react-app"
10+
content="TextUtils is a utility which can be used to manipulate your text in the way you want."
1111
/>
12-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
12+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/favicon-16x16.png" />
1313
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
1414
<!-- Bootstrap CSS -->
1515
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
1616

17-
<title>React App</title>
17+
<title>TextUtils - Home</title>
1818
</head>
1919
<body>
2020
<noscript>You need to enable JavaScript to run this app.</noscript>

public/logo192.png

-5.22 KB
Binary file not shown.

public/logo512.png

-9.44 KB
Binary file not shown.

src/App.js

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,71 @@
11
import './App.css';
22
import Navbar from './components/Navbar';
33
import TextForm from './components/TextForm';
4+
import About from './components/About';
45
import React, { useState } from 'react';
6+
import Alert from './components/Alert';
7+
import {
8+
BrowserRouter as Router,
9+
Switch,
10+
Route,
11+
Link
12+
} from "react-router-dom";
513

614

715
function App() {
816
const [mode, setMode] = useState('light'); // Whether dark mode is enabled or not
17+
const [alert, setAlert] = useState(null);
18+
19+
const showAlert = (message, type)=>{
20+
setAlert({
21+
msg: message,
22+
type: type
23+
})
24+
setTimeout(() => {
25+
setAlert(null);
26+
}, 1500);
27+
}
928

1029
const toggleMode = ()=>{
1130
if(mode === 'light'){
1231
setMode('dark');
1332
document.body.style.backgroundColor = '#042743';
33+
showAlert("Dark mode has been enabled", "success");
34+
document.title = 'TextUtils - Dark Mode';
35+
// setInterval(() => {
36+
// document.title = 'TextUtils is Amazing Mode';
37+
// }, 2000);
38+
// setInterval(() => {
39+
// document.title = 'Install TextUtils Now';
40+
// }, 1500);
1441
}
1542
else{
1643
setMode('light');
1744
document.body.style.backgroundColor = 'white';
45+
showAlert("Light mode has been enabled", "success");
46+
document.title = 'TextUtils - Light Mode';
1847
}
1948
}
2049
return (
2150
<>
2251
{/* <Navbar title="TextUtils" aboutText="About TextUtils" /> */}
2352
{/* <Navbar/> */}
53+
<Router>
2454
<Navbar title="TextUtils" mode={mode} toggleMode={toggleMode} />
55+
<Alert alert={alert}/>
2556
<div className="container my-3">
26-
<TextForm heading="Enter the text to analyze below" mode={mode}/>
57+
<Switch>
58+
{/* /users --> Component 1
59+
/users/home --> Component 2 */}
60+
<Route exact path="/about">
61+
<About />
62+
</Route>
63+
<Route exact path="/">
64+
<TextForm showAlert={showAlert} heading="Enter the text to analyze below" mode={mode}/>
65+
</Route>
66+
</Switch>
2767
</div>
68+
</Router>
2869
</>
2970
);
3071
}

0 commit comments

Comments
 (0)