Overview
TheMenuBar component renders a macOS-inspired system bar at the top of the screen. It displays the portfolio branding on the left and a live clock with date on the right, creating an authentic desktop OS experience.
Features
- Fixed Top Bar: Always visible at the top of the viewport
- Live Clock: Updates every second with current time
- Date Display: Shows weekday, month, and day
- Glassmorphism: Translucent background with backdrop blur
- Responsive: Hides some elements on small screens
- No Props Required: Self-contained component
Props
The MenuBar component accepts no props. It’s a fully self-contained component.Usage Examples
Structure
The MenuBar is a fixed bar with two sections:Left Section: Branding
The left side displays the Apple logo and portfolio branding:Hover Effects
Each text item has a subtle hover effect:Right Section: Time & Date
The right side shows live time and date:Time Update Logic
The component usessetInterval to update every second:
Formatting
Cleanup
The interval is properly cleaned up on unmount:Styling
The MenuBar uses glassmorphism for a modern macOS look:Background Effect
Typography
Spacing
Z-Index
The MenuBar usesz-[9999] to ensure it stays above all content:
Responsive Design
On small screens, some elements are hidden:Breakpoints
Tailwind’ssm: breakpoint is 640px:
- < 640px: Shows logo, name, and time only
- ≥ 640px: Shows logo, name, “Portfolio” label, date, and time
Performance Considerations
Interval Optimization
The component updates every second, which is efficient for a clock:Render Optimization
The component is lightweight and doesn’t need memoization. Each re-render updates only the time strings.Customization
Change Height
Change Colors
Add Menu Items
Change Locale
Integration with Desktop
The MenuBar is rendered at the top level of the Desktop component:- Top 28px (
top-7): MenuBar space - Bottom 80px (
bottom-20): Dock space - Middle area: Workspace for windows and icons