Overview
TheWindowDropDowns component creates the classic Windows XP menu bar found at the top of applications like Internet Explorer, Notepad, and Minesweeper. It handles keyboard navigation, hover interactions, and nested submenus.
Component Structure
Main Component: WindowDropDowns
Location:src/components/WindowDropDowns/index.jsx
Manages the top-level menu bar with labels like “File”, “Edit”, “View”.
Sub Component: WindowDropDown
Location:src/components/WindowDropDowns/WindowDropDown.jsx
Renders individual dropdown menus with items, separators, and nested submenus.
Props API
WindowDropDowns
Menu structure object where keys are menu labels (e.g., “File”, “Edit”) and values are arrays of menu items
Callback function called when a menu item is clicked
Additional CSS class for styling
Height of the menu bar in pixels
WindowDropDown
Array of menu item objects (see Item Structure below)
CSS positioning object (top, left, right, bottom)
Click handler for menu items
Item Structure
Menu items can be one of three types:Type: “item”
Standard clickable menu item:Type: “separator”
Visual separator line:Type: “menu”
Nested submenu:Usage Example
Basic Implementation
Real-World Example: Internet Explorer
Source:src/WinXP/apps/InternetExplorer/index.jsx:271-276
Styled-Components Implementation
WindowDropDowns Styling
Source:src/components/WindowDropDowns/index.jsx:58-79
WindowDropDown Styling
Source:src/components/WindowDropDowns/WindowDropDown.jsx:99-207
Key styling features:
- Grid Layout: Uses CSS Grid for precise menu item alignment
- Hover Effects: Blue highlight (#e99f17) with invert filter
- Shadows: Drop shadows for depth
- Arrow Indicators: CSS triangles for submenu indicators
Behavior Details
Hover State Management
Source:src/components/WindowDropDowns/index.jsx:12-14
Click Outside Detection
Source:src/components/WindowDropDowns/index.jsx:20-28
Symbol Icons
Source:src/components/WindowDropDowns/WindowDropDown.jsx:73-97
Supported symbol types:
| Symbol | Description | Usage |
|---|---|---|
ie-paper | Internet Explorer document icon | Document actions |
ie-book | Internet Explorer book icon | Help, documentation |
folder | Folder icon | Directory operations |
check | Checkmark | Selected/enabled state |
circle | Filled circle | Radio selection |
Applications Using WindowDropDowns
- Internet Explorer (
src/WinXP/apps/InternetExplorer/index.jsx) - Notepad (
src/WinXP/apps/Notepad/index.jsx) - Minesweeper (
src/WinXP/apps/Minesweeper/MinesweeperView.jsx) - My Computer (
src/WinXP/apps/MyComputer/index.jsx)
Best Practices
- Consistent Hotkey Formatting: Use Windows-style shortcuts (e.g., “Ctrl+S”, “Alt+F4”)
- Separator Usage: Group related menu items with separators
- Disable State: Use
disable: truefor unavailable actions rather than hiding items - Nested Menus: Limit nesting to 2-3 levels for usability
- Click Handler: Use a switch statement for clean action routing
See Also
- SubMenu Component - Alternative menu component used in the Start menu
- Styled-Components Documentation
