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

0 downloads

dbbasic-web-native/component-library-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
component-library-demo.html · 21.7 KB · 652 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>Semantic Component Library - Demo</title>
7 <script src="semantic-components.js"></script>
8 <style>
9 * {
10 margin: 0;
11 padding: 0;
12 box-sizing: border-box;
13 }
14
15 body {
16 font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
17 background: #000;
18 color: #fff;
19 padding: 48px;
20 line-height: 1.6;
21 }
22
23 .container {
24 max-width: 1400px;
25 margin: 0 auto;
26 }
27
28 header {
29 margin-bottom: 48px;
30 }
31
32 h1 {
33 font-size: 48px;
34 font-weight: 700;
35 margin-bottom: 16px;
36 background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
37 -webkit-background-clip: text;
38 -webkit-text-fill-color: transparent;
39 background-clip: text;
40 }
41
42 .subtitle {
43 font-size: 20px;
44 color: #98989d;
45 }
46
47 section {
48 margin-bottom: 64px;
49 }
50
51 section h2 {
52 font-size: 32px;
53 margin-bottom: 24px;
54 padding-bottom: 16px;
55 border-bottom: 2px solid #38383a;
56 }
57
58 .component-demo {
59 background: #1c1c1e;
60 border: 1px solid #38383a;
61 border-radius: 12px;
62 padding: 32px;
63 margin-bottom: 32px;
64 }
65
66 .demo-title {
67 font-size: 18px;
68 font-weight: 600;
69 margin-bottom: 16px;
70 color: #007aff;
71 }
72
73 .demo-description {
74 font-size: 14px;
75 color: #98989d;
76 margin-bottom: 24px;
77 }
78
79 .grid {
80 display: grid;
81 gap: 24px;
82 }
83
84 .grid-2 {
85 grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
86 }
87
88 .grid-3 {
89 grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
90 }
91
92 .button-group {
93 display: flex;
94 gap: 16px;
95 flex-wrap: wrap;
96 }
97
98 .code-block {
99 background: #0a0a0a;
100 border: 1px solid #38383a;
101 border-radius: 8px;
102 padding: 16px;
103 margin-top: 16px;
104 font-family: 'Monaco', 'Courier New', monospace;
105 font-size: 13px;
106 overflow-x: auto;
107 color: #34c759;
108 }
109
110 .event-log {
111 background: #0a0a0a;
112 border: 1px solid #38383a;
113 border-radius: 8px;
114 padding: 16px;
115 min-height: 100px;
116 max-height: 200px;
117 overflow-y: auto;
118 font-family: 'Monaco', monospace;
119 font-size: 12px;
120 margin-top: 16px;
121 }
122
123 .event-log-entry {
124 padding: 4px 0;
125 border-bottom: 1px solid #38383a;
126 animation: fadeIn 0.3s;
127 }
128
129 @keyframes fadeIn {
130 from { opacity: 0; }
131 }
132
133 .event-timestamp {
134 color: #98989d;
135 margin-right: 8px;
136 }
137
138 .event-type {
139 color: #007aff;
140 font-weight: 600;
141 margin-right: 8px;
142 }
143
144 .event-detail {
145 color: #34c759;
146 }
147
148 .control-panel {
149 background: #2c2c2e;
150 border: 2px solid #38383a;
151 border-radius: 12px;
152 padding: 24px;
153 margin-bottom: 32px;
154 }
155
156 .control-panel h3 {
157 font-size: 16px;
158 text-transform: uppercase;
159 letter-spacing: 1px;
160 margin-bottom: 16px;
161 color: #98989d;
162 }
163
164 .control-group {
165 display: flex;
166 gap: 12px;
167 flex-wrap: wrap;
168 margin-bottom: 16px;
169 }
170
171 .control-btn {
172 padding: 8px 16px;
173 background: #1c1c1e;
174 border: 1px solid #38383a;
175 border-radius: 6px;
176 color: #fff;
177 cursor: pointer;
178 font-size: 14px;
179 transition: all 0.2s;
180 }
181
182 .control-btn:hover {
183 background: #007aff;
184 border-color: #007aff;
185 }
186
187 .control-btn.active {
188 background: #007aff;
189 border-color: #007aff;
190 font-weight: 600;
191 }
192
193 .feedback-container {
194 position: fixed;
195 top: 24px;
196 right: 24px;
197 width: 400px;
198 z-index: 1000;
199 display: flex;
200 flex-direction: column;
201 gap: 8px;
202 }
203
204 card-title {
205 font-size: 20px;
206 font-weight: 600;
207 color: #fff;
208 }
209
210 card-description {
211 color: #98989d;
212 font-size: 14px;
213 }
214 </style>
215</head>
216<body>
217 <div class="container">
218 <header>
219 <h1>Semantic Component Library</h1>
220 <p class="subtitle">Intent-based, context-aware, modality-agnostic web components</p>
221 </header>
222
223 <!-- Context Control Panel -->
224 <div class="control-panel">
225 <h3>Context Simulator</h3>
226 <div class="control-group">
227 <button class="control-btn active" onclick="setModality('screen')">🖥️ Screen</button>
228 <button class="control-btn" onclick="setModality('voice-screen')">🎤 Voice+Screen</button>
229 <button class="control-btn" onclick="setModality('touch')">👆 Touch</button>
230 </div>
231 <div class="control-group">
232 <button class="control-btn" onclick="toggleContext('isBusy')">⏳ Toggle Busy</button>
233 <button class="control-btn" onclick="toggleContext('inFocusMode')">🎯 Toggle Focus</button>
234 <button class="control-btn" onclick="incrementViewers()">👥 Add Viewer</button>
235 </div>
236 </div>
237
238 <!-- Actions Demo -->
239 <section>
240 <h2>01. Actions</h2>
241
242 <div class="component-demo">
243 <div class="demo-title">Primary, Secondary, Tertiary Intents</div>
244 <div class="demo-description">
245 Components declare WHAT the user wants to do, not HOW to do it.
246 Try clicking, long-pressing (500ms), or using keyboard navigation.
247 </div>
248
249 <div class="button-group">
250 <semantic-action intent="primary" sentiment="constructive">
251 Save Document
252 </semantic-action>
253
254 <semantic-action intent="secondary">
255 Export PDF
256 </semantic-action>
257
258 <semantic-action intent="tertiary">
259 Preview
260 </semantic-action>
261
262 <semantic-action intent="secondary" sentiment="destructive">
263 Delete
264 </semantic-action>
265 </div>
266
267 <div class="code-block">
268&lt;semantic-action intent="primary" sentiment="constructive"&gt;
269 Save Document
270&lt;/semantic-action&gt;
271 </div>
272
273 <div class="event-log" id="action-log"></div>
274 </div>
275 </section>
276
277 <!-- Cards Demo -->
278 <section>
279 <h2>02. Cards</h2>
280
281 <div class="component-demo">
282 <div class="demo-title">Inspectable Content</div>
283 <div class="demo-description">
284 Hover to INSPECT (preview), click to ACTIVATE (navigate).
285 On touch devices, long-press to inspect, tap to activate.
286 </div>
287
288 <div class="grid grid-3">
289 <semantic-card>
290 <span slot="media-icon">🚀</span>
291 <card-title slot="title">Project Alpha</card-title>
292 <card-description slot="description">
293 Next-gen platform architecture
294 </card-description>
295 <div slot="preview">
296 <strong>Preview:</strong> Full design system with 50+ components
297 </div>
298 <div slot="actions">
299 <semantic-action intent="tertiary">Share</semantic-action>
300 <semantic-action intent="tertiary">Edit</semantic-action>
301 </div>
302 </semantic-card>
303
304 <semantic-card media-url="https://via.placeholder.com/400x200/667eea/ffffff?text=Project+Beta" media-alt="Project Beta">
305 <card-title slot="title">Project Beta</card-title>
306 <card-description slot="description">
307 Creative design system
308 </card-description>
309 <div slot="preview">
310 <strong>Preview:</strong> 15 team members, 85% complete
311 </div>
312 <div slot="actions">
313 <semantic-action intent="tertiary">Share</semantic-action>
314 <semantic-action intent="tertiary">Edit</semantic-action>
315 </div>
316 </semantic-card>
317
318 <semantic-card>
319 <span slot="media-icon">⚡</span>
320 <card-title slot="title">Project Gamma</card-title>
321 <card-description slot="description">
322 Performance optimization suite
323 </card-description>
324 <div slot="preview">
325 <strong>Preview:</strong> 40% faster load times achieved
326 </div>
327 <div slot="actions">
328 <semantic-action intent="tertiary">Share</semantic-action>
329 <semantic-action intent="tertiary">Edit</semantic-action>
330 </div>
331 </semantic-card>
332 </div>
333
334 <div class="code-block">
335&lt;semantic-card&gt;
336 &lt;span slot="media-icon"&gt;🚀&lt;/span&gt;
337 &lt;card-title slot="title"&gt;Project Alpha&lt;/card-title&gt;
338 &lt;card-description slot="description"&gt;
339 Next-gen platform architecture
340 &lt;/card-description&gt;
341 &lt;div slot="preview"&gt;Preview content here&lt;/div&gt;
342 &lt;div slot="actions"&gt;
343 &lt;semantic-action intent="tertiary"&gt;Share&lt;/semantic-action&gt;
344 &lt;/div&gt;
345&lt;/semantic-card&gt;
346 </div>
347
348 <div class="event-log" id="card-log"></div>
349 </div>
350 </section>
351
352 <!-- Adjusters Demo -->
353 <section>
354 <h2>03. Value Adjusters</h2>
355
356 <div class="component-demo">
357 <div class="demo-title">Multi-Modal Value Control</div>
358 <div class="demo-description">
359 Adjust values via buttons, slider, keyboard, or voice commands.
360 Same component, multiple interaction methods.
361 </div>
362
363 <div class="grid grid-2">
364 <semantic-adjuster
365 label="Volume"
366 value="50"
367 min="0"
368 max="100"
369 step="5">
370 </semantic-adjuster>
371
372 <semantic-adjuster
373 label="Brightness"
374 value="75"
375 min="0"
376 max="100"
377 step="5">
378 </semantic-adjuster>
379 </div>
380
381 <div class="code-block">
382&lt;semantic-adjuster
383 label="Volume"
384 value="50"
385 min="0"
386 max="100"
387 step="5"&gt;
388&lt;/semantic-adjuster&gt;
389 </div>
390
391 <div class="event-log" id="adjuster-log"></div>
392 </div>
393 </section>
394
395 <!-- Feedback Demo -->
396 <section>
397 <h2>04. Feedback & Notifications</h2>
398
399 <div class="component-demo">
400 <div class="demo-title">Context-Aware Notifications</div>
401 <div class="demo-description">
402 Notifications compete for attention based on urgency and context.
403 Try toggling "Busy" or "Focus" mode to see prioritization.
404 </div>
405
406 <div class="button-group">
407 <semantic-action intent="secondary" onclick="showNotification('critical')">
408 Show Critical Alert
409 </semantic-action>
410 <semantic-action intent="secondary" onclick="showNotification('high')">
411 Show High Priority
412 </semantic-action>
413 <semantic-action intent="secondary" onclick="showNotification('medium')">
414 Show Medium Priority
415 </semantic-action>
416 <semantic-action intent="secondary" onclick="showNotification('low')">
417 Show Low Priority
418 </semantic-action>
419 </div>
420
421 <div class="code-block">
422&lt;semantic-feedback urgency="critical" type="notification"&gt;
423 Critical system alert requires immediate attention
424&lt;/semantic-feedback&gt;
425
426&lt;!-- Component automatically:
427 - Prioritizes by urgency
428 - Defers if user is busy
429 - Hides if in focus mode (unless critical)
430 - Adapts presentation to context
431--&gt;
432 </div>
433 </div>
434 </section>
435
436 <!-- Context Awareness Demo -->
437 <section>
438 <h2>05. Context Awareness</h2>
439
440 <div class="component-demo">
441 <div class="demo-title">Automatic Context Adaptation</div>
442 <div class="demo-description">
443 Components automatically adapt to context without developer intervention.
444 All context-aware properties are built-in.
445 </div>
446
447 <div class="grid grid-2">
448 <div>
449 <h4 style="margin-bottom: 16px;">Privacy-Sensitive Content</h4>
450 <semantic-feedback
451 urgency="medium"
452 sensitivity="private"
453 attention-weight="60">
454 <span slot="icon">💬</span>
455 You have 3 new private messages
456 </semantic-feedback>
457 <p style="margin-top: 8px; font-size: 13px; color: #98989d;">
458 Try clicking "Add Viewer" - this will auto-hide
459 </p>
460 </div>
461
462 <div>
463 <h4 style="margin-bottom: 16px;">Deferrable Updates</h4>
464 <semantic-feedback
465 urgency="low"
466 can-defer="true"
467 attention-weight="20">
468 <span slot="icon">⬆️</span>
469 Software update available
470 </semantic-feedback>
471 <p style="margin-top: 8px; font-size: 13px; color: #98989d;">
472 Try toggling "Busy" or "Focus" - this will defer
473 </p>
474 </div>
475 </div>
476
477 <div class="code-block">
478&lt;!-- Privacy-aware --&gt;
479&lt;semantic-feedback sensitivity="private"&gt;
480 Private content automatically hidden with multiple viewers
481&lt;/semantic-feedback&gt;
482
483&lt;!-- Attention-aware --&gt;
484&lt;semantic-feedback urgency="low" can-defer="true"&gt;
485 Defers when user is busy or in focus mode
486&lt;/semantic-feedback&gt;
487
488&lt;!-- No JavaScript required for context handling! --&gt;
489 </div>
490 </div>
491 </section>
492
493 <!-- Integration Demo -->
494 <section>
495 <h2>06. Real-World Example</h2>
496
497 <div class="component-demo">
498 <div class="demo-title">Complete Workflow</div>
499 <div class="demo-description">
500 All components working together in a realistic scenario.
501 </div>
502
503 <div style="margin-bottom: 24px;">
504 <semantic-card>
505 <span slot="media-icon">📝</span>
506 <card-title slot="title">Quarterly Report Draft</card-title>
507 <card-description slot="description">
508 Last edited 5 minutes ago • 3 sections
509 </card-description>
510 <div slot="preview">
511 <strong>Status:</strong> Unsaved changes in Executive Summary, Financial Overview, and Projections sections.
512 </div>
513 <div slot="actions">
514 <semantic-action intent="primary" sentiment="constructive">
515 Save
516 </semantic-action>
517 <semantic-action intent="tertiary">
518 Preview
519 </semantic-action>
520 </div>
521 </semantic-card>
522 </div>
523
524 <div class="grid grid-2">
525 <semantic-adjuster
526 label="Auto-save Interval (minutes)"
527 value="5"
528 min="1"
529 max="30"
530 step="1">
531 </semantic-adjuster>
532
533 <semantic-adjuster
534 label="Font Size"
535 value="16"
536 min="12"
537 max="24"
538 step="1">
539 </semantic-adjuster>
540 </div>
541 </div>
542 </section>
543 </div>
544
545 <!-- Notification Container -->
546 <div class="feedback-container" id="notifications"></div>
547
548 <script>
549 // Event logging
550 function logEvent(logId, type, detail) {
551 const log = document.getElementById(logId);
552 if (!log) return;
553
554 const entry = document.createElement('div');
555 entry.className = 'event-log-entry';
556
557 const timestamp = new Date().toLocaleTimeString();
558 const detailStr = detail ? JSON.stringify(detail) : '';
559
560 entry.innerHTML = `
561 <span class="event-timestamp">${timestamp}</span>
562 <span class="event-type">${type}</span>
563 <span class="event-detail">${detailStr}</span>
564 `;
565
566 log.insertBefore(entry, log.firstChild);
567
568 // Keep only last 10 entries
569 while (log.children.length > 10) {
570 log.removeChild(log.lastChild);
571 }
572 }
573
574 // Listen to all semantic intents
575 document.addEventListener('intent', (e) => {
576 const component = e.target.tagName.toLowerCase();
577 const logMap = {
578 'semantic-action': 'action-log',
579 'semantic-card': 'card-log',
580 'semantic-adjuster': 'adjuster-log'
581 };
582
583 const logId = logMap[component];
584 if (logId) {
585 logEvent(logId, e.detail.type.toUpperCase(), e.detail);
586 }
587 });
588
589 // Context controls
590 function setModality(modality) {
591 window.semanticContext.setModality(modality);
592
593 // Update active button
594 document.querySelectorAll('.control-btn').forEach(btn => {
595 btn.classList.remove('active');
596 });
597 event.target.classList.add('active');
598 }
599
600 function toggleContext(key) {
601 const context = window.semanticContext.context;
602 context.user[key] = !context.user[key];
603 window.semanticContext.updateContext(context);
604 event.target.classList.toggle('active');
605 }
606
607 function incrementViewers() {
608 const context = window.semanticContext.context;
609 context.environment.viewerCount = (context.environment.viewerCount % 5) + 1;
610 window.semanticContext.updateContext(context);
611 event.target.textContent = `👥 ${context.environment.viewerCount} Viewer${context.environment.viewerCount > 1 ? 's' : ''}`;
612 }
613
614 // Notification demo
615 function showNotification(urgency) {
616 const container = document.getElementById('notifications');
617
618 const messages = {
619 'critical': 'Critical: Security alert requires immediate attention',
620 'high': 'High: Meeting starting in 5 minutes',
621 'medium': 'Medium: You have 3 new messages',
622 'low': 'Low: Software update available'
623 };
624
625 const weights = {
626 'critical': 100,
627 'high': 80,
628 'medium': 60,
629 'low': 20
630 };
631
632 const notification = document.createElement('semantic-feedback');
633 notification.setAttribute('urgency', urgency);
634 notification.setAttribute('attention-weight', weights[urgency]);
635 notification.setAttribute('can-defer', urgency === 'low' || urgency === 'medium');
636 notification.textContent = messages[urgency];
637
638 container.appendChild(notification);
639
640 // Auto-remove after 5 seconds
641 setTimeout(() => {
642 notification.remove();
643 }, 5000);
644 }
645
646 // Show welcome notification
647 setTimeout(() => {
648 showNotification('medium');
649 }, 1000);
650 </script>
651</body>
652</html>