ywana-core8 0.2.8 → 0.2.10
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 +295 -58
- package/dist/index.js +215 -114
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +215 -114
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +215 -114
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/desktop/AppManager.js +179 -115
- package/src/desktop/ApplicationMenu.css +295 -55
- package/src/desktop/ApplicationMenu.js +55 -15
- package/src/desktop/Desktop.stories.jsx +148 -584
- package/src/desktop/desktop-windows.css +0 -3
- package/src/desktop/desktop.js +43 -23
- package/src/desktop.backup/desktop.css +0 -6
- package/src/desktop.backup/desktop.js +0 -13
- package/src/desktop.backup/window.css +0 -58
- package/src/desktop.backup/window.js +0 -27
- package/src/examples/ApplicationMenuExample.js +0 -361
@@ -185,15 +185,12 @@
|
|
185
185
|
|
186
186
|
.desktop--windows .application-menu__category {
|
187
187
|
background: #ffffff;
|
188
|
-
border: 1px solid #e0e0e0;
|
189
|
-
border-radius: 16px;
|
190
188
|
font-family: 'Segoe UI', sans-serif;
|
191
189
|
font-size: 13px;
|
192
190
|
}
|
193
191
|
|
194
192
|
.desktop--windows .application-menu__category:hover {
|
195
193
|
background: #f5f5f5;
|
196
|
-
border-color: #d0d0d0;
|
197
194
|
}
|
198
195
|
|
199
196
|
.desktop--windows .application-menu__category.active {
|
package/src/desktop/desktop.js
CHANGED
@@ -2,7 +2,7 @@ import React, { useRef, useEffect, useState, createContext, useContext } from 'r
|
|
2
2
|
import { WindowProvider, useWindows } from './WindowContext'
|
3
3
|
import { Window } from './window'
|
4
4
|
import { ApplicationMenu } from './ApplicationMenu'
|
5
|
-
import {
|
5
|
+
import { AppManager, AppLoader, defaultDesktopConfig } from './AppManager'
|
6
6
|
import { ToggleButton } from '../html/selector'
|
7
7
|
import { Icon } from '../html/icon'
|
8
8
|
import './desktop.css'
|
@@ -34,9 +34,22 @@ export const useAppManager = () => {
|
|
34
34
|
/**
|
35
35
|
* AppProvider - Provides Application state and AppManager to React components
|
36
36
|
*/
|
37
|
-
export const AppProvider = ({
|
37
|
+
export const AppProvider = ({
|
38
|
+
children,
|
39
|
+
desktopConfig = defaultDesktopConfig
|
40
|
+
}) => {
|
41
|
+
// Create a new AppManager instance if none provided
|
42
|
+
const appManager = new AppManager()
|
38
43
|
const [isApplicationMenuOpen, setIsApplicationMenuOpen] = useState(false)
|
39
44
|
|
45
|
+
// Load configuration on mount
|
46
|
+
useEffect(() => {
|
47
|
+
// Only load if the appManager is empty (no apps registered)
|
48
|
+
if (appManager.getAllApps().length === 0 && desktopConfig) {
|
49
|
+
AppLoader.load(appManager, desktopConfig)
|
50
|
+
}
|
51
|
+
}, [appManager, desktopConfig])
|
52
|
+
|
40
53
|
const value = {
|
41
54
|
// Application Menu state
|
42
55
|
applicationMenu: {
|
@@ -46,7 +59,7 @@ export const AppProvider = ({ children, appManager = defaultAppManager }) => {
|
|
46
59
|
toggle: () => setIsApplicationMenuOpen(!isApplicationMenuOpen)
|
47
60
|
},
|
48
61
|
// App Manager instance
|
49
|
-
appManager
|
62
|
+
appManager
|
50
63
|
}
|
51
64
|
|
52
65
|
return (
|
@@ -243,24 +256,24 @@ export const DesktopTaskbar = () => {
|
|
243
256
|
|
244
257
|
return (
|
245
258
|
<div className='desktop-taskbar' style={{
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
259
|
+
height: '50px',
|
260
|
+
background: 'rgba(0,0,0,0.8)',
|
261
|
+
display: 'flex',
|
262
|
+
alignItems: 'center',
|
263
|
+
padding: '0 16px',
|
264
|
+
gap: '8px'
|
265
|
+
}}>
|
266
|
+
{/* Start button */}
|
267
|
+
<ToggleButton
|
268
|
+
checked={isOpen}
|
269
|
+
onToggle={() => {
|
270
|
+
console.log('Start button toggled, current state:', isOpen)
|
271
|
+
toggle()
|
272
|
+
}}
|
273
|
+
icon="start"
|
274
|
+
label="Start"
|
275
|
+
>
|
276
|
+
</ToggleButton>
|
264
277
|
|
265
278
|
{/* Separator */}
|
266
279
|
<div style={{
|
@@ -429,9 +442,16 @@ const DesktopInternal = ({ desktopSize, children, ...props }) => {
|
|
429
442
|
/**
|
430
443
|
* Main Desktop component with AppProvider wrapper
|
431
444
|
*/
|
432
|
-
export const Desktop = ({
|
445
|
+
export const Desktop = ({
|
446
|
+
desktopSize,
|
447
|
+
children,
|
448
|
+
desktopConfig,
|
449
|
+
...props
|
450
|
+
}) => {
|
433
451
|
return (
|
434
|
-
<AppProvider
|
452
|
+
<AppProvider
|
453
|
+
desktopConfig={desktopConfig}
|
454
|
+
>
|
435
455
|
<DesktopInternal desktopSize={desktopSize} {...props}>
|
436
456
|
{children}
|
437
457
|
</DesktopInternal>
|
@@ -1,58 +0,0 @@
|
|
1
|
-
.window {
|
2
|
-
position: absolute;
|
3
|
-
top: 1rem;
|
4
|
-
left: 1rem;
|
5
|
-
min-width: 20rem;
|
6
|
-
min-height: 15rem;
|
7
|
-
resize: both;
|
8
|
-
background-color: rgb(227, 227, 227);
|
9
|
-
display: grid;
|
10
|
-
overflow: hidden;
|
11
|
-
resize: both;
|
12
|
-
}
|
13
|
-
|
14
|
-
.window.normal {
|
15
|
-
grid-template-areas:
|
16
|
-
"header header header"
|
17
|
-
"nav nav nav"
|
18
|
-
"menu main aside"
|
19
|
-
"footer footer footer";
|
20
|
-
grid-template-columns: auto 1fr auto;
|
21
|
-
grid-template-rows: 2rem auto 1fr auto;
|
22
|
-
}
|
23
|
-
|
24
|
-
.window>header {
|
25
|
-
grid-area: header;
|
26
|
-
padding: .3rem .3rem 0 0;
|
27
|
-
display: flex;
|
28
|
-
align-items: center;
|
29
|
-
overflow: hidden;
|
30
|
-
}
|
31
|
-
|
32
|
-
.window>header>label {
|
33
|
-
flex: 1;
|
34
|
-
}
|
35
|
-
|
36
|
-
.window>nav {
|
37
|
-
grid-area: nav;
|
38
|
-
}
|
39
|
-
|
40
|
-
.window>menu {
|
41
|
-
grid-area: menu;
|
42
|
-
padding: 0;
|
43
|
-
}
|
44
|
-
|
45
|
-
.window>main {
|
46
|
-
grid-area: main;
|
47
|
-
padding: .5rem;
|
48
|
-
overflow: hidden;
|
49
|
-
border: solid 1px var(--divider-color);
|
50
|
-
}
|
51
|
-
|
52
|
-
.window>aside {
|
53
|
-
grid-area: aside;
|
54
|
-
}
|
55
|
-
|
56
|
-
.window>footer {
|
57
|
-
grid-area: footer;
|
58
|
-
}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import { Button, Icon } from '../html'
|
3
|
-
import './window.css'
|
4
|
-
|
5
|
-
export const Window = (props) => {
|
6
|
-
|
7
|
-
const { id, icon, title, children } = props
|
8
|
-
|
9
|
-
return (
|
10
|
-
<div className="window normal" draggable>
|
11
|
-
<header>
|
12
|
-
<Icon icon={icon} size="small" />
|
13
|
-
<label>{title}</label>
|
14
|
-
<Icon icon="close" clickable size="small" />
|
15
|
-
</header>
|
16
|
-
<nav>
|
17
|
-
|
18
|
-
</nav>
|
19
|
-
<menu></menu>
|
20
|
-
<main>
|
21
|
-
{children}x
|
22
|
-
</main>
|
23
|
-
<aside></aside>
|
24
|
-
<footer>x</footer>
|
25
|
-
</div>
|
26
|
-
)
|
27
|
-
}
|
@@ -1,361 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import { Desktop, AppProvider, AppManager, defaultAppManager, useApplicationMenu, useAppManager } from '../desktop'
|
3
|
-
|
4
|
-
// Example custom components for applications
|
5
|
-
const TextEditorComponent = () => (
|
6
|
-
<div style={{ padding: '20px', height: '100%', display: 'flex', flexDirection: 'column' }}>
|
7
|
-
<div style={{ marginBottom: '10px', display: 'flex', gap: '10px' }}>
|
8
|
-
<button style={{ padding: '5px 10px', fontSize: '12px' }}>New</button>
|
9
|
-
<button style={{ padding: '5px 10px', fontSize: '12px' }}>Open</button>
|
10
|
-
<button style={{ padding: '5px 10px', fontSize: '12px' }}>Save</button>
|
11
|
-
</div>
|
12
|
-
<textarea
|
13
|
-
style={{
|
14
|
-
flex: 1,
|
15
|
-
border: '1px solid #ccc',
|
16
|
-
padding: '10px',
|
17
|
-
fontFamily: 'monospace',
|
18
|
-
fontSize: '14px',
|
19
|
-
resize: 'none'
|
20
|
-
}}
|
21
|
-
placeholder="Start typing your text here..."
|
22
|
-
defaultValue="Welcome to the Text Editor!\n\nThis is a simple text editor application launched from the Application Menu."
|
23
|
-
/>
|
24
|
-
</div>
|
25
|
-
)
|
26
|
-
|
27
|
-
const CalculatorComponent = () => {
|
28
|
-
const [display, setDisplay] = React.useState('0')
|
29
|
-
const [previousValue, setPreviousValue] = React.useState(null)
|
30
|
-
const [operation, setOperation] = React.useState(null)
|
31
|
-
const [waitingForOperand, setWaitingForOperand] = React.useState(false)
|
32
|
-
|
33
|
-
const inputNumber = (num) => {
|
34
|
-
if (waitingForOperand) {
|
35
|
-
setDisplay(String(num))
|
36
|
-
setWaitingForOperand(false)
|
37
|
-
} else {
|
38
|
-
setDisplay(display === '0' ? String(num) : display + num)
|
39
|
-
}
|
40
|
-
}
|
41
|
-
|
42
|
-
const inputOperation = (nextOperation) => {
|
43
|
-
const inputValue = parseFloat(display)
|
44
|
-
|
45
|
-
if (previousValue === null) {
|
46
|
-
setPreviousValue(inputValue)
|
47
|
-
} else if (operation) {
|
48
|
-
const currentValue = previousValue || 0
|
49
|
-
const newValue = calculate(currentValue, inputValue, operation)
|
50
|
-
|
51
|
-
setDisplay(String(newValue))
|
52
|
-
setPreviousValue(newValue)
|
53
|
-
}
|
54
|
-
|
55
|
-
setWaitingForOperand(true)
|
56
|
-
setOperation(nextOperation)
|
57
|
-
}
|
58
|
-
|
59
|
-
const calculate = (firstValue, secondValue, operation) => {
|
60
|
-
switch (operation) {
|
61
|
-
case '+': return firstValue + secondValue
|
62
|
-
case '-': return firstValue - secondValue
|
63
|
-
case '×': return firstValue * secondValue
|
64
|
-
case '÷': return firstValue / secondValue
|
65
|
-
case '=': return secondValue
|
66
|
-
default: return secondValue
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
const performCalculation = () => {
|
71
|
-
const inputValue = parseFloat(display)
|
72
|
-
|
73
|
-
if (previousValue !== null && operation) {
|
74
|
-
const newValue = calculate(previousValue, inputValue, operation)
|
75
|
-
setDisplay(String(newValue))
|
76
|
-
setPreviousValue(null)
|
77
|
-
setOperation(null)
|
78
|
-
setWaitingForOperand(true)
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
const clear = () => {
|
83
|
-
setDisplay('0')
|
84
|
-
setPreviousValue(null)
|
85
|
-
setOperation(null)
|
86
|
-
setWaitingForOperand(false)
|
87
|
-
}
|
88
|
-
|
89
|
-
const buttonStyle = {
|
90
|
-
padding: '15px',
|
91
|
-
margin: '2px',
|
92
|
-
border: 'none',
|
93
|
-
borderRadius: '4px',
|
94
|
-
cursor: 'pointer',
|
95
|
-
fontSize: '16px',
|
96
|
-
fontWeight: 'bold'
|
97
|
-
}
|
98
|
-
|
99
|
-
return (
|
100
|
-
<div style={{ padding: '20px', maxWidth: '250px' }}>
|
101
|
-
<div style={{
|
102
|
-
background: '#000',
|
103
|
-
color: '#fff',
|
104
|
-
padding: '15px',
|
105
|
-
textAlign: 'right',
|
106
|
-
fontSize: '24px',
|
107
|
-
marginBottom: '10px',
|
108
|
-
borderRadius: '4px',
|
109
|
-
minHeight: '40px',
|
110
|
-
display: 'flex',
|
111
|
-
alignItems: 'center',
|
112
|
-
justifyContent: 'flex-end'
|
113
|
-
}}>
|
114
|
-
{display}
|
115
|
-
</div>
|
116
|
-
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: '2px' }}>
|
117
|
-
<button style={{...buttonStyle, background: '#f0f0f0'}} onClick={clear}>C</button>
|
118
|
-
<button style={{...buttonStyle, background: '#f0f0f0'}} onClick={() => {}}>±</button>
|
119
|
-
<button style={{...buttonStyle, background: '#f0f0f0'}} onClick={() => {}}>%</button>
|
120
|
-
<button style={{...buttonStyle, background: '#ff9500', color: 'white'}} onClick={() => inputOperation('÷')}>÷</button>
|
121
|
-
|
122
|
-
<button style={{...buttonStyle, background: '#333', color: 'white'}} onClick={() => inputNumber(7)}>7</button>
|
123
|
-
<button style={{...buttonStyle, background: '#333', color: 'white'}} onClick={() => inputNumber(8)}>8</button>
|
124
|
-
<button style={{...buttonStyle, background: '#333', color: 'white'}} onClick={() => inputNumber(9)}>9</button>
|
125
|
-
<button style={{...buttonStyle, background: '#ff9500', color: 'white'}} onClick={() => inputOperation('×')}>×</button>
|
126
|
-
|
127
|
-
<button style={{...buttonStyle, background: '#333', color: 'white'}} onClick={() => inputNumber(4)}>4</button>
|
128
|
-
<button style={{...buttonStyle, background: '#333', color: 'white'}} onClick={() => inputNumber(5)}>5</button>
|
129
|
-
<button style={{...buttonStyle, background: '#333', color: 'white'}} onClick={() => inputNumber(6)}>6</button>
|
130
|
-
<button style={{...buttonStyle, background: '#ff9500', color: 'white'}} onClick={() => inputOperation('-')}>-</button>
|
131
|
-
|
132
|
-
<button style={{...buttonStyle, background: '#333', color: 'white'}} onClick={() => inputNumber(1)}>1</button>
|
133
|
-
<button style={{...buttonStyle, background: '#333', color: 'white'}} onClick={() => inputNumber(2)}>2</button>
|
134
|
-
<button style={{...buttonStyle, background: '#333', color: 'white'}} onClick={() => inputNumber(3)}>3</button>
|
135
|
-
<button style={{...buttonStyle, background: '#ff9500', color: 'white'}} onClick={() => inputOperation('+')}>+</button>
|
136
|
-
|
137
|
-
<button style={{...buttonStyle, background: '#333', color: 'white', gridColumn: 'span 2'}} onClick={() => inputNumber(0)}>0</button>
|
138
|
-
<button style={{...buttonStyle, background: '#333', color: 'white'}} onClick={() => {}}>.</button>
|
139
|
-
<button style={{...buttonStyle, background: '#ff9500', color: 'white'}} onClick={performCalculation}>=</button>
|
140
|
-
</div>
|
141
|
-
</div>
|
142
|
-
)
|
143
|
-
}
|
144
|
-
|
145
|
-
// Register custom applications with components
|
146
|
-
const setupCustomApps = () => {
|
147
|
-
// Register Text Editor with actual component
|
148
|
-
defaultAppManager.registerApp({
|
149
|
-
id: 'text-editor-custom',
|
150
|
-
name: 'Advanced Text Editor',
|
151
|
-
description: 'Full-featured text editor with toolbar',
|
152
|
-
icon: '📝',
|
153
|
-
category: 'Productivity',
|
154
|
-
component: <TextEditorComponent />,
|
155
|
-
size: { width: 600, height: 400 }
|
156
|
-
})
|
157
|
-
|
158
|
-
// Register Calculator with actual component
|
159
|
-
defaultAppManager.registerApp({
|
160
|
-
id: 'calculator-custom',
|
161
|
-
name: 'Calculator Pro',
|
162
|
-
description: 'Advanced calculator with full functionality',
|
163
|
-
icon: '🧮',
|
164
|
-
category: 'Utilities',
|
165
|
-
component: <CalculatorComponent />,
|
166
|
-
size: { width: 300, height: 450 }
|
167
|
-
})
|
168
|
-
|
169
|
-
// Register a custom dashboard app
|
170
|
-
defaultAppManager.registerApp({
|
171
|
-
id: 'dashboard',
|
172
|
-
name: 'Dashboard',
|
173
|
-
description: 'System monitoring dashboard',
|
174
|
-
icon: '📊',
|
175
|
-
category: 'System',
|
176
|
-
component: (
|
177
|
-
<div style={{ padding: '20px' }}>
|
178
|
-
<h2>System Dashboard</h2>
|
179
|
-
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '20px', marginTop: '20px' }}>
|
180
|
-
<div style={{ padding: '15px', background: '#e3f2fd', borderRadius: '8px' }}>
|
181
|
-
<h4>CPU Usage</h4>
|
182
|
-
<div style={{ fontSize: '24px', fontWeight: 'bold', color: '#1976d2' }}>45%</div>
|
183
|
-
</div>
|
184
|
-
<div style={{ padding: '15px', background: '#e8f5e8', borderRadius: '8px' }}>
|
185
|
-
<h4>Memory</h4>
|
186
|
-
<div style={{ fontSize: '24px', fontWeight: 'bold', color: '#388e3c' }}>2.1GB</div>
|
187
|
-
</div>
|
188
|
-
<div style={{ padding: '15px', background: '#fff3e0', borderRadius: '8px' }}>
|
189
|
-
<h4>Disk Space</h4>
|
190
|
-
<div style={{ fontSize: '24px', fontWeight: 'bold', color: '#f57c00' }}>78%</div>
|
191
|
-
</div>
|
192
|
-
<div style={{ padding: '15px', background: '#fce4ec', borderRadius: '8px' }}>
|
193
|
-
<h4>Network</h4>
|
194
|
-
<div style={{ fontSize: '24px', fontWeight: 'bold', color: '#c2185b' }}>125 MB/s</div>
|
195
|
-
</div>
|
196
|
-
</div>
|
197
|
-
</div>
|
198
|
-
),
|
199
|
-
size: { width: 500, height: 400 }
|
200
|
-
})
|
201
|
-
}
|
202
|
-
|
203
|
-
// Component that demonstrates using both AppProvider hooks
|
204
|
-
const DemoControls = () => {
|
205
|
-
const { isOpen, open, close, toggle } = useApplicationMenu()
|
206
|
-
const appManager = useAppManager()
|
207
|
-
const [appCount, setAppCount] = React.useState(0)
|
208
|
-
|
209
|
-
React.useEffect(() => {
|
210
|
-
const updateCount = () => setAppCount(appManager.getAllApps().length)
|
211
|
-
updateCount()
|
212
|
-
appManager.addListener(updateCount)
|
213
|
-
return () => appManager.removeListener(updateCount)
|
214
|
-
}, [appManager])
|
215
|
-
|
216
|
-
const addCustomApp = () => {
|
217
|
-
const randomId = `custom-app-${Date.now()}`
|
218
|
-
appManager.registerApp({
|
219
|
-
id: randomId,
|
220
|
-
name: `Custom App ${Math.floor(Math.random() * 100)}`,
|
221
|
-
description: 'Dynamically added application',
|
222
|
-
icon: ['🎨', '🎯', '🎪', '🎭', '🎨'][Math.floor(Math.random() * 5)],
|
223
|
-
category: 'Custom',
|
224
|
-
component: (
|
225
|
-
<div style={{ padding: '20px', textAlign: 'center' }}>
|
226
|
-
<h2>Dynamic App</h2>
|
227
|
-
<p>This app was added dynamically using AppManager!</p>
|
228
|
-
<p>ID: {randomId}</p>
|
229
|
-
</div>
|
230
|
-
),
|
231
|
-
size: { width: 400, height: 300 }
|
232
|
-
})
|
233
|
-
}
|
234
|
-
|
235
|
-
return (
|
236
|
-
<div style={{
|
237
|
-
position: 'absolute',
|
238
|
-
top: '20px',
|
239
|
-
right: '20px',
|
240
|
-
background: 'rgba(255,255,255,0.9)',
|
241
|
-
padding: '20px',
|
242
|
-
borderRadius: '8px',
|
243
|
-
boxShadow: '0 2px 10px rgba(0,0,0,0.1)',
|
244
|
-
maxWidth: '300px'
|
245
|
-
}}>
|
246
|
-
<h4 style={{ margin: '0 0 15px 0' }}>🎮 App Controls</h4>
|
247
|
-
<p style={{ margin: '0 0 10px 0', fontSize: '14px', color: '#666' }}>
|
248
|
-
Menu: <strong>{isOpen ? 'Open' : 'Closed'}</strong><br/>
|
249
|
-
Apps: <strong>{appCount}</strong>
|
250
|
-
</p>
|
251
|
-
|
252
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
|
253
|
-
<button
|
254
|
-
onClick={open}
|
255
|
-
style={{
|
256
|
-
padding: '8px 12px',
|
257
|
-
background: '#4caf50',
|
258
|
-
color: 'white',
|
259
|
-
border: 'none',
|
260
|
-
borderRadius: '4px',
|
261
|
-
cursor: 'pointer',
|
262
|
-
fontSize: '12px'
|
263
|
-
}}
|
264
|
-
>
|
265
|
-
Open Menu
|
266
|
-
</button>
|
267
|
-
<button
|
268
|
-
onClick={close}
|
269
|
-
style={{
|
270
|
-
padding: '8px 12px',
|
271
|
-
background: '#f44336',
|
272
|
-
color: 'white',
|
273
|
-
border: 'none',
|
274
|
-
borderRadius: '4px',
|
275
|
-
cursor: 'pointer',
|
276
|
-
fontSize: '12px'
|
277
|
-
}}
|
278
|
-
>
|
279
|
-
Close Menu
|
280
|
-
</button>
|
281
|
-
<button
|
282
|
-
onClick={toggle}
|
283
|
-
style={{
|
284
|
-
padding: '8px 12px',
|
285
|
-
background: '#2196f3',
|
286
|
-
color: 'white',
|
287
|
-
border: 'none',
|
288
|
-
borderRadius: '4px',
|
289
|
-
cursor: 'pointer',
|
290
|
-
fontSize: '12px'
|
291
|
-
}}
|
292
|
-
>
|
293
|
-
Toggle Menu
|
294
|
-
</button>
|
295
|
-
<hr style={{ margin: '10px 0', border: 'none', borderTop: '1px solid #eee' }} />
|
296
|
-
<button
|
297
|
-
onClick={addCustomApp}
|
298
|
-
style={{
|
299
|
-
padding: '8px 12px',
|
300
|
-
background: '#ff9800',
|
301
|
-
color: 'white',
|
302
|
-
border: 'none',
|
303
|
-
borderRadius: '4px',
|
304
|
-
cursor: 'pointer',
|
305
|
-
fontSize: '12px'
|
306
|
-
}}
|
307
|
-
>
|
308
|
-
Add Custom App
|
309
|
-
</button>
|
310
|
-
</div>
|
311
|
-
</div>
|
312
|
-
)
|
313
|
-
}
|
314
|
-
|
315
|
-
/**
|
316
|
-
* Example component demonstrating the ApplicationMenu system
|
317
|
-
*/
|
318
|
-
export const ApplicationMenuExample = () => {
|
319
|
-
React.useEffect(() => {
|
320
|
-
setupCustomApps()
|
321
|
-
}, [])
|
322
|
-
|
323
|
-
return (
|
324
|
-
<div style={{ height: '100vh', position: 'relative', backgroundColor: '#f0f0f0' }}>
|
325
|
-
<Desktop desktopSize={{ width: 1200, height: 800 }}>
|
326
|
-
{/* Desktop background content */}
|
327
|
-
<div style={{
|
328
|
-
position: 'absolute',
|
329
|
-
top: '20px',
|
330
|
-
left: '20px',
|
331
|
-
background: 'rgba(255,255,255,0.9)',
|
332
|
-
padding: '20px',
|
333
|
-
borderRadius: '8px',
|
334
|
-
boxShadow: '0 2px 10px rgba(0,0,0,0.1)',
|
335
|
-
maxWidth: '400px'
|
336
|
-
}}>
|
337
|
-
<h3 style={{ margin: '0 0 15px 0' }}>🚀 AppProvider + AppManager Demo</h3>
|
338
|
-
<p style={{ margin: '0 0 15px 0', lineHeight: '1.5' }}>
|
339
|
-
AppProvider and AppManager now collaborate seamlessly. The ApplicationMenu gets apps
|
340
|
-
from AppManager through the context. Try adding custom apps dynamically!
|
341
|
-
</p>
|
342
|
-
<div style={{ fontSize: '14px', color: '#666' }}>
|
343
|
-
<p><strong>Collaboration Features:</strong></p>
|
344
|
-
<ul style={{ margin: '5px 0', paddingLeft: '20px' }}>
|
345
|
-
<li>AppProvider provides AppManager via context</li>
|
346
|
-
<li>ApplicationMenu uses useAppManager() hook</li>
|
347
|
-
<li>Dynamic app registration and updates</li>
|
348
|
-
<li>Real-time app count updates</li>
|
349
|
-
<li>Clean separation of concerns</li>
|
350
|
-
</ul>
|
351
|
-
</div>
|
352
|
-
</div>
|
353
|
-
|
354
|
-
{/* Demo controls using the hook */}
|
355
|
-
<DemoControls />
|
356
|
-
</Desktop>
|
357
|
-
</div>
|
358
|
-
)
|
359
|
-
}
|
360
|
-
|
361
|
-
export default ApplicationMenuExample
|