Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
import {observer} from 'mobx-react';
import {Link} from 'react-router-dom';
import {useLocation} from 'react-router-dom';
import hasRole from '@aosprodsys/brucke-ui-core/dist/es/utils/hasRole';
import LinkConstants from '../constants/LinkConstants';
import {StoreContext} from '../utils/StoreContext';
import styles from '../sass/components/left-nav.scss';
export const LeftNav = () => {
const {
appState: {isLeftNavOpen, user}
} = React.useContext(StoreContext);
const location = useLocation(),
{pathname = ''} = location || {};
const [expandedMenus, setExpandedMenus] = useState({});
const toggleMenu = name => {
setExpandedMenus(prev => ({...prev, [name]: !prev[name]}));
};
return (
<section className={`${styles.leftNav} left-nav ${isLeftNavOpen ? 'open' : ''}`}>
<div className="links-wrapper">
{LinkConstants.map((link, ind) => {
if (link.requiredRoles && !hasRole(link.requiredRoles, user?.roles)) return null;
if (link.url) {
return (
<Link key={ind} to={link.url} className={`${pathname === link.url ? 'active' : ''} list-link`}>
<div className="global-body-medium nav-item main-nav">{link.name}</div>
</Link>
);
}
const isExpanded = !!expandedMenus[link.name];
const hasSubmenu = link.links && link.links.length > 0;
return (
<div key={ind}>
<div className="list-link" onClick={() => hasSubmenu && toggleMenu(link.name)}>
<div className={`${pathname === link.url ? 'active' : ''} global-body-medium nav-item main-nav`}>
{link.name}
</div>
{hasSubmenu && <span className={`expand-icon ${isExpanded ? 'icon-chevronup' : 'icon-chevrondown'}`} />}
</div>
{hasSubmenu && isExpanded && <SubNav navObj={link} key={ind} user={user} pathname={pathname} />}
</div>
);
})}
</div>
</section>
);
};
export const SubNav = ({navObj, user, pathname}) => {
const [expandedMenus, setExpandedMenus] = useState({});
const toggleSubmenu = name => {
setExpandedMenus(prevMenus => ({...prevMenus, [name]: !prevMenus[name]}));
};
return (
<section className={`subnav-container`}>
{navObj?.links?.map((link, index) => {
const isSubMenuOpen = !!expandedMenus[link.name];
const hasSubMenu = link.links && link.links.length > 0;
return (
<div key={index}>
<div className="list-link">
<Link to={link.url} className={`${pathname === link.url ? 'active' : ''}`}>
<div className="global-body-medium nav-item main-nav">{link.name}</div>
</Link>
{hasSubMenu && (
<span
className={`icon ${isSubMenuOpen ? 'icon-chevronup' : 'icon-chevrondown'}`}
onClick={() => toggleSubmenu(link.name)}
/>
)}
</div>
{hasSubMenu &&
isSubMenuOpen && (
<div className={`list-wrapper ${isSubMenuOpen ? 'open' : ''}`}>
{link.links.map((sublink, subIndex) => (
<Link
to={sublink.url}
className={`${pathname === sublink.url ? 'active' : ''} list-link`}
key={subIndex}
>
<div className="global-body-medium nav-item sub-nav">{sublink.name}</div>
</Link>
))}
</div>
)}
</div>
);
})}
</section>
);
};
export default observer(LeftNav);
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team