Overview
TheMenu component provides a collapsible sidebar navigation that allows users to navigate between different sections of the application. It features a logo, navigation links with icons, and a user profile section.
Component Definition
The CSS selector used to include this component in templates
Standalone component with explicit imports
Dependencies:
RouterLink, RouterLinkActiveSource Code Location
File:src/app/menu/menu.ts:5
Properties
isCollapsed
Controls the collapsed/expanded state of the sidebar menu
isCollapsed signal determines whether the sidebar shows full navigation labels or only icons.
Implementation: src/app/menu/menu.ts:11
Methods
toggleMenu()
Toggles the sidebar between collapsed and expanded states
src/app/menu/menu.ts:13-15
Template Structure
The menu is organized into three main sections:Header Section
Contains the application logo and name
Menu icon button that changes between
bx-menu and bx-menu-alt-right based on collapse stateNavigation Menu
The menu includes five navigation items:- Dashboard
- Pacientes
- Citas
- Calendario
- Tratamientos
Route:
/homeIcon: bx-grid-altOverview and statisticsProfile Section
Displays user information at the bottom of the sidebar:
- User icon (
bx-user-circle) - Name: “Dr. Admin”
- Role: “Administrador”
Router Integration
The component uses Angular Router directives for navigation:routerLink
routerLink directive enables navigation to specified routes when the list item is clicked.
routerLinkActive
routerLinkActive directive automatically adds the “active” class to the menu item when its route matches the current URL.
Usage
The Menu component is included in the main app layout:Dynamic Class Binding
The sidebar uses Angular’s class binding to toggle the collapsed state:isCollapsed() returns true, the “collapsed” class is added to the sidebar, triggering CSS transitions.
Toggle Icon
The toggle button icon changes based on the collapsed state:- Expanded: Shows
bx-menuicon - Collapsed: Shows
bx-menu-alt-righticon
Styling Behavior
The menu uses CSS transitions for smooth collapse/expand animations:- Expanded State
- Collapsed State
- Active State
- Full width sidebar (typically 250px)
- Navigation labels visible
- Profile details displayed
Icon Library
The component uses Boxicons for all icons. The icon classes follow the pattern:bx: Base Boxicons classbx-[icon-name]: Specific icon (e.g.,bx-user,bx-calendar)
Customization
Add New Menu Item
To add a new navigation link, add a list item to the menu:Change Logo
Replace the logo image source inmenu.html:4:
Dynamic User Profile
Replace static profile information with dynamic data:Persist Collapsed State
Store the collapsed state in localStorage:Accessibility
Consider adding ARIA attributes for better accessibility:Related Components
Header
Top navigation bar component
Architecture
Main application layout