-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added active class #139
added active class #139
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import React, { useContext, useEffect, useState } from 'react' | ||
import './Sidenav.css' | ||
import { Link, useNavigate } from 'react-router-dom'; | ||
import { Link, useNavigate, useLocation } from 'react-router-dom'; | ||
import logo from '../../assets/logo.png' | ||
import GlobalContext from '../../context/GlobalContext'; | ||
import NotesContext from '../../context/NotesContext'; | ||
|
||
const Sidenav = () => { | ||
const location = window.location.pathname; | ||
const { theme ,setTheme } = useContext(GlobalContext) | ||
const { getNotes } = useContext(NotesContext) | ||
const [search, setSearch] = useState('') | ||
|
@@ -68,14 +69,14 @@ const Sidenav = () => { | |
</li> | ||
|
||
<ul className="menu-links"> | ||
<li className="nav-link"> | ||
<li className={`nav-link ${location === '/notes'?"active":""}`}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For automatically adding the active class according to the url |
||
<Link to={'/notes'}> | ||
<i className="fa-solid fa-house icon"></i> | ||
<span className="text nav-text">Dashboard</span> | ||
</Link> | ||
</li> | ||
|
||
<li className="nav-link"> | ||
<li className={`nav-link ${location === '/myaccount' ? "active" : ""}`}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For automatically adding the active class according to the url |
||
<Link to={'/myaccount'}> | ||
<i className="fa-solid fa-circle-user icon"></i> | ||
<span className="text nav-text">My Account</span> | ||
|
@@ -89,7 +90,7 @@ const Sidenav = () => { | |
</a> | ||
</li> | ||
|
||
<li className="nav-link"> | ||
<li className={`nav-link ${location === '/bin' ? "active" : ""}`}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For automatically adding the active class according to the url |
||
<Link to={'/bin'}> | ||
<i className="fa-solid fa-trash icon"></i> | ||
<span className="text nav-text">Bin</span> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for active class background color