-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
67 lines (62 loc) · 1.5 KB
/
App.js
File metadata and controls
67 lines (62 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import './App.css';
import Alert from './components/Alert';
import Navbar from './components/Navbar';
import TextForm from './components/TextForm';
import About from './components/About';
import React,{useState} from 'react';
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from "react-router-dom";
function App() {
const[mode,setMode]= useState('light'); //check whether dark mode is enabled
const[alert,setAlert]= useState(null);
const showAlert=(message,type)=>{
setAlert({
msg:message,
type:type
});
setTimeout(()=>{
setAlert(null);
},2000);
};
const toggleMode=()=>{
if(mode==='dark'){
setMode('light');
document.body.style.backgroundColor = 'white';
showAlert("Light mode is enabled","success");
document.title="Textyy:Light mode";
//setInterval(()=>{
//document.title="install now"; for blinging title
//},2000)
// };
}
else{
setMode('dark');
document.body.style.backgroundColor = '#191b24';
showAlert("Dark mode is enabled","success");
document.title="Textyy:Dark mode";
}
}
return (
<>
<Router>
<Navbar title="Textyy" mode={mode} toggleMode={toggleMode}/>
<Alert alert={alert}></Alert>
<div className="container my-3">
<Switch>
<Route exact path="/about">
<About />
</Route>
<Route exact path="/">
<TextForm heading="Text Analyze" mode={mode} showAlert={showAlert}/>
</Route>
</Switch>
</div>
</Router>
</>
);
}
export default App;