Skip to content
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

Add hover text #261

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions src/components/Sidebar/SideBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,18 @@ const showAnimation = {
const SideBar = ({ routes, children }) => {
const [isOpen, setIsOpen] = useState(false);
const location = useLocation();
const [modes,setModes]=useState("Dark")
const [modes, setModes] = useState("Dark");

useEffect(() => {
const currentCategory = getCurrentCategory();
const scrollbarColor = getScrollbarColor(currentCategory);
applyScrollbarColor(scrollbarColor);
}, [location]); // Watch for changes in location state
}, [location]);

const getCurrentCategory = () => {
const currentPath = location.pathname;
const category = routes.find((route) => currentPath.startsWith(route.path));
return currentPath; // Return the category name
return currentPath;
};

const getScrollbarColor = (currentPath) => {
Expand Down Expand Up @@ -94,16 +95,15 @@ const SideBar = ({ routes, children }) => {

const toggle = () => setIsOpen(!isOpen);

const modes_control=()=>{
document.body.classList.toggle('light')
if(document.body.classList.contains('light')){
setModes("Light")
const modes_control = () => {
document.body.classList.toggle('light');
if (document.body.classList.contains('light')) {
setModes("Light");
} else {
setModes("Dark");
}
else{
setModes("Dark")
}
}
console.log(modes)
};

return (
<>
<div className='main-container'>
Expand Down Expand Up @@ -148,14 +148,19 @@ const SideBar = ({ routes, children }) => {
showAnimation={showAnimation}
isOpen={isOpen}
setIsOpen={setIsOpen}
routes={routes} // Pass the routes prop here
routes={routes}
/>

);
}

return (
<NavLink to={route.path} key={index} className='link' activeClassName='active'>
<NavLink
to={route.path}
key={index}
className='link'
activeClassName='active'
title={route.name} // Add hover text here
>
<div className='circle'>
<div className='icon'>{route.icon}</div>
</div>
Expand All @@ -169,11 +174,11 @@ const SideBar = ({ routes, children }) => {
</NavLink>
);
})}
<div className={isOpen?"opened_menu_bar":'Dark_Light_mode'} onClick={()=>modes_control()}>
<img src='https://cdn-icons-png.flaticon.com/128/12301/12301351.png' alt='Dark_light_mode' />
{isOpen?<p>{modes}</p>:<></>}
<div className={isOpen ? "opened_menu_bar" : 'Dark_Light_mode'} onClick={modes_control}>
<img src='https://cdn-icons-png.flaticon.com/128/12301/12301351.png' alt='Dark_light_mode' />
{isOpen ? <p>{modes}</p> : <></>}
</div>
</section>
</section>
</motion.div>

<main style={{ marginLeft: 'auto', transition: 'all 0.3s' }}>{children}</main>
Expand Down