Overview
Adding a new application to Web XP involves several steps:- Create the app component
- Add app assets (icons, images)
- Register the app in
appSettings - Add the app to desktop icons (optional)
- Add the app to the start menu (optional)
Step 1: Create the App Component
Create a new component for your app insrc/WinXP/apps/.
Example: Simple Calculator App
Createsrc/WinXP/apps/Calculator/index.jsx:
App Component Guidelines
Styling:- Use styled-components for all styling
- Match Windows XP visual style (colors:
#ece9d8,#d4d0c8,#fff) - Use borders:
2px outset #ffffor buttons
- The app fills its window container automatically
- Use
height: 100%to fill the window - Design for the default window size you’ll specify
- Apps receive
injectPropsfrom the window (if specified) - Example:
function MyApp({ message, title }) { ... }
Step 2: Add App Assets
Add icons and images tosrc/assets/windowsIcons/.
Icon Requirements
Two icon sizes:16x16- For window header and taskbar32x32- For desktop icons (optional, can reuse 16x16)
- PNG with transparency preferred
- Name convention:
appname(16x16).pngandappname(32x32).png
Example: Calculator Icons
Place these files:src/assets/windowsIcons/calc(16x16).pngsrc/assets/windowsIcons/calc(32x32).png
Step 3: Register in appSettings
Add your app to theappSettings object in src/WinXP/apps/index.jsx.
Import Your Component and Icons
At the top ofsrc/WinXP/apps/index.jsx:
Add to appSettings Object
Add an entry to theappSettings export (src/WinXP/apps/index.jsx:234):
appSettings Configuration Options
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | App name identifier |
header.icon | string | Yes | Path to 16x16 icon |
header.title | string | Yes | Window title text |
header.buttons | string[] | No | Button visibility (e.g., ['close'] for close only) |
header.noFooterWindow | boolean | No | If true, hides from taskbar |
header.invisible | boolean | No | If true, hides window chrome |
component | React.Component | Yes | The app component |
defaultSize.width | number | Yes | Initial window width in pixels |
defaultSize.height | number | Yes | Initial window height in pixels |
defaultOffset.x | number | Yes | Initial X position |
defaultOffset.y | number | Yes | Initial Y position |
resizable | boolean | Yes | Can window be resized? |
minimized | boolean | Yes | Start minimized? (usually false) |
maximized | boolean | Yes | Start maximized? |
multiInstance | boolean | Yes | Allow multiple windows? |
minWidth | number | No | Minimum window width |
minHeight | number | No | Minimum window height |
injectProps | object | No | Props to pass to component |
Helper Functions
getCenter(width, height)
Returns { x, y } to center the window:
src/WinXP/apps/index.jsx:65
shouldMaximize(width, height, isResizable)
Returns true if window should start maximized (e.g., on mobile or if window is too large for screen):
src/WinXP/apps/index.jsx:75
multiInstance vs Single Instance
multiInstance: true (multiple windows allowed):
- Each open creates a new window
- Examples: Notepad, Internet Explorer, Error dialogs
multiInstance: false (single window only):
- Opening again focuses existing window
- Examples: My Computer, Winamp, Paint
injectProps Example
Pass props to your app component:Step 4: Add to Desktop Icons
To add your app to the desktop, add an entry todefaultIconState in src/WinXP/apps/index.jsx:135:
Desktop Icon Properties
| Property | Type | Description |
|---|---|---|
id | number | Unique ID (use genId()) |
icon | string | Path to 32x32 icon |
title | string | Label shown under icon |
component | React.Component | The app component |
isFocus | boolean | Initially focused? (always false) |
appName | string | App name (matches appSettings key) |
Step 5: Add to Start Menu
To add your app to the start menu, modify theonClickMenuItem function in src/WinXP/index.jsx:138:
Footer component’s start menu configuration (in src/WinXP/Footer/).
Note: The exact implementation of start menu items depends on the Footer component structure. Refer to existing menu items for the pattern.
Complete Example: Adding Calculator
Here’s a complete example of all files to modify:1. Create component
src/WinXP/apps/Calculator/index.jsx (see Step 1 above)
2. Add icons
src/assets/windowsIcons/calc(16x16).pngsrc/assets/windowsIcons/calc(32x32).png
3. Update src/WinXP/apps/index.jsx
4. Update src/WinXP/index.jsx
5. Add to start menu
Modify theFooter component to include “Calculator” in the appropriate submenu.
Advanced: Conditional App Loading
Some apps should show error messages on certain devices or screen sizes:Wrapper Component Pattern
Seesrc/WinXP/apps/index.jsx:85 for examples:
appSettings:
Detection Functions
Mobile detection:src/WinXP/apps/index.jsx:41
Screen size detection:
src/WinXP/apps/index.jsx:50
Window Configuration Best Practices
Resizable Apps
For apps with flexible content (browsers, file explorers, text editors):Fixed-Size Apps
For apps with fixed layouts (games, calculators):Constrained Resizing
For apps that can resize but have minimum sizes:Chromeless Windows
For apps that manage their own window chrome (Winamp):Testing Your App
After adding your app:-
Test opening from desktop icon:
- Double-click icon
- Window appears with correct size and position
-
Test opening from start menu:
- Click Start
- Navigate to your app
- Window appears
-
Test window operations:
- Drag window
- Resize (if resizable)
- Minimize
- Maximize
- Close
- Focus (click on window)
-
Test multi-instance:
- If
multiInstance: true: multiple windows should open - If
multiInstance: false: should focus existing window
- If
-
Test taskbar:
- App appears in taskbar
- Clicking taskbar button minimizes/restores
- Icon and title are correct
-
Test mobile (if applicable):
- Open DevTools
- Toggle device toolbar
- Verify mobile warnings appear if expected
Troubleshooting
App doesn’t open
- Check console for errors
- Verify component is exported from
src/WinXP/apps/index.jsx - Verify
appSettingsentry is correct - Check
onClickMenuItemhas your case
Icon doesn’t appear on desktop
- Verify icon path is correct
- Check
defaultIconStatehas your entry - Verify
genId()is called forid
Window size is wrong
- Check
defaultSizeinappSettings - Use
getCenter()fordefaultOffset - Consider using
shouldMaximize()formaximized
Can’t resize window
- Set
resizable: trueinappSettings - Optionally add
minWidthandminHeight
Multiple windows open when they shouldn’t
- Set
multiInstance: falseinappSettings
App doesn’t appear in taskbar
- Remove or set
header.noFooterWindow: false - Verify app is in
state.apps(check with React DevTools)
Examples from Existing Apps
Refer to these existing apps for examples:- Simple app:
src/WinXP/apps/ErrorBox/- Basic dialog - Complex app:
src/WinXP/apps/MyComputer/- Navigation and state - Game:
src/WinXP/apps/Minesweeper/- Game logic and UI - Embedded iframe:
src/WinXP/apps/InternetExplorer/- Iframe wrapper - Custom chrome:
src/WinXP/apps/Winamp/- No window header
Next Steps
After adding your app:- Test thoroughly (see Testing section)
- Run linter:
npm run lint - Build project:
npm run build - Submit a pull request (see Contributing)
