100+ copy-paste UI components in plain HTML and CSS: no dependencies, no build step.

0 downloads

dbbasic-web-native/modality-demo.html
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-web-native.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-web-native.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-web-native.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 Add canonical.html v1.0 - The single source of truth for usability standards fb6e650 1 year ago History
modality-demo.html · 29.8 KB · 892 lines
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <title>Modality-Agnostic Web Standard - Demo</title>
7 <style>
8 * {
9 margin: 0;
10 padding: 0;
11 box-sizing: border-box;
12 }
13
14 :root {
15 --primary: #0066cc;
16 --primary-hover: #0052a3;
17 --secondary: #6c757d;
18 --destructive: #dc3545;
19 --success: #28a745;
20 --bg: #0a0a0a;
21 --surface: #1a1a1a;
22 --surface-elevated: #2a2a2a;
23 --text: #ffffff;
24 --text-secondary: #a0a0a0;
25 --border: #333333;
26 --focus: #4d9fff;
27
28 --spacing-xs: 8px;
29 --spacing-sm: 12px;
30 --spacing-md: 16px;
31 --spacing-lg: 24px;
32 --spacing-xl: 32px;
33 --spacing-2xl: 48px;
34
35 --radius-sm: 8px;
36 --radius-md: 12px;
37 --radius-lg: 16px;
38 }
39
40 body {
41 font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
42 background: var(--bg);
43 color: var(--text);
44 line-height: 1.6;
45 font-size: 18px;
46 }
47
48 /* Mode Indicator */
49 .mode-selector {
50 position: fixed;
51 top: var(--spacing-lg);
52 right: var(--spacing-lg);
53 background: var(--surface-elevated);
54 border: 2px solid var(--border);
55 border-radius: var(--radius-md);
56 padding: var(--spacing-md);
57 z-index: 1000;
58 box-shadow: 0 8px 32px rgba(0,0,0,0.4);
59 }
60
61 .mode-selector h3 {
62 font-size: 16px;
63 margin-bottom: var(--spacing-sm);
64 color: var(--text-secondary);
65 text-transform: uppercase;
66 letter-spacing: 1px;
67 }
68
69 .mode-buttons {
70 display: flex;
71 gap: var(--spacing-sm);
72 }
73
74 .mode-btn {
75 padding: var(--spacing-sm) var(--spacing-md);
76 background: var(--surface);
77 border: 2px solid var(--border);
78 border-radius: var(--radius-sm);
79 color: var(--text);
80 cursor: pointer;
81 font-size: 14px;
82 transition: all 0.2s;
83 }
84
85 .mode-btn.active {
86 background: var(--primary);
87 border-color: var(--primary);
88 font-weight: 600;
89 }
90
91 /* Interaction Feedback Overlay */
92 .interaction-overlay {
93 position: fixed;
94 bottom: var(--spacing-lg);
95 left: var(--spacing-lg);
96 background: var(--surface-elevated);
97 border: 2px solid var(--border);
98 border-radius: var(--radius-md);
99 padding: var(--spacing-md);
100 min-width: 300px;
101 z-index: 1000;
102 box-shadow: 0 8px 32px rgba(0,0,0,0.4);
103 }
104
105 .interaction-overlay h3 {
106 font-size: 14px;
107 color: var(--text-secondary);
108 margin-bottom: var(--spacing-sm);
109 text-transform: uppercase;
110 letter-spacing: 1px;
111 }
112
113 .interaction-log {
114 font-family: 'Monaco', 'Courier New', monospace;
115 font-size: 13px;
116 color: var(--success);
117 max-height: 150px;
118 overflow-y: auto;
119 }
120
121 .interaction-log div {
122 margin-bottom: 4px;
123 opacity: 0;
124 animation: fadeIn 0.3s forwards;
125 }
126
127 @keyframes fadeIn {
128 to { opacity: 1; }
129 }
130
131 /* Container */
132 .container {
133 max-width: 1600px;
134 margin: 0 auto;
135 padding: var(--spacing-2xl);
136 }
137
138 header {
139 margin-bottom: var(--spacing-2xl);
140 }
141
142 h1 {
143 font-size: 48px;
144 font-weight: 700;
145 margin-bottom: var(--spacing-md);
146 }
147
148 .subtitle {
149 font-size: 24px;
150 color: var(--text-secondary);
151 }
152
153 /* App Actions - Intent-based buttons */
154 [data-intent] {
155 position: relative;
156 display: inline-flex;
157 align-items: center;
158 justify-content: center;
159 padding: var(--spacing-md) var(--spacing-xl);
160 min-height: 64px;
161 min-width: 120px;
162 border-radius: var(--radius-md);
163 font-size: 20px;
164 font-weight: 600;
165 border: none;
166 cursor: pointer;
167 transition: all 0.2s;
168 user-select: none;
169 -webkit-tap-highlight-color: transparent;
170 }
171
172 [data-intent="primary"] {
173 background: var(--primary);
174 color: white;
175 }
176
177 [data-intent="secondary"] {
178 background: var(--secondary);
179 color: white;
180 }
181
182 [data-intent="tertiary"] {
183 background: transparent;
184 border: 2px solid var(--border);
185 color: var(--text);
186 }
187
188 [data-sentiment="destructive"] {
189 background: var(--destructive);
190 }
191
192 [data-sentiment="constructive"] {
193 background: var(--success);
194 }
195
196 /* Hover state (mouse modality) */
197 body.modality-mouse [data-intent]:hover {
198 transform: translateY(-2px);
199 box-shadow: 0 8px 24px rgba(0,102,204,0.3);
200 }
201
202 body.modality-mouse [data-intent="primary"]:hover {
203 background: var(--primary-hover);
204 }
205
206 /* Active state (all modalities) */
207 [data-intent]:active,
208 [data-intent].activating {
209 transform: scale(0.96);
210 }
211
212 /* Long-press indicator (touch/mouse) */
213 [data-intent].inspecting::after {
214 content: '';
215 position: absolute;
216 inset: -4px;
217 border: 3px solid var(--focus);
218 border-radius: var(--radius-md);
219 animation: pulse 1s infinite;
220 }
221
222 @keyframes pulse {
223 0%, 100% { opacity: 1; }
224 50% { opacity: 0.5; }
225 }
226
227 /* Focus state (keyboard) */
228 [data-intent]:focus-visible {
229 outline: 3px solid var(--focus);
230 outline-offset: 4px;
231 }
232
233 /* Cards with inspect/activate */
234 .app-card {
235 position: relative;
236 background: var(--surface);
237 border: 2px solid var(--border);
238 border-radius: var(--radius-lg);
239 overflow: hidden;
240 cursor: pointer;
241 transition: all 0.3s;
242 user-select: none;
243 }
244
245 body.modality-mouse .app-card:hover {
246 border-color: var(--primary);
247 transform: translateY(-4px);
248 box-shadow: 0 12px 48px rgba(0,0,0,0.4);
249 }
250
251 body.modality-mouse .app-card:hover .card-preview {
252 opacity: 1;
253 transform: translateY(0);
254 }
255
256 .app-card.inspecting {
257 border-color: var(--focus);
258 box-shadow: 0 0 0 4px rgba(77, 159, 255, 0.2);
259 }
260
261 .card-preview {
262 position: absolute;
263 bottom: 100%;
264 left: 0;
265 right: 0;
266 background: var(--surface-elevated);
267 border: 2px solid var(--primary);
268 border-radius: var(--radius-lg);
269 padding: var(--spacing-lg);
270 margin-bottom: var(--spacing-md);
271 opacity: 0;
272 transform: translateY(20px);
273 transition: all 0.3s;
274 pointer-events: none;
275 z-index: 10;
276 }
277
278 .app-card.inspecting .card-preview {
279 opacity: 1;
280 transform: translateY(0);
281 }
282
283 .card-media {
284 width: 100%;
285 height: 240px;
286 background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
287 display: flex;
288 align-items: center;
289 justify-content: center;
290 font-size: 64px;
291 }
292
293 .card-content {
294 padding: var(--spacing-lg);
295 }
296
297 .card-title {
298 font-size: 24px;
299 font-weight: 600;
300 margin-bottom: var(--spacing-sm);
301 }
302
303 .card-description {
304 color: var(--text-secondary);
305 font-size: 16px;
306 }
307
308 .card-actions {
309 padding: var(--spacing-md) var(--spacing-lg);
310 background: var(--surface-elevated);
311 display: flex;
312 gap: var(--spacing-sm);
313 border-top: 1px solid var(--border);
314 }
315
316 .card-actions [data-intent] {
317 min-height: 48px;
318 font-size: 16px;
319 padding: var(--spacing-sm) var(--spacing-md);
320 }
321
322 /* Value Adjustment */
323 .app-input-group {
324 background: var(--surface);
325 border: 2px solid var(--border);
326 border-radius: var(--radius-lg);
327 padding: var(--spacing-lg);
328 }
329
330 .input-label {
331 font-size: 18px;
332 font-weight: 600;
333 margin-bottom: var(--spacing-md);
334 display: block;
335 }
336
337 .value-adjuster {
338 display: flex;
339 align-items: center;
340 gap: var(--spacing-lg);
341 }
342
343 .value-display {
344 font-size: 32px;
345 font-weight: 700;
346 color: var(--primary);
347 min-width: 100px;
348 text-align: center;
349 }
350
351 .adjust-btn {
352 width: 64px;
353 height: 64px;
354 border-radius: 50%;
355 background: var(--surface-elevated);
356 border: 2px solid var(--border);
357 color: var(--text);
358 font-size: 32px;
359 cursor: pointer;
360 transition: all 0.2s;
361 display: flex;
362 align-items: center;
363 justify-content: center;
364 }
365
366 body.modality-mouse .adjust-btn:hover {
367 background: var(--primary);
368 border-color: var(--primary);
369 transform: scale(1.1);
370 }
371
372 .slider-track {
373 flex: 1;
374 height: 8px;
375 background: var(--border);
376 border-radius: 4px;
377 position: relative;
378 cursor: pointer;
379 }
380
381 .slider-fill {
382 height: 100%;
383 background: var(--primary);
384 border-radius: 4px;
385 transition: width 0.2s;
386 }
387
388 .slider-thumb {
389 position: absolute;
390 top: 50%;
391 transform: translate(-50%, -50%);
392 width: 32px;
393 height: 32px;
394 background: white;
395 border: 3px solid var(--primary);
396 border-radius: 50%;
397 cursor: grab;
398 transition: all 0.2s;
399 }
400
401 .slider-thumb:active {
402 cursor: grabbing;
403 transform: translate(-50%, -50%) scale(1.2);
404 }
405
406 /* Grid Layout */
407 .grid {
408 display: grid;
409 gap: var(--spacing-xl);
410 margin-bottom: var(--spacing-2xl);
411 }
412
413 .grid-2 {
414 grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
415 }
416
417 .grid-3 {
418 grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
419 }
420
421 /* Section */
422 section {
423 margin-bottom: var(--spacing-2xl);
424 }
425
426 section h2 {
427 font-size: 32px;
428 margin-bottom: var(--spacing-lg);
429 color: var(--text-secondary);
430 }
431
432 /* Voice Command Indicator */
433 body.modality-voice::before {
434 content: '🎤 Voice Mode Active - Try: "Activate [button]", "Inspect [card]", "Increase volume"';
435 position: fixed;
436 top: 50%;
437 left: 50%;
438 transform: translate(-50%, -50%);
439 background: rgba(0, 102, 204, 0.95);
440 color: white;
441 padding: var(--spacing-xl);
442 border-radius: var(--radius-lg);
443 font-size: 24px;
444 z-index: 999;
445 pointer-events: none;
446 animation: fadeInOut 3s forwards;
447 }
448
449 @keyframes fadeInOut {
450 0%, 100% { opacity: 0; }
451 10%, 90% { opacity: 1; }
452 }
453
454 /* Touch indicators */
455 .touch-ripple {
456 position: absolute;
457 border-radius: 50%;
458 background: rgba(255, 255, 255, 0.5);
459 transform: scale(0);
460 animation: ripple 0.6s ease-out;
461 pointer-events: none;
462 }
463
464 @keyframes ripple {
465 to {
466 transform: scale(4);
467 opacity: 0;
468 }
469 }
470
471 /* Action buttons group */
472 .action-group {
473 display: flex;
474 gap: var(--spacing-md);
475 flex-wrap: wrap;
476 }
477 </style>
478</head>
479<body class="modality-mouse">
480
481 <!-- Mode Selector -->
482 <div class="mode-selector">
483 <h3>Input Modality</h3>
484 <div class="mode-buttons">
485 <button class="mode-btn active" data-mode="mouse">🖱️ Mouse</button>
486 <button class="mode-btn" data-mode="touch">👆 Touch</button>
487 <button class="mode-btn" data-mode="voice">🎤 Voice</button>
488 <button class="mode-btn" data-mode="keyboard">⌨️ Keyboard</button>
489 </div>
490 </div>
491
492 <!-- Interaction Feedback -->
493 <div class="interaction-overlay">
494 <h3>Intent Log</h3>
495 <div class="interaction-log" id="intentLog"></div>
496 </div>
497
498 <div class="container">
499 <header>
500 <h1>Modality-Agnostic Interface</h1>
501 <p class="subtitle">Same semantic intent, different input methods</p>
502 </header>
503
504 <!-- Actions Section -->
505 <section>
506 <h2>01. Actions (Primary Intents)</h2>
507 <div class="action-group">
508 <button
509 data-intent="primary"
510 data-sentiment="constructive"
511 data-action-id="save">
512 Save Document
513 </button>
514 <button
515 data-intent="secondary"
516 data-action-id="export">
517 Export PDF
518 </button>
519 <button
520 data-intent="tertiary"
521 data-action-id="preview">
522 Preview
523 </button>
524 <button
525 data-intent="secondary"
526 data-sentiment="destructive"
527 data-action-id="delete">
528 Delete
529 </button>
530 </div>
531 </section>
532
533 <!-- Cards Section -->
534 <section>
535 <h2>02. Cards (Inspect → Preview, Activate → Navigate)</h2>
536 <div class="grid grid-3">
537 <div class="app-card" data-card-id="project-alpha">
538 <div class="card-preview">
539 <strong>Preview Mode</strong>
540 <p style="margin-top: 8px; font-size: 14px;">
541 Mouse: Hover | Touch: Long-press | Voice: "Inspect Alpha"
542 </p>
543 </div>
544 <div class="card-media">🚀</div>
545 <div class="card-content">
546 <div class="card-title">Project Alpha</div>
547 <div class="card-description">
548 Next-gen platform architecture
549 </div>
550 </div>
551 <div class="card-actions">
552 <button data-intent="tertiary" data-action-id="share-alpha">Share</button>
553 <button data-intent="tertiary" data-action-id="edit-alpha">Edit</button>
554 </div>
555 </div>
556
557 <div class="app-card" data-card-id="project-beta">
558 <div class="card-preview">
559 <strong>Preview Mode</strong>
560 <p style="margin-top: 8px; font-size: 14px;">
561 Mouse: Hover | Touch: Long-press | Voice: "Inspect Beta"
562 </p>
563 </div>
564 <div class="card-media" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);">🎨</div>
565 <div class="card-content">
566 <div class="card-title">Project Beta</div>
567 <div class="card-description">
568 Creative design system
569 </div>
570 </div>
571 <div class="card-actions">
572 <button data-intent="tertiary" data-action-id="share-beta">Share</button>
573 <button data-intent="tertiary" data-action-id="edit-beta">Edit</button>
574 </div>
575 </div>
576
577 <div class="app-card" data-card-id="project-gamma">
578 <div class="card-preview">
579 <strong>Preview Mode</strong>
580 <p style="margin-top: 8px; font-size: 14px;">
581 Mouse: Hover | Touch: Long-press | Voice: "Inspect Gamma"
582 </p>
583 </div>
584 <div class="card-media" style="background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);">⚡</div>
585 <div class="card-content">
586 <div class="card-title">Project Gamma</div>
587 <div class="card-description">
588 Performance optimization suite
589 </div>
590 </div>
591 <div class="card-actions">
592 <button data-intent="tertiary" data-action-id="share-gamma">Share</button>
593 <button data-intent="tertiary" data-action-id="edit-gamma">Edit</button>
594 </div>
595 </div>
596 </div>
597 </section>
598
599 <!-- Value Adjustment Section -->
600 <section>
601 <h2>03. Value Adjustment (Multi-Modal Control)</h2>
602 <div class="grid grid-2">
603 <div class="app-input-group">
604 <label class="input-label">Volume Level</label>
605 <div class="value-adjuster">
606 <button class="adjust-btn" data-adjust="volume" data-direction="decrease">−</button>
607 <div class="value-display" id="volumeDisplay">50</div>
608 <button class="adjust-btn" data-adjust="volume" data-direction="increase">+</button>
609 </div>
610 <div style="margin-top: var(--spacing-lg);">
611 <div class="slider-track" data-slider="volume">
612 <div class="slider-fill" style="width: 50%"></div>
613 <div class="slider-thumb" style="left: 50%"></div>
614 </div>
615 </div>
616 </div>
617
618 <div class="app-input-group">
619 <label class="input-label">Brightness</label>
620 <div class="value-adjuster">
621 <button class="adjust-btn" data-adjust="brightness" data-direction="decrease">−</button>
622 <div class="value-display" id="brightnessDisplay">75</div>
623 <button class="adjust-btn" data-adjust="brightness" data-direction="increase">+</button>
624 </div>
625 <div style="margin-top: var(--spacing-lg);">
626 <div class="slider-track" data-slider="brightness">
627 <div class="slider-fill" style="width: 75%"></div>
628 <div class="slider-thumb" style="left: 75%"></div>
629 </div>
630 </div>
631 </div>
632 </div>
633 </section>
634 </div>
635
636 <script>
637 // State
638 let currentMode = 'mouse';
639 let values = { volume: 50, brightness: 75 };
640 let longPressTimer = null;
641 let activeElement = null;
642
643 // Utility: Log interaction
644 function logIntent(intent, target, modality) {
645 const log = document.getElementById('intentLog');
646 const entry = document.createElement('div');
647 entry.textContent = `[${modality.toUpperCase()}] ${intent}: ${target}`;
648 log.insertBefore(entry, log.firstChild);
649
650 // Keep only last 5 entries
651 while (log.children.length > 5) {
652 log.removeChild(log.lastChild);
653 }
654 }
655
656 // Utility: Create touch ripple effect
657 function createRipple(element, x, y) {
658 const ripple = document.createElement('div');
659 ripple.className = 'touch-ripple';
660 const rect = element.getBoundingClientRect();
661 const size = Math.max(rect.width, rect.height);
662 ripple.style.width = ripple.style.height = size + 'px';
663 ripple.style.left = (x - rect.left - size / 2) + 'px';
664 ripple.style.top = (y - rect.top - size / 2) + 'px';
665 element.style.position = 'relative';
666 element.appendChild(ripple);
667 setTimeout(() => ripple.remove(), 600);
668 }
669
670 // Mode Switching
671 document.querySelectorAll('.mode-btn').forEach(btn => {
672 btn.addEventListener('click', () => {
673 document.querySelectorAll('.mode-btn').forEach(b => b.classList.remove('active'));
674 btn.classList.add('active');
675 currentMode = btn.dataset.mode;
676 document.body.className = `modality-${currentMode}`;
677 logIntent('MODE_CHANGE', currentMode, 'system');
678 });
679 });
680
681 // Action Buttons - Intent-based interactions
682 document.querySelectorAll('[data-intent]').forEach(btn => {
683 const actionId = btn.dataset.actionId;
684
685 // ACTIVATE intent
686 btn.addEventListener('click', (e) => {
687 if (e.target.closest('.card-actions')) {
688 // Card action buttons
689 logIntent('ACTIVATE', actionId || 'card-action', currentMode);
690 } else if (btn.hasAttribute('data-action-id')) {
691 // Regular action buttons
692 btn.classList.add('activating');
693 setTimeout(() => btn.classList.remove('activating'), 200);
694 logIntent('ACTIVATE', actionId, currentMode);
695 }
696 });
697
698 // INSPECT intent (long-press / hover)
699 if (currentMode === 'touch' || currentMode === 'mouse') {
700 btn.addEventListener('mousedown', (e) => {
701 if (currentMode !== 'mouse') {
702 longPressTimer = setTimeout(() => {
703 btn.classList.add('inspecting');
704 logIntent('INSPECT', actionId, currentMode);
705 }, 500);
706 }
707 });
708
709 btn.addEventListener('mouseup', () => {
710 clearTimeout(longPressTimer);
711 btn.classList.remove('inspecting');
712 });
713
714 btn.addEventListener('mouseleave', () => {
715 clearTimeout(longPressTimer);
716 btn.classList.remove('inspecting');
717 });
718 }
719
720 // Touch ripple effect
721 btn.addEventListener('touchstart', (e) => {
722 const touch = e.touches[0];
723 createRipple(btn, touch.clientX, touch.clientY);
724 });
725 });
726
727 // Cards - Inspect (preview) and Activate (navigate)
728 document.querySelectorAll('.app-card').forEach(card => {
729 const cardId = card.dataset.cardId;
730
731 // ACTIVATE intent (tap/click on card)
732 card.addEventListener('click', (e) => {
733 if (!e.target.closest('.card-actions')) {
734 logIntent('ACTIVATE', `navigate to ${cardId}`, currentMode);
735 }
736 });
737
738 // INSPECT intent (hover for mouse)
739 if (currentMode === 'mouse') {
740 card.addEventListener('mouseenter', () => {
741 logIntent('INSPECT', `preview ${cardId}`, 'mouse');
742 });
743 }
744
745 // INSPECT intent (long-press for touch)
746 card.addEventListener('mousedown', (e) => {
747 if (currentMode === 'touch' && !e.target.closest('.card-actions')) {
748 longPressTimer = setTimeout(() => {
749 card.classList.add('inspecting');
750 logIntent('INSPECT', `preview ${cardId}`, 'touch');
751 }, 500);
752 }
753 });
754
755 card.addEventListener('mouseup', () => {
756 clearTimeout(longPressTimer);
757 setTimeout(() => card.classList.remove('inspecting'), 2000);
758 });
759
760 card.addEventListener('mouseleave', () => {
761 clearTimeout(longPressTimer);
762 card.classList.remove('inspecting');
763 });
764
765 // Touch ripple
766 card.addEventListener('touchstart', (e) => {
767 const touch = e.touches[0];
768 createRipple(card, touch.clientX, touch.clientY);
769 });
770 });
771
772 // Value Adjustment - ADJUST intent
773 function updateValue(type, delta) {
774 values[type] = Math.max(0, Math.min(100, values[type] + delta));
775 const display = document.getElementById(`${type}Display`);
776 const slider = document.querySelector(`[data-slider="${type}"]`);
777 const fill = slider.querySelector('.slider-fill');
778 const thumb = slider.querySelector('.slider-thumb');
779
780 display.textContent = values[type];
781 fill.style.width = values[type] + '%';
782 thumb.style.left = values[type] + '%';
783
784 logIntent('ADJUST', `${type} to ${values[type]}`, currentMode);
785 }
786
787 document.querySelectorAll('[data-adjust]').forEach(btn => {
788 btn.addEventListener('click', () => {
789 const type = btn.dataset.adjust;
790 const direction = btn.dataset.direction;
791 const delta = direction === 'increase' ? 5 : -5;
792 updateValue(type, delta);
793 });
794 });
795
796 // Slider dragging
797 document.querySelectorAll('.slider-track').forEach(track => {
798 const type = track.dataset.slider;
799 let isDragging = false;
800
801 function updateFromPosition(clientX) {
802 const rect = track.getBoundingClientRect();
803 const percent = Math.max(0, Math.min(100, ((clientX - rect.left) / rect.width) * 100));
804 values[type] = Math.round(percent);
805
806 const display = document.getElementById(`${type}Display`);
807 const fill = track.querySelector('.slider-fill');
808 const thumb = track.querySelector('.slider-thumb');
809
810 display.textContent = values[type];
811 fill.style.width = values[type] + '%';
812 thumb.style.left = values[type] + '%';
813 }
814
815 track.addEventListener('mousedown', (e) => {
816 isDragging = true;
817 updateFromPosition(e.clientX);
818 logIntent('ADJUST_START', `${type} dragging`, currentMode);
819 });
820
821 document.addEventListener('mousemove', (e) => {
822 if (isDragging) {
823 updateFromPosition(e.clientX);
824 }
825 });
826
827 document.addEventListener('mouseup', () => {
828 if (isDragging) {
829 logIntent('ADJUST_END', `${type} to ${values[type]}`, currentMode);
830 isDragging = false;
831 }
832 });
833
834 // Touch support
835 track.addEventListener('touchstart', (e) => {
836 isDragging = true;
837 updateFromPosition(e.touches[0].clientX);
838 logIntent('ADJUST_START', `${type} dragging`, 'touch');
839 });
840
841 document.addEventListener('touchmove', (e) => {
842 if (isDragging) {
843 updateFromPosition(e.touches[0].clientX);
844 }
845 });
846
847 document.addEventListener('touchend', () => {
848 if (isDragging) {
849 logIntent('ADJUST_END', `${type} to ${values[type]}`, 'touch');
850 isDragging = false;
851 }
852 });
853 });
854
855 // Keyboard Navigation (simulated)
856 document.addEventListener('keydown', (e) => {
857 if (currentMode === 'keyboard') {
858 if (e.key === 'Enter' && document.activeElement.hasAttribute('data-intent')) {
859 const actionId = document.activeElement.dataset.actionId;
860 logIntent('ACTIVATE', actionId, 'keyboard');
861 }
862 }
863 });
864
865 // Voice Commands (simulated)
866 window.addEventListener('keydown', (e) => {
867 if (e.key === 'v' && e.ctrlKey && currentMode === 'voice') {
868 const commands = [
869 'activate save',
870 'inspect project alpha',
871 'increase volume',
872 'navigate to project beta'
873 ];
874 const cmd = commands[Math.floor(Math.random() * commands.length)];
875 logIntent('VOICE_COMMAND', cmd, 'voice');
876
877 // Simulate command execution
878 if (cmd.includes('increase volume')) {
879 updateValue('volume', 10);
880 } else if (cmd.includes('inspect')) {
881 const card = document.querySelector('[data-card-id="project-alpha"]');
882 card.classList.add('inspecting');
883 setTimeout(() => card.classList.remove('inspecting'), 2000);
884 }
885 }
886 });
887
888 // Initial log
889 logIntent('SYSTEM_READY', 'Demo initialized', 'system');
890 </script>
891</body>
892</html>