ywana-core8 0.2.9 → 0.2.13
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 +9 -4
- package/dist/index.js +258 -198
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +258 -198
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +258 -198
- package/dist/index.umd.js.map +1 -1
- package/package.json +6 -7
- package/src/desktop/ApplicationMenu.css +4 -3
- package/src/desktop/window.css +5 -1
- package/src/desktop/window.js +3 -1
- package/src/html/switch.example.js +1 -1
- package/src/examples/ApplicationMenuExample.js +0 -361
- package/src/html/switch-debug.js +0 -197
- package/src/html/switch-test-visual.js +0 -294
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ywana-core8",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.13",
|
4
4
|
"description": "ywana-core8",
|
5
5
|
"homepage": "https://ywana.github.io/workspace",
|
6
6
|
"author": "Ernesto Roldan Garcia",
|
@@ -32,6 +32,10 @@
|
|
32
32
|
"svgo": "^3.0.0",
|
33
33
|
"webpack-dev-server": "^4.15.1"
|
34
34
|
},
|
35
|
+
"overrides": {
|
36
|
+
"react": "^19.1.1",
|
37
|
+
"react-dom": "^19.1.1"
|
38
|
+
},
|
35
39
|
"peerDependencies": {
|
36
40
|
"react": "^19.1.1",
|
37
41
|
"react-dom": "^19.1.1"
|
@@ -45,21 +49,16 @@
|
|
45
49
|
"jsdom": "^26.1.0",
|
46
50
|
"react": "^19.1.1",
|
47
51
|
"react-dom": "^19.1.1",
|
48
|
-
"vite": "^7.1.
|
52
|
+
"vite": "^7.1.5"
|
49
53
|
},
|
50
54
|
"dependencies": {
|
51
55
|
"axios": "^1.3.4",
|
52
|
-
"crypto-js": "^4.1.1",
|
53
56
|
"deep-equal": "^2.0.5",
|
54
57
|
"material-design-icons-iconfont": "^6.7.0",
|
55
58
|
"moment": "^2.29.1",
|
56
59
|
"moment-range": "^4.0.2",
|
57
|
-
"react-datepicker": "^4.6.0",
|
58
60
|
"react-error-overlay": "^6.0.10",
|
59
|
-
"react-image-pan-zoom-rotate": "^1.6.0",
|
60
61
|
"react-notifications-component": "^4.0.1",
|
61
|
-
"react-switch": "^6.0.0",
|
62
|
-
"react-syntax-highlighter": "^15.6.6",
|
63
62
|
"resumablejs": "^1.1.0"
|
64
63
|
}
|
65
64
|
}
|
@@ -6,8 +6,8 @@
|
|
6
6
|
left: 0;
|
7
7
|
right: 0;
|
8
8
|
bottom: 0; /* Covers entire workspace container */
|
9
|
-
background: rgba(0, 0, 0, 0.
|
10
|
-
backdrop-filter: blur(
|
9
|
+
background: rgba(0, 0, 0, 0.16);
|
10
|
+
backdrop-filter: blur(1px);
|
11
11
|
z-index: 10000; /* Always above all windows */
|
12
12
|
display: flex;
|
13
13
|
align-items: flex-end;
|
@@ -32,7 +32,8 @@
|
|
32
32
|
box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
|
33
33
|
width: 30rem;
|
34
34
|
max-width: 1000px;
|
35
|
-
height:
|
35
|
+
height: 55vh;
|
36
|
+
min-height: 30rem;
|
36
37
|
max-height: calc(100% - 80px); /* Espacio para taskbar */
|
37
38
|
display: grid;
|
38
39
|
grid-template-rows: auto auto 1fr;
|
package/src/desktop/window.css
CHANGED
@@ -24,6 +24,11 @@
|
|
24
24
|
box-shadow: none;
|
25
25
|
}
|
26
26
|
|
27
|
+
.window--minimized {
|
28
|
+
visibility: hidden;
|
29
|
+
pointer-events: none;
|
30
|
+
}
|
31
|
+
|
27
32
|
.window--dragging {
|
28
33
|
pointer-events: none;
|
29
34
|
}
|
@@ -143,7 +148,6 @@
|
|
143
148
|
/* Content */
|
144
149
|
.window__content {
|
145
150
|
flex: 1;
|
146
|
-
overflow: auto;
|
147
151
|
background: white;
|
148
152
|
}
|
149
153
|
|
package/src/desktop/window.js
CHANGED
@@ -301,12 +301,14 @@ export const Window = ({
|
|
301
301
|
width: maximized ? 'calc(100% - 0px)' : size.width,
|
302
302
|
height: maximized ? 'calc(100% - 50px)' : size.height, // Leave space for taskbar
|
303
303
|
zIndex: zIndex,
|
304
|
-
display
|
304
|
+
// Removed display property - let CSS handle it
|
305
|
+
...(minimized && { visibility: 'hidden' }) // Use visibility instead of display
|
305
306
|
}
|
306
307
|
|
307
308
|
const windowClasses = [
|
308
309
|
'window',
|
309
310
|
maximized && 'window--maximized',
|
311
|
+
minimized && 'window--minimized',
|
310
312
|
isDragging && 'window--dragging',
|
311
313
|
isResizing && 'window--resizing',
|
312
314
|
className
|
@@ -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
|
package/src/html/switch-debug.js
DELETED
@@ -1,197 +0,0 @@
|
|
1
|
-
import React, { useState } from 'react'
|
2
|
-
import RSwitch from 'react-switch'
|
3
|
-
import { Switch, Switch2 } from './switch'
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Componente de debug para verificar que los switches se ven correctamente
|
7
|
-
*/
|
8
|
-
export const SwitchDebug = () => {
|
9
|
-
const [checked, setChecked] = useState(false)
|
10
|
-
|
11
|
-
return (
|
12
|
-
<div style={{ padding: '2rem', maxWidth: '600px' }}>
|
13
|
-
<h1>🔍 Debug de Switches</h1>
|
14
|
-
|
15
|
-
{/* React Switch directo */}
|
16
|
-
<section style={{ marginBottom: '2rem' }}>
|
17
|
-
<h3>React Switch Directo (sin wrapper)</h3>
|
18
|
-
<div style={{
|
19
|
-
background: '#fff',
|
20
|
-
padding: '1.5rem',
|
21
|
-
borderRadius: '8px',
|
22
|
-
border: '1px solid #ddd'
|
23
|
-
}}>
|
24
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: '1rem', marginBottom: '1rem' }}>
|
25
|
-
<span>Estado: {checked ? 'ON' : 'OFF'}</span>
|
26
|
-
<RSwitch
|
27
|
-
checked={checked}
|
28
|
-
onChange={setChecked}
|
29
|
-
onColor="#2693e6"
|
30
|
-
offColor="#ccc"
|
31
|
-
onHandleColor="#ffffff"
|
32
|
-
offHandleColor="#ffffff"
|
33
|
-
handleDiameter={18}
|
34
|
-
uncheckedIcon={false}
|
35
|
-
checkedIcon={false}
|
36
|
-
boxShadow="0px 2px 4px rgba(0, 0, 0, 0.2)"
|
37
|
-
activeBoxShadow="0px 0px 0px 3px rgba(38, 147, 230, 0.2)"
|
38
|
-
height={20}
|
39
|
-
width={48}
|
40
|
-
/>
|
41
|
-
</div>
|
42
|
-
<p style={{ fontSize: '0.9rem', color: '#666' }}>
|
43
|
-
Este es react-switch sin ningún wrapper. Si no se ve bien, el problema es con la librería o CSS global.
|
44
|
-
</p>
|
45
|
-
</div>
|
46
|
-
</section>
|
47
|
-
|
48
|
-
{/* Nuestro Switch wrapper */}
|
49
|
-
<section style={{ marginBottom: '2rem' }}>
|
50
|
-
<h3>Nuestro Switch (wrapper)</h3>
|
51
|
-
<div style={{
|
52
|
-
background: '#fff',
|
53
|
-
padding: '1.5rem',
|
54
|
-
borderRadius: '8px',
|
55
|
-
border: '1px solid #ddd'
|
56
|
-
}}>
|
57
|
-
<Switch
|
58
|
-
id="debug-switch"
|
59
|
-
label="Switch con wrapper"
|
60
|
-
checked={checked}
|
61
|
-
onChange={(id, value) => setChecked(value)}
|
62
|
-
/>
|
63
|
-
<p style={{ fontSize: '0.9rem', color: '#666', marginTop: '1rem' }}>
|
64
|
-
Este usa nuestro wrapper. Debería verse igual que el de arriba.
|
65
|
-
</p>
|
66
|
-
</div>
|
67
|
-
</section>
|
68
|
-
|
69
|
-
{/* Switch2 para comparación */}
|
70
|
-
<section style={{ marginBottom: '2rem' }}>
|
71
|
-
<h3>Switch2 (Material Icons)</h3>
|
72
|
-
<div style={{
|
73
|
-
background: '#fff',
|
74
|
-
padding: '1.5rem',
|
75
|
-
borderRadius: '8px',
|
76
|
-
border: '1px solid #ddd'
|
77
|
-
}}>
|
78
|
-
<Switch2
|
79
|
-
id="debug-switch2"
|
80
|
-
label="Switch2 con iconos"
|
81
|
-
checked={checked}
|
82
|
-
onChange={(id, value) => setChecked(value)}
|
83
|
-
/>
|
84
|
-
<p style={{ fontSize: '0.9rem', color: '#666', marginTop: '1rem' }}>
|
85
|
-
Este usa iconos Material. Debería mostrar toggle_on/toggle_off.
|
86
|
-
</p>
|
87
|
-
</div>
|
88
|
-
</section>
|
89
|
-
|
90
|
-
{/* Diferentes estados */}
|
91
|
-
<section style={{ marginBottom: '2rem' }}>
|
92
|
-
<h3>Diferentes Estados</h3>
|
93
|
-
<div style={{
|
94
|
-
background: '#fff',
|
95
|
-
padding: '1.5rem',
|
96
|
-
borderRadius: '8px',
|
97
|
-
border: '1px solid #ddd'
|
98
|
-
}}>
|
99
|
-
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))', gap: '1rem' }}>
|
100
|
-
<div>
|
101
|
-
<h4>Normal OFF</h4>
|
102
|
-
<RSwitch
|
103
|
-
checked={false}
|
104
|
-
onChange={() => {}}
|
105
|
-
onColor="#2693e6"
|
106
|
-
offColor="#ccc"
|
107
|
-
height={20}
|
108
|
-
width={48}
|
109
|
-
handleDiameter={18}
|
110
|
-
uncheckedIcon={false}
|
111
|
-
checkedIcon={false}
|
112
|
-
/>
|
113
|
-
</div>
|
114
|
-
<div>
|
115
|
-
<h4>Normal ON</h4>
|
116
|
-
<RSwitch
|
117
|
-
checked={true}
|
118
|
-
onChange={() => {}}
|
119
|
-
onColor="#2693e6"
|
120
|
-
offColor="#ccc"
|
121
|
-
height={20}
|
122
|
-
width={48}
|
123
|
-
handleDiameter={18}
|
124
|
-
uncheckedIcon={false}
|
125
|
-
checkedIcon={false}
|
126
|
-
/>
|
127
|
-
</div>
|
128
|
-
<div>
|
129
|
-
<h4>Disabled OFF</h4>
|
130
|
-
<RSwitch
|
131
|
-
checked={false}
|
132
|
-
onChange={() => {}}
|
133
|
-
disabled={true}
|
134
|
-
onColor="#2693e6"
|
135
|
-
offColor="#ccc"
|
136
|
-
height={20}
|
137
|
-
width={48}
|
138
|
-
handleDiameter={18}
|
139
|
-
uncheckedIcon={false}
|
140
|
-
checkedIcon={false}
|
141
|
-
/>
|
142
|
-
</div>
|
143
|
-
<div>
|
144
|
-
<h4>Disabled ON</h4>
|
145
|
-
<RSwitch
|
146
|
-
checked={true}
|
147
|
-
onChange={() => {}}
|
148
|
-
disabled={true}
|
149
|
-
onColor="#2693e6"
|
150
|
-
offColor="#ccc"
|
151
|
-
height={20}
|
152
|
-
width={48}
|
153
|
-
handleDiameter={18}
|
154
|
-
uncheckedIcon={false}
|
155
|
-
checkedIcon={false}
|
156
|
-
/>
|
157
|
-
</div>
|
158
|
-
</div>
|
159
|
-
</div>
|
160
|
-
</section>
|
161
|
-
|
162
|
-
{/* Información de debug */}
|
163
|
-
<section>
|
164
|
-
<h3>Información de Debug</h3>
|
165
|
-
<div style={{
|
166
|
-
background: '#f8f9fa',
|
167
|
-
padding: '1rem',
|
168
|
-
borderRadius: '4px',
|
169
|
-
border: '1px solid #dee2e6'
|
170
|
-
}}>
|
171
|
-
<h4>¿Qué deberías ver?</h4>
|
172
|
-
<ul>
|
173
|
-
<li><strong>Switch OFF:</strong> Fondo gris (#ccc), handle blanco a la izquierda</li>
|
174
|
-
<li><strong>Switch ON:</strong> Fondo azul (#2693e6), handle blanco a la derecha</li>
|
175
|
-
<li><strong>Handle:</strong> Círculo blanco con sombra sutil</li>
|
176
|
-
<li><strong>Transición:</strong> Animación suave al cambiar estado</li>
|
177
|
-
</ul>
|
178
|
-
|
179
|
-
<h4>Si solo ves un círculo gris:</h4>
|
180
|
-
<ul>
|
181
|
-
<li>Verifica que react-switch esté instalado: <code>npm list react-switch</code></li>
|
182
|
-
<li>Revisa la consola del navegador por errores</li>
|
183
|
-
<li>Verifica que no hay CSS conflictivo</li>
|
184
|
-
<li>Asegúrate de que las props de color se están aplicando</li>
|
185
|
-
</ul>
|
186
|
-
|
187
|
-
<h4>Estado actual:</h4>
|
188
|
-
<pre style={{ background: '#fff', padding: '0.5rem', borderRadius: '4px' }}>
|
189
|
-
{JSON.stringify({ checked }, null, 2)}
|
190
|
-
</pre>
|
191
|
-
</div>
|
192
|
-
</section>
|
193
|
-
</div>
|
194
|
-
)
|
195
|
-
}
|
196
|
-
|
197
|
-
export default SwitchDebug
|