Overview
Layout components define the overall page structure for different user roles in the Happy Habitat application. They compose shared components (header, menu, footer) with Angular’s<router-outlet> to create consistent page templates.
Location: src/app/layouts/
Layout Architecture
All layouts follow a similar structure:Main Application Layout
The root application layout is defined inapp.component.ts.
Location: src/app/app.component.ts:1
Structure
Template Structure
Features
- Conditional Layout: Different layouts for auth vs. main app
- Responsive: Flexbox-based responsive layout
- Global Notifications: Toast notifications container
- Route Awareness: Tracks previous URL for 404 handling
Resident Layout
Layout for resident-facing pages. Location:src/app/layouts/resident/resident-actividades-layout.ts:1
Component
Template
Sections
Resident layout typically includes navigation for:- Home/Dashboard
- My Payments
- My Vehicles
- My Pets
- Visitors
- Amenity Reservations
- Announcements
- Documents
- Support Tickets
Admin Company Layout
Layout for community administration pages. Location:src/app/layouts/admincompany/admincompany-actividades-layout.ts:1
Component
Template
Sections
Admin company layout includes navigation for:- Dashboard
- Resident Management
- Payment Management
- Delinquent Accounts
- Bank Balances
- Amenity Management
- Announcement Management
- Document Management
- Survey Management
- Configuration
System Admin Layout
Layout for system administrator pages. Location:src/app/layouts/sysadmin/system-admin-layout.ts:1
Sections
System admin layout includes:- User Management
- Community Management
- System Configuration
- Logs and Monitoring
- Backup and Restore
Vigilancia (Security) Layout
Layout for security guard pages. Location:src/app/layouts/vigilancia/vigilancia-actividades-layout.ts:1
Sections
Vigilancia layout includes:- Visitor Check-in/Check-out
- Vehicle Registration Verification
- Access Log
- Emergency Alerts
- Incident Reports
Amenidades (Amenities) Layout
Layout for amenity management pages. Location:src/app/layouts/amenidades/amenidades-layout.ts:1
Sections
Amenidades layout includes:- Amenity List
- Reservation Calendar
- Availability Management
- Pricing Configuration
Layout Patterns
Top Menu Navigation
Most layouts use a top menu component for section navigation:Content Container
Standard content container pattern:p-4: Padding on all sidesmax-w-7xl: Maximum width constraintmx-auto: Center horizontally
Responsive Layout
Layouts use Tailwind’s responsive utilities:Routing Configuration
Layouts are configured in route definitions:Route Guards
- AuthGuard: Verifies user is authenticated
- AdminGuard: Verifies user has admin role
- RoleGuard: Generic role-based guard
Creating a New Layout
Step 1: Create Layout Component
Step 2: Configure Routes
Step 3: Update Left Menu
Add route to main navigation menu:Best Practices
1. Consistent Structure
All layouts should follow the same basic structure:- Top menu (if needed)
- Content container with proper padding
- Router outlet for child routes
2. Responsive Design
3. Role-Based Access
Always protect routes with appropriate guards:4. Menu Items Configuration
Define menu items in the layout component:5. Loading States
Show loading indicators in layout:6. Error Boundaries
Implement error handling in layouts:Layout Components Checklist
When creating a new layout:- Create layout component in
src/app/layouts/{role}/ - Define menu items with routes, labels, and icons
- Add responsive container with proper padding
- Include
<router-outlet>for child routes - Configure routes in
app.routes.ts - Add appropriate route guards
- Update main navigation menu if needed
- Test on mobile, tablet, and desktop viewports
- Verify accessibility (keyboard navigation, ARIA labels)
- Add loading and error states
Common Layout Issues
Issue: Menu Not Highlighting Active Route
Solution: UserouterLinkActive directive:
Issue: Layout Shifts on Route Change
Solution: Use consistent container heights:Issue: Nested Layouts Not Working
Solution: Ensure child routes are properly configured:Next Steps
- Shared Components - Reusable UI components
- Component Architecture - Overall architecture
- Routing & Navigation - Advanced routing patterns
- Authentication Service - Security and request handling