ywana-core8 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +961 -0
- package/dist/index.js +450 -6
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +450 -6
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +450 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/desktop/AppManager.js +270 -0
- package/src/desktop/ApplicationMenu.css +279 -0
- package/src/desktop/ApplicationMenu.js +214 -0
- package/src/desktop/Desktop.stories.jsx +432 -5
- package/src/desktop/WindowContext.js +1 -0
- package/src/desktop/WindowManager.js +23 -0
- package/src/desktop/desktop-linux.css +232 -0
- package/src/desktop/desktop-macos.css +260 -0
- package/src/desktop/desktop-windows.css +190 -0
- package/src/desktop/desktop.js +131 -33
- package/src/desktop/index.js +5 -1
- package/src/desktop/window.js +9 -2
- package/src/examples/ApplicationMenuExample.js +361 -0
@@ -0,0 +1,214 @@
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react'
|
2
|
+
import { useWindows } from './WindowContext'
|
3
|
+
import { useAppManager } from './desktop'
|
4
|
+
import './ApplicationMenu.css'
|
5
|
+
|
6
|
+
/**
|
7
|
+
* ApplicationMenu - Full-screen overlay menu for launching applications
|
8
|
+
*/
|
9
|
+
export const ApplicationMenu = ({ isOpen, onClose }) => {
|
10
|
+
const appManager = useAppManager()
|
11
|
+
const [searchTerm, setSearchTerm] = useState('')
|
12
|
+
const [selectedCategory, setSelectedCategory] = useState('all')
|
13
|
+
const [apps, setApps] = useState([])
|
14
|
+
const [categories, setCategories] = useState([])
|
15
|
+
const searchInputRef = useRef(null)
|
16
|
+
const { createWindow } = useWindows()
|
17
|
+
|
18
|
+
// Load apps and categories
|
19
|
+
useEffect(() => {
|
20
|
+
const loadData = () => {
|
21
|
+
setApps(appManager.getAllApps())
|
22
|
+
setCategories(appManager.getAllCategories())
|
23
|
+
}
|
24
|
+
|
25
|
+
loadData()
|
26
|
+
appManager.addListener(loadData)
|
27
|
+
|
28
|
+
return () => {
|
29
|
+
appManager.removeListener(loadData)
|
30
|
+
}
|
31
|
+
}, [appManager])
|
32
|
+
|
33
|
+
// Focus search input when menu opens
|
34
|
+
useEffect(() => {
|
35
|
+
if (isOpen && searchInputRef.current) {
|
36
|
+
setTimeout(() => {
|
37
|
+
searchInputRef.current.focus()
|
38
|
+
}, 100)
|
39
|
+
}
|
40
|
+
}, [isOpen])
|
41
|
+
|
42
|
+
// Handle escape key to close menu
|
43
|
+
useEffect(() => {
|
44
|
+
const handleKeyDown = (e) => {
|
45
|
+
if (e.key === 'Escape' && isOpen) {
|
46
|
+
onClose()
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
if (isOpen) {
|
51
|
+
document.addEventListener('keydown', handleKeyDown)
|
52
|
+
return () => document.removeEventListener('keydown', handleKeyDown)
|
53
|
+
}
|
54
|
+
}, [isOpen, onClose])
|
55
|
+
|
56
|
+
// Filter apps based on search and category
|
57
|
+
const filteredApps = apps.filter(app => {
|
58
|
+
const matchesSearch = searchTerm === '' ||
|
59
|
+
app.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
60
|
+
app.description.toLowerCase().includes(searchTerm.toLowerCase())
|
61
|
+
|
62
|
+
const matchesCategory = selectedCategory === 'all' ||
|
63
|
+
app.category.toLowerCase() === selectedCategory.toLowerCase()
|
64
|
+
|
65
|
+
return matchesSearch && matchesCategory
|
66
|
+
})
|
67
|
+
|
68
|
+
// Group filtered apps by category
|
69
|
+
const groupedApps = filteredApps.reduce((groups, app) => {
|
70
|
+
const category = app.category
|
71
|
+
if (!groups[category]) {
|
72
|
+
groups[category] = []
|
73
|
+
}
|
74
|
+
groups[category].push(app)
|
75
|
+
return groups
|
76
|
+
}, {})
|
77
|
+
|
78
|
+
// Handle app launch
|
79
|
+
const handleLaunchApp = (app) => {
|
80
|
+
createWindow({
|
81
|
+
id: `${app.id}-${Date.now()}`,
|
82
|
+
title: app.name,
|
83
|
+
icon: app.icon,
|
84
|
+
size: app.size,
|
85
|
+
toolbar: app.toolbar,
|
86
|
+
statusBar: app.statusBar,
|
87
|
+
content: app.component || (
|
88
|
+
<div style={{ padding: '20px', textAlign: 'center' }}>
|
89
|
+
<div style={{ fontSize: '48px', marginBottom: '16px' }}>{app.icon}</div>
|
90
|
+
<h2>{app.name}</h2>
|
91
|
+
<p style={{ color: '#666', marginBottom: '20px' }}>{app.description}</p>
|
92
|
+
<p style={{ fontSize: '14px', color: '#999' }}>
|
93
|
+
This is a placeholder for the {app.name} application.
|
94
|
+
</p>
|
95
|
+
</div>
|
96
|
+
)
|
97
|
+
})
|
98
|
+
onClose()
|
99
|
+
}
|
100
|
+
|
101
|
+
// Handle category selection
|
102
|
+
const handleCategorySelect = (categoryId) => {
|
103
|
+
setSelectedCategory(categoryId)
|
104
|
+
setSearchTerm('')
|
105
|
+
}
|
106
|
+
|
107
|
+
if (!isOpen) return null
|
108
|
+
|
109
|
+
return (
|
110
|
+
<div className="application-menu-overlay" onClick={onClose}>
|
111
|
+
<div className="application-menu" onClick={(e) => e.stopPropagation()}>
|
112
|
+
{/* Header */}
|
113
|
+
<div className="application-menu__header">
|
114
|
+
<h2>Applications</h2>
|
115
|
+
<button
|
116
|
+
className="application-menu__close"
|
117
|
+
onClick={onClose}
|
118
|
+
title="Close menu"
|
119
|
+
>
|
120
|
+
×
|
121
|
+
</button>
|
122
|
+
</div>
|
123
|
+
|
124
|
+
{/* Search */}
|
125
|
+
<div className="application-menu__search">
|
126
|
+
<input
|
127
|
+
ref={searchInputRef}
|
128
|
+
type="text"
|
129
|
+
placeholder="Search applications..."
|
130
|
+
value={searchTerm}
|
131
|
+
onChange={(e) => setSearchTerm(e.target.value)}
|
132
|
+
className="application-menu__search-input"
|
133
|
+
/>
|
134
|
+
</div>
|
135
|
+
|
136
|
+
{/* Categories */}
|
137
|
+
<div className="application-menu__categories">
|
138
|
+
<button
|
139
|
+
className={`application-menu__category ${selectedCategory === 'all' ? 'active' : ''}`}
|
140
|
+
onClick={() => handleCategorySelect('all')}
|
141
|
+
>
|
142
|
+
<span className="category-icon">📱</span>
|
143
|
+
All Apps
|
144
|
+
</button>
|
145
|
+
{categories.map(category => (
|
146
|
+
<button
|
147
|
+
key={category.id}
|
148
|
+
className={`application-menu__category ${selectedCategory === category.id ? 'active' : ''}`}
|
149
|
+
onClick={() => handleCategorySelect(category.id)}
|
150
|
+
>
|
151
|
+
<span className="category-icon">{category.icon}</span>
|
152
|
+
{category.name}
|
153
|
+
</button>
|
154
|
+
))}
|
155
|
+
</div>
|
156
|
+
|
157
|
+
{/* Applications Grid */}
|
158
|
+
<div className="application-menu__content">
|
159
|
+
{searchTerm && (
|
160
|
+
<div className="application-menu__search-results">
|
161
|
+
<h3>Search Results ({filteredApps.length})</h3>
|
162
|
+
<div className="application-menu__apps-grid">
|
163
|
+
{filteredApps.map(app => (
|
164
|
+
<div
|
165
|
+
key={app.id}
|
166
|
+
className="application-menu__app"
|
167
|
+
onClick={() => handleLaunchApp(app)}
|
168
|
+
title={app.description}
|
169
|
+
>
|
170
|
+
<div className="app-icon">{app.icon}</div>
|
171
|
+
<div className="app-name">{app.name}</div>
|
172
|
+
</div>
|
173
|
+
))}
|
174
|
+
</div>
|
175
|
+
</div>
|
176
|
+
)}
|
177
|
+
|
178
|
+
{!searchTerm && (
|
179
|
+
<div className="application-menu__categories-content">
|
180
|
+
{Object.entries(groupedApps).map(([categoryName, categoryApps]) => (
|
181
|
+
<div key={categoryName} className="application-menu__category-section">
|
182
|
+
<h3 className="category-title">{categoryName}</h3>
|
183
|
+
<div className="application-menu__apps-grid">
|
184
|
+
{categoryApps.map(app => (
|
185
|
+
<div
|
186
|
+
key={app.id}
|
187
|
+
className="application-menu__app"
|
188
|
+
onClick={() => handleLaunchApp(app)}
|
189
|
+
title={app.description}
|
190
|
+
>
|
191
|
+
<div className="app-icon">{app.icon}</div>
|
192
|
+
<div className="app-name">{app.name}</div>
|
193
|
+
</div>
|
194
|
+
))}
|
195
|
+
</div>
|
196
|
+
</div>
|
197
|
+
))}
|
198
|
+
</div>
|
199
|
+
)}
|
200
|
+
|
201
|
+
{filteredApps.length === 0 && (
|
202
|
+
<div className="application-menu__no-results">
|
203
|
+
<div style={{ fontSize: '48px', marginBottom: '16px' }}>🔍</div>
|
204
|
+
<h3>No applications found</h3>
|
205
|
+
<p>Try adjusting your search or category filter.</p>
|
206
|
+
</div>
|
207
|
+
)}
|
208
|
+
</div>
|
209
|
+
</div>
|
210
|
+
</div>
|
211
|
+
)
|
212
|
+
}
|
213
|
+
|
214
|
+
export default ApplicationMenu
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import React from 'react'
|
2
|
-
import { Desktop } from './desktop.js'
|
2
|
+
import { Desktop, useApplicationMenu, useAppManager } from './desktop.js'
|
3
|
+
import { defaultAppManager } from './AppManager.js'
|
3
4
|
|
4
5
|
/**
|
5
6
|
* Basic Desktop with WindowManager
|
@@ -88,10 +89,10 @@ export const DarkDesktop = () => (
|
|
88
89
|
export const LightDesktop = () => (
|
89
90
|
<div style={{ height: '600px', width: '100%', position: 'relative', overflow: 'hidden' }}>
|
90
91
|
<Desktop className="desktop--light">
|
91
|
-
<div style={{
|
92
|
-
position: 'absolute',
|
93
|
-
top: '50%',
|
94
|
-
left: '50%',
|
92
|
+
<div style={{
|
93
|
+
position: 'absolute',
|
94
|
+
top: '50%',
|
95
|
+
left: '50%',
|
95
96
|
transform: 'translate(-50%, -50%)',
|
96
97
|
background: 'rgba(255,255,255,0.9)',
|
97
98
|
color: '#333',
|
@@ -108,3 +109,429 @@ export const LightDesktop = () => (
|
|
108
109
|
</Desktop>
|
109
110
|
</div>
|
110
111
|
)
|
112
|
+
|
113
|
+
// Component that demonstrates using both AppProvider hooks
|
114
|
+
const DemoControls = () => {
|
115
|
+
const { isOpen, open, close, toggle } = useApplicationMenu()
|
116
|
+
const appManager = useAppManager()
|
117
|
+
const [appCount, setAppCount] = React.useState(0)
|
118
|
+
|
119
|
+
React.useEffect(() => {
|
120
|
+
const updateCount = () => setAppCount(appManager.getAllApps().length)
|
121
|
+
updateCount()
|
122
|
+
appManager.addListener(updateCount)
|
123
|
+
return () => appManager.removeListener(updateCount)
|
124
|
+
}, [appManager])
|
125
|
+
|
126
|
+
const addCustomApp = () => {
|
127
|
+
const randomId = `custom-app-${Date.now()}`
|
128
|
+
appManager.registerApp({
|
129
|
+
id: randomId,
|
130
|
+
name: `Custom App ${Math.floor(Math.random() * 100)}`,
|
131
|
+
description: 'Dynamically added application',
|
132
|
+
icon: ['🎨', '🎯', '🎪', '🎭', '🎨'][Math.floor(Math.random() * 5)],
|
133
|
+
category: 'Custom',
|
134
|
+
component: React.createElement('div', {
|
135
|
+
style: { padding: '20px', textAlign: 'center' }
|
136
|
+
}, [
|
137
|
+
React.createElement('h2', { key: 'title' }, 'Dynamic App'),
|
138
|
+
React.createElement('p', { key: 'desc' }, 'This app was added dynamically using AppManager!'),
|
139
|
+
React.createElement('p', { key: 'id' }, `ID: ${randomId}`)
|
140
|
+
]),
|
141
|
+
size: { width: 400, height: 300 }
|
142
|
+
})
|
143
|
+
}
|
144
|
+
|
145
|
+
return (
|
146
|
+
<div style={{
|
147
|
+
position: 'absolute',
|
148
|
+
top: '20px',
|
149
|
+
right: '20px',
|
150
|
+
background: 'rgba(255,255,255,0.9)',
|
151
|
+
padding: '20px',
|
152
|
+
borderRadius: '8px',
|
153
|
+
boxShadow: '0 2px 10px rgba(0,0,0,0.1)',
|
154
|
+
maxWidth: '300px'
|
155
|
+
}}>
|
156
|
+
<h4 style={{ margin: '0 0 15px 0' }}>🎮 App Controls</h4>
|
157
|
+
<p style={{ margin: '0 0 10px 0', fontSize: '14px', color: '#666' }}>
|
158
|
+
Menu: <strong>{isOpen ? 'Open' : 'Closed'}</strong><br/>
|
159
|
+
Apps: <strong>{appCount}</strong>
|
160
|
+
</p>
|
161
|
+
|
162
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
|
163
|
+
<button
|
164
|
+
onClick={open}
|
165
|
+
style={{
|
166
|
+
padding: '8px 12px',
|
167
|
+
background: '#4caf50',
|
168
|
+
color: 'white',
|
169
|
+
border: 'none',
|
170
|
+
borderRadius: '4px',
|
171
|
+
cursor: 'pointer',
|
172
|
+
fontSize: '12px'
|
173
|
+
}}
|
174
|
+
>
|
175
|
+
Open Menu
|
176
|
+
</button>
|
177
|
+
<button
|
178
|
+
onClick={close}
|
179
|
+
style={{
|
180
|
+
padding: '8px 12px',
|
181
|
+
background: '#f44336',
|
182
|
+
color: 'white',
|
183
|
+
border: 'none',
|
184
|
+
borderRadius: '4px',
|
185
|
+
cursor: 'pointer',
|
186
|
+
fontSize: '12px'
|
187
|
+
}}
|
188
|
+
>
|
189
|
+
Close Menu
|
190
|
+
</button>
|
191
|
+
<button
|
192
|
+
onClick={toggle}
|
193
|
+
style={{
|
194
|
+
padding: '8px 12px',
|
195
|
+
background: '#2196f3',
|
196
|
+
color: 'white',
|
197
|
+
border: 'none',
|
198
|
+
borderRadius: '4px',
|
199
|
+
cursor: 'pointer',
|
200
|
+
fontSize: '12px'
|
201
|
+
}}
|
202
|
+
>
|
203
|
+
Toggle Menu
|
204
|
+
</button>
|
205
|
+
<hr style={{ margin: '10px 0', border: 'none', borderTop: '1px solid #eee' }} />
|
206
|
+
<button
|
207
|
+
onClick={addCustomApp}
|
208
|
+
style={{
|
209
|
+
padding: '8px 12px',
|
210
|
+
background: '#ff9800',
|
211
|
+
color: 'white',
|
212
|
+
border: 'none',
|
213
|
+
borderRadius: '4px',
|
214
|
+
cursor: 'pointer',
|
215
|
+
fontSize: '12px'
|
216
|
+
}}
|
217
|
+
>
|
218
|
+
Add Custom App
|
219
|
+
</button>
|
220
|
+
</div>
|
221
|
+
</div>
|
222
|
+
)
|
223
|
+
}
|
224
|
+
|
225
|
+
/**
|
226
|
+
* Desktop with ApplicationMenu - Basic functionality
|
227
|
+
*/
|
228
|
+
export const ApplicationMenuBasic = () => (
|
229
|
+
<div style={{ height: '600px', width: '100%', position: 'relative', overflow: 'hidden' }}>
|
230
|
+
<Desktop desktopSize={{ width: 1200, height: 600 }}>
|
231
|
+
<div style={{
|
232
|
+
position: 'absolute',
|
233
|
+
top: '20px',
|
234
|
+
left: '20px',
|
235
|
+
background: 'rgba(255,255,255,0.9)',
|
236
|
+
padding: '20px',
|
237
|
+
borderRadius: '8px',
|
238
|
+
boxShadow: '0 2px 10px rgba(0,0,0,0.1)',
|
239
|
+
maxWidth: '400px'
|
240
|
+
}}>
|
241
|
+
<h3 style={{ margin: '0 0 15px 0' }}>🚀 Application Menu Demo</h3>
|
242
|
+
<p style={{ margin: '0 0 15px 0', lineHeight: '1.5' }}>
|
243
|
+
Click the <strong>"Start"</strong> button in the taskbar to open the Application Menu.
|
244
|
+
Browse applications by category and launch them to create windows.
|
245
|
+
</p>
|
246
|
+
<div style={{ fontSize: '14px', color: '#666' }}>
|
247
|
+
<p><strong>Features:</strong></p>
|
248
|
+
<ul style={{ margin: '5px 0', paddingLeft: '20px' }}>
|
249
|
+
<li>Browse apps by category</li>
|
250
|
+
<li>Search functionality</li>
|
251
|
+
<li>Launch applications as windows</li>
|
252
|
+
<li>Full-screen overlay menu</li>
|
253
|
+
</ul>
|
254
|
+
</div>
|
255
|
+
</div>
|
256
|
+
</Desktop>
|
257
|
+
</div>
|
258
|
+
)
|
259
|
+
|
260
|
+
/**
|
261
|
+
* Windows Theme Desktop
|
262
|
+
*/
|
263
|
+
export const WindowsTheme = () => (
|
264
|
+
<div style={{ height: '600px', width: '100%', position: 'relative', overflow: 'hidden' }}>
|
265
|
+
<Desktop theme="windows" desktopSize={{ width: 1200, height: 600 }}>
|
266
|
+
<div style={{
|
267
|
+
position: 'absolute',
|
268
|
+
top: '20px',
|
269
|
+
left: '20px',
|
270
|
+
background: 'rgba(255,255,255,0.9)',
|
271
|
+
padding: '20px',
|
272
|
+
borderRadius: '8px',
|
273
|
+
boxShadow: '0 2px 10px rgba(0,0,0,0.1)',
|
274
|
+
maxWidth: '400px'
|
275
|
+
}}>
|
276
|
+
<h3 style={{ margin: '0 0 15px 0' }}>🪟 Windows Theme</h3>
|
277
|
+
<p style={{ margin: '0 0 15px 0', lineHeight: '1.5' }}>
|
278
|
+
Windows-inspired desktop theme with Segoe UI font, blue gradient background,
|
279
|
+
and Windows-style window controls and taskbar.
|
280
|
+
</p>
|
281
|
+
<div style={{ fontSize: '14px', color: '#666' }}>
|
282
|
+
<p><strong>Features:</strong></p>
|
283
|
+
<ul style={{ margin: '5px 0', paddingLeft: '20px' }}>
|
284
|
+
<li>Windows 11 inspired design</li>
|
285
|
+
<li>Segoe UI font family</li>
|
286
|
+
<li>Blue gradient background</li>
|
287
|
+
<li>Windows-style window controls</li>
|
288
|
+
</ul>
|
289
|
+
</div>
|
290
|
+
</div>
|
291
|
+
</Desktop>
|
292
|
+
</div>
|
293
|
+
)
|
294
|
+
|
295
|
+
/**
|
296
|
+
* macOS Theme Desktop
|
297
|
+
*/
|
298
|
+
export const MacOSTheme = () => (
|
299
|
+
<div style={{ height: '600px', width: '100%', position: 'relative', overflow: 'hidden' }}>
|
300
|
+
<Desktop theme="macos" desktopSize={{ width: 1200, height: 600 }}>
|
301
|
+
<div style={{
|
302
|
+
position: 'absolute',
|
303
|
+
top: '20px',
|
304
|
+
left: '20px',
|
305
|
+
background: 'rgba(255,255,255,0.9)',
|
306
|
+
padding: '20px',
|
307
|
+
borderRadius: '16px',
|
308
|
+
boxShadow: '0 8px 25px rgba(0,0,0,0.15)',
|
309
|
+
maxWidth: '400px',
|
310
|
+
backdropFilter: 'blur(20px)'
|
311
|
+
}}>
|
312
|
+
<h3 style={{ margin: '0 0 15px 0' }}>🍎 macOS Theme</h3>
|
313
|
+
<p style={{ margin: '0 0 15px 0', lineHeight: '1.5' }}>
|
314
|
+
macOS-inspired desktop theme with SF Pro Display font, purple gradient background,
|
315
|
+
and signature traffic light window controls.
|
316
|
+
</p>
|
317
|
+
<div style={{ fontSize: '14px', color: '#666' }}>
|
318
|
+
<p><strong>Features:</strong></p>
|
319
|
+
<ul style={{ margin: '5px 0', paddingLeft: '20px' }}>
|
320
|
+
<li>macOS Big Sur/Monterey design</li>
|
321
|
+
<li>SF Pro Display font family</li>
|
322
|
+
<li>Purple gradient background</li>
|
323
|
+
<li>Traffic light window controls</li>
|
324
|
+
</ul>
|
325
|
+
</div>
|
326
|
+
</div>
|
327
|
+
</Desktop>
|
328
|
+
</div>
|
329
|
+
)
|
330
|
+
|
331
|
+
/**
|
332
|
+
* Linux Theme Desktop
|
333
|
+
*/
|
334
|
+
export const LinuxTheme = () => (
|
335
|
+
<div style={{ height: '600px', width: '100%', position: 'relative', overflow: 'hidden' }}>
|
336
|
+
<Desktop theme="linux" desktopSize={{ width: 1200, height: 600 }}>
|
337
|
+
<div style={{
|
338
|
+
position: 'absolute',
|
339
|
+
top: '20px',
|
340
|
+
left: '20px',
|
341
|
+
background: 'rgba(255,255,255,0.9)',
|
342
|
+
padding: '20px',
|
343
|
+
borderRadius: '12px',
|
344
|
+
boxShadow: '0 4px 16px rgba(0,0,0,0.3)',
|
345
|
+
maxWidth: '400px'
|
346
|
+
}}>
|
347
|
+
<h3 style={{ margin: '0 0 15px 0' }}>🐧 Linux Theme</h3>
|
348
|
+
<p style={{ margin: '0 0 15px 0', lineHeight: '1.5' }}>
|
349
|
+
Linux GNOME-inspired desktop theme with Ubuntu font, dark gradient background,
|
350
|
+
and colorful circular window controls.
|
351
|
+
</p>
|
352
|
+
<div style={{ fontSize: '14px', color: '#666' }}>
|
353
|
+
<p><strong>Features:</strong></p>
|
354
|
+
<ul style={{ margin: '5px 0', paddingLeft: '20px' }}>
|
355
|
+
<li>GNOME/Ubuntu inspired design</li>
|
356
|
+
<li>Ubuntu/Cantarell font family</li>
|
357
|
+
<li>Dark gradient background</li>
|
358
|
+
<li>Colorful circular controls</li>
|
359
|
+
</ul>
|
360
|
+
</div>
|
361
|
+
</div>
|
362
|
+
</Desktop>
|
363
|
+
</div>
|
364
|
+
)
|
365
|
+
|
366
|
+
/**
|
367
|
+
* Theme Comparison - All three themes side by side
|
368
|
+
*/
|
369
|
+
export const ThemeComparison = () => (
|
370
|
+
<div style={{
|
371
|
+
display: 'grid',
|
372
|
+
gridTemplateColumns: 'repeat(3, 1fr)',
|
373
|
+
gap: '20px',
|
374
|
+
padding: '20px',
|
375
|
+
height: '600px'
|
376
|
+
}}>
|
377
|
+
<div style={{ position: 'relative', overflow: 'hidden', border: '2px solid #ccc', borderRadius: '8px' }}>
|
378
|
+
<div style={{
|
379
|
+
position: 'absolute',
|
380
|
+
top: '5px',
|
381
|
+
left: '5px',
|
382
|
+
background: 'rgba(0,0,0,0.7)',
|
383
|
+
color: 'white',
|
384
|
+
padding: '4px 8px',
|
385
|
+
borderRadius: '4px',
|
386
|
+
fontSize: '12px',
|
387
|
+
zIndex: 1000
|
388
|
+
}}>
|
389
|
+
Windows
|
390
|
+
</div>
|
391
|
+
<Desktop theme="windows" desktopSize={{ width: 400, height: 560 }} />
|
392
|
+
</div>
|
393
|
+
|
394
|
+
<div style={{ position: 'relative', overflow: 'hidden', border: '2px solid #ccc', borderRadius: '8px' }}>
|
395
|
+
<div style={{
|
396
|
+
position: 'absolute',
|
397
|
+
top: '5px',
|
398
|
+
left: '5px',
|
399
|
+
background: 'rgba(0,0,0,0.7)',
|
400
|
+
color: 'white',
|
401
|
+
padding: '4px 8px',
|
402
|
+
borderRadius: '4px',
|
403
|
+
fontSize: '12px',
|
404
|
+
zIndex: 1000
|
405
|
+
}}>
|
406
|
+
macOS
|
407
|
+
</div>
|
408
|
+
<Desktop theme="macos" desktopSize={{ width: 400, height: 560 }} />
|
409
|
+
</div>
|
410
|
+
|
411
|
+
<div style={{ position: 'relative', overflow: 'hidden', border: '2px solid #ccc', borderRadius: '8px' }}>
|
412
|
+
<div style={{
|
413
|
+
position: 'absolute',
|
414
|
+
top: '5px',
|
415
|
+
left: '5px',
|
416
|
+
background: 'rgba(0,0,0,0.7)',
|
417
|
+
color: 'white',
|
418
|
+
padding: '4px 8px',
|
419
|
+
borderRadius: '4px',
|
420
|
+
fontSize: '12px',
|
421
|
+
zIndex: 1000
|
422
|
+
}}>
|
423
|
+
Linux
|
424
|
+
</div>
|
425
|
+
<Desktop theme="linux" desktopSize={{ width: 400, height: 560 }} />
|
426
|
+
</div>
|
427
|
+
</div>
|
428
|
+
)
|
429
|
+
|
430
|
+
/**
|
431
|
+
* Desktop with ApplicationMenu - Advanced with controls
|
432
|
+
*/
|
433
|
+
export const ApplicationMenuAdvanced = () => {
|
434
|
+
// Setup custom apps
|
435
|
+
React.useEffect(() => {
|
436
|
+
// Register some custom applications
|
437
|
+
defaultAppManager.registerApp({
|
438
|
+
id: 'advanced-calculator',
|
439
|
+
name: 'Advanced Calculator',
|
440
|
+
description: 'Scientific calculator with advanced functions',
|
441
|
+
icon: '🧮',
|
442
|
+
category: 'Utilities',
|
443
|
+
component: React.createElement('div', {
|
444
|
+
style: { padding: '20px', textAlign: 'center' }
|
445
|
+
}, [
|
446
|
+
React.createElement('h2', { key: 'title' }, '🧮 Advanced Calculator'),
|
447
|
+
React.createElement('p', { key: 'desc' }, 'A powerful calculator with scientific functions.'),
|
448
|
+
React.createElement('div', {
|
449
|
+
key: 'buttons',
|
450
|
+
style: { display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: '8px', marginTop: '20px' }
|
451
|
+
}, [
|
452
|
+
...['7', '8', '9', '/', '4', '5', '6', '*', '1', '2', '3', '-', '0', '.', '=', '+'].map((btn, i) =>
|
453
|
+
React.createElement('button', {
|
454
|
+
key: i,
|
455
|
+
style: {
|
456
|
+
padding: '12px',
|
457
|
+
background: '#f0f0f0',
|
458
|
+
border: '1px solid #ccc',
|
459
|
+
borderRadius: '4px',
|
460
|
+
cursor: 'pointer'
|
461
|
+
}
|
462
|
+
}, btn)
|
463
|
+
)
|
464
|
+
])
|
465
|
+
]),
|
466
|
+
size: { width: 300, height: 400 }
|
467
|
+
})
|
468
|
+
|
469
|
+
defaultAppManager.registerApp({
|
470
|
+
id: 'text-editor-pro',
|
471
|
+
name: 'Text Editor Pro',
|
472
|
+
description: 'Professional text editor with syntax highlighting',
|
473
|
+
icon: '📝',
|
474
|
+
category: 'Productivity',
|
475
|
+
component: React.createElement('div', {
|
476
|
+
style: { padding: '20px', height: '100%', display: 'flex', flexDirection: 'column' }
|
477
|
+
}, [
|
478
|
+
React.createElement('div', {
|
479
|
+
key: 'toolbar',
|
480
|
+
style: { marginBottom: '10px', display: 'flex', gap: '10px' }
|
481
|
+
}, [
|
482
|
+
React.createElement('button', { key: 'new', style: { padding: '5px 10px', fontSize: '12px' } }, 'New'),
|
483
|
+
React.createElement('button', { key: 'open', style: { padding: '5px 10px', fontSize: '12px' } }, 'Open'),
|
484
|
+
React.createElement('button', { key: 'save', style: { padding: '5px 10px', fontSize: '12px' } }, 'Save')
|
485
|
+
]),
|
486
|
+
React.createElement('textarea', {
|
487
|
+
key: 'editor',
|
488
|
+
style: {
|
489
|
+
flex: 1,
|
490
|
+
border: '1px solid #ccc',
|
491
|
+
padding: '10px',
|
492
|
+
fontFamily: 'monospace',
|
493
|
+
fontSize: '14px',
|
494
|
+
resize: 'none'
|
495
|
+
},
|
496
|
+
placeholder: 'Start typing your code here...',
|
497
|
+
defaultValue: '// Welcome to Text Editor Pro!\nfunction hello() {\n console.log("Hello, World!");\n}'
|
498
|
+
})
|
499
|
+
]),
|
500
|
+
size: { width: 600, height: 400 }
|
501
|
+
})
|
502
|
+
}, [])
|
503
|
+
|
504
|
+
return (
|
505
|
+
<div style={{ height: '600px', width: '100%', position: 'relative', overflow: 'hidden' }}>
|
506
|
+
<Desktop desktopSize={{ width: 1200, height: 600 }}>
|
507
|
+
<div style={{
|
508
|
+
position: 'absolute',
|
509
|
+
top: '20px',
|
510
|
+
left: '20px',
|
511
|
+
background: 'rgba(255,255,255,0.9)',
|
512
|
+
padding: '20px',
|
513
|
+
borderRadius: '8px',
|
514
|
+
boxShadow: '0 2px 10px rgba(0,0,0,0.1)',
|
515
|
+
maxWidth: '400px'
|
516
|
+
}}>
|
517
|
+
<h3 style={{ margin: '0 0 15px 0' }}>🎮 AppProvider + AppManager</h3>
|
518
|
+
<p style={{ margin: '0 0 15px 0', lineHeight: '1.5' }}>
|
519
|
+
This demo shows AppProvider and AppManager collaboration. Use the controls
|
520
|
+
on the right to manage the menu and add custom applications dynamically.
|
521
|
+
</p>
|
522
|
+
<div style={{ fontSize: '14px', color: '#666' }}>
|
523
|
+
<p><strong>Advanced Features:</strong></p>
|
524
|
+
<ul style={{ margin: '5px 0', paddingLeft: '20px' }}>
|
525
|
+
<li>Dynamic app registration</li>
|
526
|
+
<li>Real-time app count updates</li>
|
527
|
+
<li>Custom app components</li>
|
528
|
+
<li>Context-based state management</li>
|
529
|
+
</ul>
|
530
|
+
</div>
|
531
|
+
</div>
|
532
|
+
|
533
|
+
<DemoControls />
|
534
|
+
</Desktop>
|
535
|
+
</div>
|
536
|
+
)
|
537
|
+
}
|
@@ -63,6 +63,7 @@ export const WindowProvider = ({ children, desktopSize }) => {
|
|
63
63
|
minimizeWindow: (id, minimize) => windowManagerRef.current.minimizeWindow(id, minimize),
|
64
64
|
maximizeWindow: (id, maximize) => windowManagerRef.current.maximizeWindow(id, maximize),
|
65
65
|
updateWindowPosition: (id, position) => windowManagerRef.current.updateWindowPosition(id, position),
|
66
|
+
updateWindowSize: (id, size) => windowManagerRef.current.updateWindowSize(id, size),
|
66
67
|
|
67
68
|
// Window queries
|
68
69
|
getWindow: (id) => windowManagerRef.current.getWindow(id),
|