-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgallery.html
More file actions
786 lines (688 loc) · 20.4 KB
/
Copy pathgallery.html
File metadata and controls
786 lines (688 loc) · 20.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Component Gallery — LARC PAN</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lexend:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Lexend', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
line-height: 1.6;
color: var(--color-text);
background: var(--color-bg-alt);
}
.container {
max-width: 1400px;
margin: 0 auto;
padding: 2rem;
}
header {
background: var(--color-surface);
border-bottom: 1px solid var(--color-border);
padding: 1.5rem 2rem;
margin-bottom: 2rem;
border-radius: var(--border-radius);
box-shadow: var(--shadow-sm);
display: flex;
justify-content: space-between;
align-items: center;
}
.header-content {
flex: 1;
}
h1 {
font-size: 2.5rem;
font-weight: 700;
color: var(--color-primary);
margin-bottom: 0.5rem;
}
.subtitle {
color: var(--color-text-muted);
font-size: 1.125rem;
}
.filter-bar {
background: var(--color-surface);
padding: 1.5rem;
border-radius: var(--border-radius);
margin-bottom: 2rem;
box-shadow: var(--shadow-sm);
display: flex;
gap: 1rem;
flex-wrap: wrap;
align-items: center;
}
.filter-bar label {
font-weight: 600;
color: var(--color-text-muted);
}
.filter-bar select,
.filter-bar input {
padding: 0.5rem 1rem;
border: 1px solid var(--color-border);
border-radius: 0.5rem;
font-family: inherit;
font-size: 0.95rem;
}
.filter-bar input {
flex: 1;
min-width: 250px;
}
.tag-group {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.tag {
padding: 0.375rem 0.875rem;
border-radius: 2rem;
font-size: 0.875rem;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
border: 1px solid var(--color-border);
background: var(--color-surface);
}
.tag:hover {
background: var(--color-surface-alt);
border-color: var(--color-primary);
}
.tag.active {
background: var(--color-primary);
color: white;
border-color: var(--color-primary);
}
.gallery-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
gap: 2rem;
}
.component-card {
background: var(--color-surface);
border-radius: var(--border-radius);
padding: 1.5rem;
box-shadow: var(--shadow-md);
transition: all 0.3s;
display: flex;
flex-direction: column;
gap: 1rem;
}
.component-card:hover {
box-shadow: var(--shadow-lg);
transform: translateY(-4px);
}
.component-header {
display: flex;
justify-content: space-between;
align-items: start;
gap: 1rem;
}
.component-name {
font-size: 1.25rem;
font-weight: 600;
color: var(--color-primary);
font-family: 'JetBrains Mono', monospace;
}
.status-badge {
padding: 0.25rem 0.625rem;
border-radius: 0.375rem;
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
}
.status-stable {
background: #d1fae5;
color: #065f46;
}
.status-new {
background: #dbeafe;
color: #1e40af;
}
.status-beta {
background: #fef3c7;
color: #92400e;
}
.component-description {
color: var(--color-text-muted);
font-size: 0.95rem;
line-height: 1.5;
}
.component-tags {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.component-tag {
padding: 0.25rem 0.625rem;
background: var(--color-bg-alt);
border-radius: 0.375rem;
font-size: 0.8rem;
color: var(--color-text-muted);
}
.component-preview {
background: var(--color-bg-alt);
border-radius: 0.5rem;
padding: 1rem;
min-height: 120px;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid var(--color-border);
}
.component-actions {
display: flex;
gap: 0.75rem;
}
.btn {
padding: 0.625rem 1.25rem;
border-radius: 0.5rem;
font-weight: 600;
text-decoration: none;
transition: all 0.2s;
cursor: pointer;
border: none;
font-family: inherit;
font-size: 0.9rem;
flex: 1;
text-align: center;
}
.btn-primary {
background: var(--color-primary);
color: white;
}
.btn-primary:hover {
background: var(--color-primary-dark);
}
.btn-secondary {
background: var(--color-surface);
color: var(--color-text);
border: 1px solid var(--color-border);
}
.btn-secondary:hover {
background: var(--color-bg-alt);
border-color: var(--color-primary);
}
.code-snippet {
background: var(--color-code-bg);
color: #e2e8f0;
padding: 1rem;
border-radius: 0.5rem;
font-family: 'JetBrains Mono', monospace;
font-size: 0.875rem;
overflow-x: auto;
line-height: 1.5;
}
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.75);
z-index: 1000;
align-items: center;
justify-content: center;
padding: 2rem;
}
.modal.active {
display: flex;
}
.modal-content {
background: var(--color-surface);
border-radius: var(--border-radius);
max-width: 900px;
width: 100%;
max-height: 90vh;
overflow-y: auto;
box-shadow: var(--shadow-lg);
}
.modal-header {
padding: 1.5rem;
border-bottom: 1px solid var(--color-border);
display: flex;
justify-content: space-between;
align-items: center;
}
.modal-title {
font-size: 1.5rem;
font-weight: 700;
color: var(--color-primary);
}
.modal-close {
font-size: 1.5rem;
border: none;
background: none;
cursor: pointer;
color: var(--color-text-muted);
}
.modal-body {
padding: 1.5rem;
}
.editor-container {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
margin-top: 1rem;
}
.editor-pane {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.editor-label {
font-weight: 600;
color: var(--color-text-muted);
font-size: 0.9rem;
}
.code-editor {
width: 100%;
min-height: 300px;
font-family: 'JetBrains Mono', monospace;
font-size: 0.875rem;
padding: 1rem;
border: 1px solid var(--color-border);
border-radius: 0.5rem;
background: var(--color-code-bg);
color: #e2e8f0;
resize: vertical;
}
.preview-frame {
width: 100%;
min-height: 300px;
border: 1px solid var(--color-border);
border-radius: 0.5rem;
background: var(--color-surface);
}
@media (max-width: 768px) {
.gallery-grid {
grid-template-columns: 1fr;
}
.editor-container {
grid-template-columns: 1fr;
}
h1 {
font-size: 2rem;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<div class="header-content">
<h1>Component Gallery</h1>
<p class="subtitle">Explore, preview, and experiment with all LARC PAN components</p>
</div>
<pan-theme-toggle variant="icon"></pan-theme-toggle>
</header>
<div class="filter-bar">
<input type="text" id="search" placeholder="Search components...">
<label>Filter by:</label>
<div class="tag-group">
<span class="tag active" data-category="all">All</span>
<span class="tag" data-category="core">Core</span>
<span class="tag" data-category="data">Data</span>
<span class="tag" data-category="ui">UI</span>
<span class="tag" data-category="bridge">Bridges</span>
<span class="tag" data-category="new">New</span>
</div>
</div>
<div class="gallery-grid" id="gallery"></div>
</div>
<!-- Modal for live editing -->
<div class="modal" id="playground-modal">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title" id="modal-title">Component Playground</h2>
<button class="modal-close" onclick="closeModal()">×</button>
</div>
<div class="modal-body">
<div class="editor-container">
<div class="editor-pane">
<label class="editor-label">HTML</label>
<textarea class="code-editor" id="code-editor"></textarea>
</div>
<div class="editor-pane">
<label class="editor-label">Live Preview</label>
<iframe class="preview-frame" id="preview-frame"></iframe>
</div>
</div>
</div>
</div>
</div>
<script type="module">
const components = [
{
name: 'pan-bus',
description: 'Core message bus for pub/sub communication. Handles topic routing, retained messages, and cross-shadow-DOM delivery.',
category: ['core'],
status: 'stable',
code: `<pan-bus></pan-bus>
<script type="module">
import { PanClient } from '../src/components/pan-client.mjs';
const pc = new PanClient();
pc.subscribe('test.topic', (msg) => {
console.log('Received:', msg.data);
});
pc.publish({ topic: 'test.topic', data: { hello: 'world' } });
<\/script>`
},
{
name: 'pan-client',
description: 'Client library for interacting with the PAN bus. Provides publish, subscribe, request/reply APIs.',
category: ['core'],
status: 'stable',
code: `<script type="module">
import { PanClient } from '../src/components/pan-client.mjs';
const pc = new PanClient();
// Subscribe to a topic
pc.subscribe('messages.*', (msg) => {
console.log('Topic:', msg.topic);
console.log('Data:', msg.data);
});
// Publish a message
pc.publish({
topic: 'messages.greeting',
data: { text: 'Hello!' },
retain: true
});
<\/script>`
},
{
name: 'pan-router',
description: 'URL router that syncs browser location with nav.state topics. Supports history/hash modes, route guards, and SPA navigation.',
category: ['core', 'new'],
status: 'new',
code: `<pan-bus></pan-bus>
<pan-router mode="history" base="/"></pan-router>
<nav>
<pan-link to="/">Home</pan-link>
<pan-link to="/about">About</pan-link>
<pan-link to="/contact">Contact</pan-link>
</nav>
<div id="content"></div>
<script type="module">
import { PanClient } from '../src/components/pan-client.mjs';
const pc = new PanClient();
pc.subscribe('nav.state', (msg) => {
const content = document.getElementById('content');
content.innerHTML = \`<h1>Current path: \${msg.data.path}</h1>\`;
}, { retained: true });
<\/script>`
},
{
name: 'pan-link',
description: 'Declarative navigation links that publish nav.goto messages. Automatically adds active class when matching current route.',
category: ['ui', 'new'],
status: 'new',
code: `<pan-bus></pan-bus>
<pan-router></pan-router>
<style>
pan-link {
display: inline-block;
padding: 0.5rem 1rem;
color: #6366f1;
}
pan-link.active {
font-weight: bold;
border-bottom: 2px solid #6366f1;
}
</style>
<pan-link to="/">Home</pan-link>
<pan-link to="/about" exact>About</pan-link>
<pan-link to="/profile" replace>Profile</pan-link>`
},
{
name: 'pan-idb',
description: 'IndexedDB bridge that exposes database operations through PAN topics. Supports CRUD, queries, and indexes.',
category: ['data', 'new'],
status: 'new',
code: `<pan-bus></pan-bus>
<pan-idb
database="myapp"
store="users"
key-path="id"
indexes='[{"name":"email","keyPath":"email","unique":true}]'>
</pan-idb>
<script type="module">
import { PanClient } from '../src/components/pan-client.mjs';
const pc = new PanClient();
// Wait for ready
pc.subscribe('users.idb.ready', () => {
// Add a user
pc.publish({
topic: 'users.idb.add',
data: { item: { id: 1, name: 'Alice', email: 'alice@example.com' } }
});
// Query users
pc.publish({
topic: 'users.idb.list',
data: {}
});
}, { retained: true });
// Listen for results
pc.subscribe('users.idb.result', (msg) => {
console.log('Result:', msg.data);
});
<\/script>`
},
{
name: 'pan-websocket',
description: 'Bidirectional WebSocket bridge with automatic reconnection, heartbeat, and topic filtering for real-time communication.',
category: ['bridge', 'new'],
status: 'new',
code: `<pan-bus></pan-bus>
<pan-websocket
url="ws://localhost:8080"
outbound-topics="chat.* user.*"
inbound-topics="*"
auto-reconnect="true"
heartbeat="30">
</pan-websocket>
<script type="module">
import { PanClient } from '../src/components/pan-client.mjs';
const pc = new PanClient();
pc.subscribe('ws.connected', () => {
console.log('WebSocket connected!');
// Send a message
pc.publish({
topic: 'chat.message',
data: { text: 'Hello server!' }
});
});
pc.subscribe('chat.*', (msg) => {
console.log('Chat message:', msg.data);
});
<\/script>`
},
{
name: 'pan-sse',
description: 'Server-Sent Events bridge that converts SSE streams into PAN topics with automatic reconnection and last-event persistence.',
category: ['bridge'],
status: 'stable',
code: `<pan-bus></pan-bus>
<pan-sse
src="/api/events"
topics="notifications updates"
persist-last-event="myapp"
backoff="1000,15000">
</pan-sse>
<script type="module">
import { PanClient } from '../src/components/pan-client.mjs';
const pc = new PanClient();
pc.subscribe('notifications.*', (msg) => {
console.log('Notification:', msg.data);
});
<\/script>`
},
{
name: 'pan-inspector',
description: 'Developer tool for monitoring all PAN messages in real-time. Shows topic, payload size, and timestamp.',
category: ['ui'],
status: 'stable',
code: `<pan-bus></pan-bus>
<pan-inspector style="height: 400px;"></pan-inspector>
<script type="module">
import { PanClient } from '../src/components/pan-client.mjs';
const pc = new PanClient();
// Generate some messages to inspect
setInterval(() => {
pc.publish({
topic: 'demo.heartbeat',
data: { timestamp: Date.now() }
});
}, 2000);
<\/script>`
},
{
name: 'pan-data-table',
description: 'Reactive data table component that subscribes to resource.list.state topics. Supports sorting, pagination, and row selection.',
category: ['ui', 'data'],
status: 'stable',
code: `<pan-bus></pan-bus>
<pan-data-provider-mock resource="users"></pan-data-provider-mock>
<pan-data-table
resource="users"
columns="id,name,email"
page-size="5">
</pan-data-table>`
},
{
name: 'pan-form',
description: 'Form component that binds to resource.item.state and publishes changes. Auto-subscribes on item selection.',
category: ['ui', 'data'],
status: 'stable',
code: `<pan-bus></pan-bus>
<pan-data-provider-mock resource="users"></pan-data-provider-mock>
<pan-form
resource="users"
fields="name,email,role">
</pan-form>`
},
{
name: 'pan-schema-form',
description: 'JSON Schema-driven form with automatic validation, error display, and type-aware input rendering.',
category: ['ui', 'data'],
status: 'stable',
code: `<pan-bus></pan-bus>
<pan-schema resource="users"></pan-schema>
<pan-schema-form resource="users"></pan-schema-form>`
}
];
const gallery = document.getElementById('gallery');
const search = document.getElementById('search');
let currentCategory = 'all';
function renderComponents(filter = '', category = 'all') {
gallery.innerHTML = '';
const filtered = components.filter(comp => {
const matchesSearch = comp.name.toLowerCase().includes(filter.toLowerCase()) ||
comp.description.toLowerCase().includes(filter.toLowerCase());
const matchesCategory = category === 'all' || comp.category.includes(category);
return matchesSearch && matchesCategory;
});
filtered.forEach(comp => {
const card = document.createElement('div');
card.className = 'component-card';
const tags = comp.category.map(cat =>
`<span class="component-tag">${cat}</span>`
).join('');
card.innerHTML = `
<div class="component-header">
<div class="component-name"><${comp.name}></div>
<span class="status-badge status-${comp.status}">${comp.status}</span>
</div>
<div class="component-description">${comp.description}</div>
<div class="component-tags">${tags}</div>
<div class="component-actions">
<button class="btn btn-primary" onclick="openPlayground('${comp.name}')">
Try it
</button>
<a href="../src/components/${comp.name}.mjs" class="btn btn-secondary" target="_blank">
View Source
</a>
</div>
`;
gallery.appendChild(card);
});
if (filtered.length === 0) {
gallery.innerHTML = '<p style="text-align:center;color:var(--color-text-muted);grid-column:1/-1;">No components found.</p>';
}
}
// Search functionality
search.addEventListener('input', (e) => {
renderComponents(e.target.value, currentCategory);
});
// Category filter
document.querySelectorAll('.tag').forEach(tag => {
tag.addEventListener('click', () => {
document.querySelectorAll('.tag').forEach(t => t.classList.remove('active'));
tag.classList.add('active');
currentCategory = tag.dataset.category;
renderComponents(search.value, currentCategory);
});
});
// Playground functionality
window.openPlayground = (componentName) => {
const comp = components.find(c => c.name === componentName);
if (!comp) return;
document.getElementById('modal-title').textContent = `<${componentName}> Playground`;
document.getElementById('code-editor').value = comp.code;
document.getElementById('playground-modal').classList.add('active');
updatePreview();
};
window.closeModal = () => {
document.getElementById('playground-modal').classList.remove('active');
};
function updatePreview() {
const code = document.getElementById('code-editor').value;
const frame = document.getElementById('preview-frame');
const html = `<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
body { font-family: system-ui; padding: 1rem; }
</style>
</head>
<body>
<script type="module">
// Make components available
const base = '${window.location.origin}${window.location.pathname.replace(/\/[^/]*$/, '')}';
window.panAutoload = { componentsPath: base + '/components/' };
<\/script>
<script type="module" src="../src/components/pan-autoload.mjs"><\/script>
${code}
</body>
</html>`;
frame.srcdoc = html;
}
// Live preview updates
document.getElementById('code-editor').addEventListener('input', updatePreview);
// Close modal on escape
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') closeModal();
});
// Close modal on backdrop click
document.getElementById('playground-modal').addEventListener('click', (e) => {
if (e.target.id === 'playground-modal') closeModal();
});
// Initial render
renderComponents();
</script>
<script type="module" src="../src/components/pan-autoload.mjs"></script>
<!-- Theme System -->
<pan-theme-provider theme="auto"></pan-theme-provider>
<script type="module">
import '../src/components/pan-theme-provider.mjs';
import '../src/components/pan-theme-toggle.mjs';
</script>
</body>
</html>