-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
858 lines (771 loc) · 30 KB
/
Copy pathindex.html
File metadata and controls
858 lines (771 loc) · 30 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
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Drow.js - Tiny Object-Based Web Component Library</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--dark-bg: #0a0e27;
--darker-bg: #050709;
--card-bg: #0f1436;
--accent-purple: #a78bfa;
--accent-cyan: #06b6d4;
--accent-gold: #fbbf24;
--text-primary: #f1f5f9;
--text-secondary: #cbd5e1;
--border-color: #1e293b;
}
body {
background: linear-gradient(135deg, var(--dark-bg) 0%, #0d1135 100%);
color: var(--text-primary);
font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
line-height: 1.6;
overflow-x: hidden;
}
/* Background animation */
body::before {
content: '';
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background:
radial-gradient(circle at 20% 50%, rgba(167, 139, 250, 0.05) 0%, transparent 50%),
radial-gradient(circle at 80% 80%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
pointer-events: none;
z-index: 0;
}
.container {
position: relative;
z-index: 1;
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
/* Header & Navigation */
header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30px 0;
border-bottom: 1px solid var(--border-color);
backdrop-filter: blur(10px);
position: sticky;
top: 0;
z-index: 100;
}
.logo {
font-size: 28px;
font-weight: 800;
background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
display: flex;
align-items: center;
gap: 8px;
}
.logo-emoji {
font-size: 32px;
}
nav a {
color: var(--text-secondary);
text-decoration: none;
margin-left: 30px;
transition: color 0.3s ease;
font-weight: 500;
}
nav a:hover {
color: var(--accent-purple);
}
/* Hero Section */
.hero {
padding: 100px 0;
text-align: center;
animation: fadeInDown 1s ease-out;
}
.hero h1 {
font-size: 64px;
font-weight: 900;
margin-bottom: 20px;
letter-spacing: -2px;
line-height: 1.1;
}
.hero .subtitle {
font-size: 24px;
color: var(--text-secondary);
margin-bottom: 40px;
max-width: 700px;
margin-left: auto;
margin-right: auto;
}
.cta-buttons {
display: flex;
gap: 20px;
justify-content: center;
flex-wrap: wrap;
margin-bottom: 60px;
}
.btn {
padding: 14px 32px;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
text-decoration: none;
display: inline-block;
}
.btn-primary {
background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
color: white;
box-shadow: 0 4px 15px rgba(167, 139, 250, 0.3);
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(167, 139, 250, 0.4);
}
.btn-secondary {
background: transparent;
color: var(--accent-purple);
border: 2px solid var(--accent-purple);
}
.btn-secondary:hover {
background: rgba(167, 139, 250, 0.1);
transform: translateY(-2px);
}
/* Feature Grid */
.features {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 30px;
margin: 80px 0;
padding: 60px 0;
}
.feature-card {
background: rgba(15, 20, 54, 0.5);
border: 1px solid var(--border-color);
padding: 30px;
border-radius: 12px;
backdrop-filter: blur(10px);
transition: all 0.3s ease;
animation: fadeInUp 0.6s ease-out;
}
.feature-card:hover {
border-color: var(--accent-purple);
transform: translateY(-5px);
box-shadow: 0 10px 30px rgba(167, 139, 250, 0.15);
}
.feature-icon {
font-size: 40px;
margin-bottom: 15px;
}
.feature-card h3 {
font-size: 18px;
margin-bottom: 12px;
color: var(--accent-purple);
}
.feature-card p {
color: var(--text-secondary);
font-size: 14px;
}
/* Code Example */
.code-section {
margin: 100px 0;
padding: 60px 0;
border-top: 1px solid var(--border-color);
border-bottom: 1px solid var(--border-color);
}
.code-section h2 {
font-size: 40px;
margin-bottom: 50px;
text-align: center;
}
.code-example {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 40px;
align-items: center;
}
.code-block {
background: rgba(5, 7, 9, 0.8);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 30px;
overflow-x: auto;
font-family: 'Monaco', 'Courier New', monospace;
font-size: 13px;
line-height: 1.8;
color: var(--text-secondary);
}
.code-block code {
color: var(--text-primary);
}
.keyword { color: var(--accent-purple); }
.string { color: var(--accent-cyan); }
.number { color: var(--accent-gold); }
.code-description {
padding: 20px;
}
.code-description h3 {
color: var(--accent-gold);
margin-bottom: 15px;
font-size: 18px;
}
.code-description p {
color: var(--text-secondary);
margin-bottom: 10px;
}
/* Interactive Demo */
.demo-section {
margin: 100px 0;
padding: 60px 0;
}
.demo-section h2 {
font-size: 40px;
margin-bottom: 50px;
text-align: center;
}
.demo-container {
background: rgba(15, 20, 54, 0.5);
border: 2px solid var(--border-color);
border-radius: 12px;
padding: 40px;
backdrop-filter: blur(10px);
text-align: center;
}
.demo-box {
background: rgba(5, 7, 9, 0.5);
padding: 30px;
border-radius: 8px;
margin-bottom: 20px;
border: 1px solid var(--border-color);
}
.demo-text {
font-size: 18px;
margin-bottom: 20px;
}
.demo-button {
background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
color: white;
border: none;
padding: 12px 24px;
border-radius: 6px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
}
.demo-button:hover {
transform: scale(1.05);
box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
}
.timestamp {
color: var(--accent-gold);
font-weight: 600;
margin-top: 10px;
}
/* Comparison */
.comparison {
margin: 100px 0;
padding: 60px 0;
border-top: 1px solid var(--border-color);
}
.comparison h2 {
font-size: 40px;
margin-bottom: 50px;
text-align: center;
}
.comparison-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 40px;
}
.comparison-box {
background: rgba(15, 20, 54, 0.5);
border: 1px solid var(--border-color);
padding: 40px;
border-radius: 12px;
backdrop-filter: blur(10px);
}
.comparison-box h3 {
font-size: 24px;
margin-bottom: 30px;
}
.drow-box h3 {
color: var(--accent-purple);
}
.comparison-box ul {
list-style: none;
}
.comparison-box li {
padding: 10px 0;
color: var(--text-secondary);
display: flex;
gap: 10px;
}
.comparison-box li::before {
color: var(--accent-gold);
font-weight: bold;
}
.drow-box li::before {
content: '✓';
}
.other-box li::before {
content: '◊';
color: var(--text-secondary);
}
/* Footer */
footer {
border-top: 1px solid var(--border-color);
padding: 60px 0 40px;
margin-top: 100px;
}
.footer-content {
display: grid;
grid-template-columns: 1fr auto auto auto auto;
gap: 40px;
align-items: start;
margin-bottom: 40px;
}
.footer-about p {
color: var(--text-secondary);
max-width: 300px;
}
.footer-link {
display: flex;
flex-direction: column;
}
.footer-link a {
color: var(--text-secondary);
text-decoration: none;
margin-bottom: 10px;
transition: color 0.3s ease;
font-size: 14px;
}
.footer-link a:hover {
color: var(--accent-purple);
}
.footer-bottom {
text-align: center;
color: var(--text-secondary);
font-size: 12px;
padding-top: 20px;
border-top: 1px solid var(--border-color);
}
/* Animations */
@keyframes fadeInDown {
from {
opacity: 0;
transform: translateY(-30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Responsive */
@media (max-width: 768px) {
.hero h1 {
font-size: 42px;
}
.hero .subtitle {
font-size: 18px;
}
.code-example {
grid-template-columns: 1fr;
}
.comparison-grid {
grid-template-columns: 1fr;
}
.footer-content {
grid-template-columns: 1fr;
gap: 20px;
}
nav {
display: none;
}
.feature-card:nth-child(n+4) {
display: none;
}
.feature-card:nth-child(1),
.feature-card:nth-child(2),
.feature-card:nth-child(3) {
animation-delay: calc(var(--index) * 0.1s);
}
}
</style>
</head>
<body>
<div class="container">
<!-- Header -->
<header>
<div class="logo">
<span class="logo-emoji">🎭</span>
Drow
</div>
<nav>
<a href="#features">Features</a>
<a href="#demo">Demo</a>
<a href="#vs">Why Drow?</a>
<a href="https://github.com/johnfacey/drowjs/tree/master/docs">Docs</a>
</nav>
</header>
<!-- Hero Section -->
<section class="hero">
<h1>The Tiny, Object-Based Web Component Library</h1>
<p class="subtitle">Zero dependencies. Under 1kb. No boilerplate. Just pure, native web components.</p>
<div class="cta-buttons">
<a href="https://www.npmjs.com/package/drow" class="btn btn-primary">Install from npm</a>
<a href="https://github.com/johnfacey/drowjs" class="btn btn-secondary">View on GitHub</a>
</div>
</section>
<!-- Features -->
<section class="features" id="features">
<div class="feature-card">
<div class="feature-icon">🚫</div>
<h3>Zero Dependencies</h3>
<p>No npm, no build steps, no headaches. Just include the script and start building.</p>
</div>
<div class="feature-card">
<div class="feature-icon">📉</div>
<h3>Microscopic Size</h3>
<p>Under 1kb gzipped. Your users won't even notice it's loaded.</p>
</div>
<div class="feature-card">
<div class="feature-icon">🧩</div>
<h3>Object-First API</h3>
<p>No classes or complex lifecycles. A single config object handles everything.</p>
</div>
<div class="feature-card">
<div class="feature-icon">⚛️</div>
<h3>Reactive State</h3>
<p>Proxy-based reactivity automatically updates the DOM when your state changes. No manual re-renders.</p>
</div>
<div class="feature-card">
<div class="feature-icon">🔁</div>
<h3>Batched Rendering</h3>
<p>Multiple state mutations in the same frame are coalesced into a single DOM update via <code>requestAnimationFrame</code>.</p>
</div>
<div class="feature-card">
<div class="feature-icon">🔑</div>
<h3>Keyed List Diffing</h3>
<p>Add <code>d-key</code> to a <code>d-for</code> loop and Drow patches only the changed items — no full list rebuild.</p>
</div>
</section>
<!-- Code Example -->
<section class="code-section">
<h2>How Simple Is It?</h2>
<div class="code-example">
<div>
<div class="code-block"><code><span class="keyword">var</span> config = {
<span class="string">"name"</span>: <span class="string">"my-comp"</span>,
<span class="string">"props"</span>: [<span class="string">'title'</span>, <span class="string">'link'</span>],
<span class="string">"template"</span>: <span class="string">`<div>
<h2>{{title}}</h2>
<a href="{{link}}">Visit</a>
</div>`</span>,
<span class="string">"css"</span>: <span class="string">"h2 { color: #a78bfa; }"</span>,
<span class="string">"init"</span>: <span class="keyword">function</span>() {
<span class="comment">// Optional initialization</span>
}
}
Drow.register(config);</code></div>
</div>
<div class="code-description">
<h3>That's All You Need</h3>
<p>✓ Define a name</p>
<p>✓ List your props</p>
<p>✓ Write a template</p>
<p>✓ Add some CSS</p>
<p>✓ Register with Drow</p>
<p style="margin-top: 20px; color: var(--text-primary);">No inheritance. No lifecycle hooks to memorize. No framework complexity.</p>
</div>
</div>
</section>
<!-- Interactive Demo -->
<section class="demo-section" id="demo">
<h2>Try It Live</h2>
<div class="demo-container">
<todo-app></todo-app>
<div style="color: var(--text-secondary); font-size: 14px; margin-top: 30px;">
This component was created with just an object definition. No complex setup required.
</div>
</div>
</section>
<!-- Shared Store Demo -->
<section class="demo-section" style="border-top: 1px solid var(--border-color);">
<h2>Global Store Sync</h2>
<div class="demo-container" style="display: flex; gap: 20px; justify-content: center; flex-wrap: wrap;">
<store-counter></store-counter>
<store-counter></store-counter>
<div style="width: 100%; color: var(--text-secondary); font-size: 14px;">
These two independent components share a single source of truth via <code>Drow.store</code>.
</div>
</div>
</section>
<!-- Dynamic Binding Demo -->
<section class="demo-section" style="border-top: 1px solid var(--border-color);">
<h2>Dynamic Attribute Binding</h2>
<div class="demo-container">
<profile-card></profile-card>
<div style="margin-top: 20px; color: var(--text-secondary); font-size: 14px;">
The <code>src</code> and <code>href</code> attributes above are updated reactively using <code>d-bind</code>.
</div>
</div>
</section>
<!-- Gallery Demo -->
<section class="demo-section" style="border-top: 1px solid var(--border-color);">
<h2>Dynamic Gallery</h2>
<div class="demo-container">
<image-gallery></image-gallery>
<div style="margin-top: 20px; color: var(--text-secondary); font-size: 14px;">
Iterates over objects with <code>d-for="(img, index) in images"</code> and uses <code>d-key="{{img.id}}"</code> for efficient keyed diffing.
</div>
</div>
</section>
<!-- Conditional Rendering Demo -->
<section class="demo-section" style="border-top: 1px solid var(--border-color);">
<h2>Conditional Rendering</h2>
<div class="demo-container">
<status-panel></status-panel>
<div style="margin-top: 20px; color: var(--text-secondary); font-size: 14px;">
Uses <code>d-if</code> / <code>d-else-if</code> / <code>d-else</code> chaining to show different states.
</div>
</div>
</section>
<!-- Comparison -->
<section class="comparison" id="vs">
<h2>Why Choose Drow?</h2>
<div class="comparison-grid">
<div class="comparison-box drow-box">
<h3>Drow.js</h3>
<ul>
<li>Zero dependencies</li>
<li>Simple object syntax</li>
<li>Built-in templating & directives</li>
<li>Tiny bundle size</li>
<li>No build step needed</li>
<li>Proxy-based reactivity</li>
<li>Batched rendering</li>
<li>Keyed list diffing</li>
<li>Scoped CSS in JS</li>
<li>Simplified lifecycle hooks</li>
<li>Native web standards</li>
<li>TypeScript definitions included</li>
</ul>
</div>
<div class="comparison-box other-box">
<h3>React, Vue, Angular...</h3>
<ul>
<li>Complex dependencies</li>
<li>Class or JSX syntax</li>
<li>Multiple abstraction layers</li>
<li>Large bundle size</li>
<li>Build pipeline required</li>
<li>Custom lifecycle hooks</li>
<li>Steep learning curve</li>
<li>Overkill for components</li>
</ul>
</div>
</div>
</section>
</div>
<!-- Footer -->
<footer id="footer">
<div class="container">
<div class="footer-content">
<div class="footer-about">
<h4 style="color: var(--accent-purple); margin-bottom: 15px;">Drow</h4>
<p>A minimalist web component library for developers who value simplicity and control.</p>
</div>
<div class="footer-link">
<strong style="color: var(--accent-purple);">Links</strong>
<a href="https://github.com/johnfacey/drowjs">GitHub</a>
<a href="https://www.npmjs.com/package/drow">NPM</a>
</div>
<div class="footer-link">
<strong style="color: var(--accent-purple);">Community</strong>
<a href="https://x.com/johnfacey">Twitter</a>
<a href="https://johnfacey.dev">Author</a>
</div>
<div class="footer-link">
<strong style="color: var(--accent-purple);">Docs</strong>
<a href="https://github.com/johnfacey/drowjs/tree/master/docs">API Reference</a>
<a href="https://github.com/johnfacey/drowjs/tree/master/docs">README</a>
<a href="https://github.com/johnfacey/drowjs/tree/master/docs">Guides</a>
</div>
</div>
<div class="footer-bottom">
<p>© 2025 Drow.js. Built with simplicity in mind. Inspired by dark elves and clean code.</p>
</div>
</div>
</footer>
<!-- Load Drow.js Library -->
<script src="drow.js"></script>
<script>
// Register the Todo App component for the interactive demo
Drow.register({
name: "todo-app",
state: {
newTask: "",
tasks: ["Master Drow.js", "Build a tiny app"]
},
template: `
<div class="todo-box">
<h3 style="margin-bottom: 15px;">Task List ({{count}})</h3>
<input d-model="newTask" placeholder="Add a new task..." style="color: #333; padding: 8px; border-radius: 4px;">
<button @click="addTask" class="demo-button" style="padding: 8px 16px;">Add</button>
<button @click="clearTasks" class="demo-button" style="padding: 8px 16px; background: transparent; border: 1px solid var(--accent-purple);">Clear</button>
<ul style="list-style: none; margin-top: 20px; text-align: left; max-width: 300px; margin-left: auto; margin-right: auto;">
<li d-for="task in tasks" style="padding: 8px 0; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center;">
<span>{{task}}</span>
<button @click="removeTask" data-item="{{task}}" style="background: #ef4444; color: white; border: none; border-radius: 4px; padding: 2px 8px; cursor: pointer;">x</button>
</li>
</ul>
</div>
`,
computed: {
count: (state) => state.tasks.length
},
methods: {
addTask() {
if (this.state.newTask.trim()) {
this.state.tasks = [...this.state.tasks, this.state.newTask];
this.state.newTask = ""; // Reset input
}
},
removeTask(e) {
const itemToRemove = e.target.dataset.item;
this.state.tasks = this.state.tasks.filter(t => t !== itemToRemove);
},
clearTasks() {
this.state.tasks = [];
}
},
css: `
.todo-box { padding: 1rem; border-radius: 8px; }
input { width: 200px; margin-bottom: 10px; }
`
});
// Shared Store Demo Components
Drow.register({
name: "store-counter",
useStore: true,
methods: {
inc() {
Drow.store.state.globalCount = (Drow.store.state.globalCount || 0) + 1;
}
},
template: `<button @click="inc" class="demo-button">Global Count: {{store.globalCount}}</button>`
});
// Dynamic Binding Demo Component
Drow.register({
name: "profile-card",
state: {
avatar: "https://api.dicebear.com/7.x/avataaars/svg?seed=Felix",
profileUrl: "https://github.com/johnfacey",
username: "johnfacey"
},
methods: {
randomize() {
const seeds = ["Felix", "Aneka", "Jack", "Max", "Midnight"];
const currentSeed = this.state.avatar.split('seed=')[1] || "";
const availableSeeds = seeds.filter(seed => seed !== currentSeed);
const randomSeed = availableSeeds[Math.floor(Math.random() * availableSeeds.length)] || seeds[0];
this.state.avatar = `https://api.dicebear.com/7.x/avataaars/svg?seed=${randomSeed}`;
}
},
template: `
<div style="display: flex; flex-direction: column; align-items: center; gap: 15px;">
<img d-bind:src="avatar" d-bind:alt="username" style="width: 80px; height: 80px; border-radius: 50%; border: 2px solid var(--accent-purple);">
<a d-bind:href="profileUrl" target="_blank" style="color: var(--accent-cyan); text-decoration: none; font-weight: 600;">
View @{{username}} on GitHub
</a>
<button @click="randomize" class="demo-button" style="font-size: 14px; padding: 8px 16px;">Randomize Avatar</button>
</div>
`
});
// Gallery Demo Component (uses d-key and index)
Drow.register({
name: "image-gallery",
state: {
images: [
{ id: 1011, title: "Lake" },
{ id: 1015, title: "River" },
{ id: 1016, title: "Canyon" }
]
},
methods: {
shuffle() {
this.state.images = [...this.state.images].sort(() => Math.random() - 0.5);
}
},
template: `
<div style="display: flex; flex-direction: column; align-items: center; gap: 20px;">
<div style="display: flex; gap: 15px; justify-content: center; flex-wrap: wrap;">
<div d-for="(img, index) in images" d-key="{{img.id}}" style="background: var(--card-bg); padding: 10px; border-radius: 8px; border: 1px solid var(--border-color);">
<img src="https://picsum.photos/id/{{img.id}}/150/100" alt="{{img.title}}" style="border-radius: 4px; display: block; margin-bottom: 8px;">
<span style="font-size: 11px; color: var(--text-secondary);">#{{index}}</span>
<span style="font-size: 12px; color: var(--accent-gold); margin-left: 6px;">{{img.title}}</span>
</div>
</div>
<button @click="shuffle" class="demo-button" style="font-size: 14px; padding: 8px 20px;">Shuffle</button>
</div>
`,
css: `
div:hover {
border-color: var(--accent-cyan) !important;
transform: scale(1.05);
transition: all 0.2s ease;
}
`
});
// Conditional Rendering Demo (d-if / d-else-if / d-else)
Drow.register({
name: "status-panel",
state: { status: "idle" },
methods: {
setIdle() { this.state.status = "idle"; },
setLoading() { this.state.status = "loading"; },
setSuccess() { this.state.status = "success"; },
setError() { this.state.status = "error"; }
},
template: `
<div style="display: flex; flex-direction: column; align-items: center; gap: 20px;">
<div style="min-height: 48px; display: flex; align-items: center; justify-content: center;">
<p d-if="status === 'loading'" style="color: var(--accent-gold); font-size: 18px;">⏳ Loading…</p>
<p d-else-if="status === 'success'" style="color: #4ade80; font-size: 18px;">✅ Success!</p>
<p d-else-if="status === 'error'" style="color: #ef4444; font-size: 18px;">❌ Something went wrong.</p>
<p d-else style="color: var(--text-secondary); font-size: 18px;">⚪ Idle — pick a state below.</p>
</div>
<div style="display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;">
<button @click="setIdle" class="demo-button" style="font-size: 13px; padding: 6px 14px; background: #475569;">Idle</button>
<button @click="setLoading" class="demo-button" style="font-size: 13px; padding: 6px 14px; background: #92400e;">Loading</button>
<button @click="setSuccess" class="demo-button" style="font-size: 13px; padding: 6px 14px; background: #166534;">Success</button>
<button @click="setError" class="demo-button" style="font-size: 13px; padding: 6px 14px; background: #7f1d1d;">Error</button>
</div>
</div>
`
});
</script>
</body>
</html>