Skip to content

Commit 6a7121b

Browse files
committed
Video 20 completed
1 parent 27893ff commit 6a7121b

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

src/App.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,22 @@ function App() {
2525
}, 1500);
2626
}
2727

28-
const toggleMode = ()=>{
28+
const removeBodyClasses = ()=>{
29+
document.body.classList.remove('bg-light')
30+
document.body.classList.remove('bg-dark')
31+
document.body.classList.remove('bg-warning')
32+
document.body.classList.remove('bg-danger')
33+
document.body.classList.remove('bg-success')
34+
}
35+
36+
const toggleMode = (cls)=>{
37+
removeBodyClasses();
38+
console.log(cls)
39+
document.body.classList.add('bg-'+cls)
2940
if(mode === 'light'){
3041
setMode('dark');
3142
document.body.style.backgroundColor = '#042743';
32-
showAlert("Dark mode has been enabled", "success");
33-
// document.title = 'TextUtils - Dark Mode';
34-
// setInterval(() => {
35-
// document.title = 'TextUtils is Amazing Mode';
36-
// }, 2000);
37-
// setInterval(() => {
38-
// document.title = 'Install TextUtils Now';
39-
// }, 1500);
43+
showAlert("Dark mode has been enabled", "success");
4044
}
4145
else{
4246
setMode('light');

src/components/Navbar.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ export default function Navbar(props) {
2020
<Link className="nav-link" to="/about">{props.aboutText}</Link>
2121
</li>
2222
</ul>
23-
{/* <form className="d-flex">
24-
<input className="form-control me-2" type="search" placeholder="Search" aria-label="Search" />
25-
<button cla
26-
ssName="btn btn-primary" type="submit">Search</button>
27-
</form> */}
28-
<div className={`form-check form-switch text-${props.mode==='light'?'dark':'light'}`}>
29-
<input className="form-check-input" onClick={props.toggleMode} type="checkbox" id="flexSwitchCheckDefault"/>
30-
<label className="form-check-label" htmlFor="flexSwitchCheckDefault">Enable DarkMode</label>
23+
<div className="d-flex">
24+
<div className="bg-primary rounded mx-2" onClick={()=>{props.toggleMode('primary')}} style={{height: '30px', width:'30px', cursor: 'pointer'}}></div>
25+
<div className="bg-danger rounded mx-2" onClick={()=>{props.toggleMode('danger')}} style={{height: '30px', width:'30px', cursor: 'pointer'}}></div>
26+
<div className="bg-success rounded mx-2" onClick={()=>{props.toggleMode('success')}} style={{height: '30px', width:'30px', cursor: 'pointer'}}></div>
27+
<div className="bg-warning rounded mx-2" onClick={()=>{props.toggleMode('warning')}} style={{height: '30px', width:'30px', cursor: 'pointer'}}></div>
28+
<div className="bg-light rounded mx-2" onClick={()=>{props.toggleMode('light')}} style={{height: '30px', width:'30px', cursor: 'pointer'}}></div>
29+
<div className="bg-dark rounded mx-2" onClick={()=>{props.toggleMode('dark')}} style={{height: '30px', width:'30px', cursor: 'pointer'}}></div>
3130
</div>
31+
32+
3233
</div>
3334
</div>
3435
</nav>

0 commit comments

Comments
 (0)